Skip to content
Snippets Groups Projects
Commit ddf2733d authored by yakomaxa's avatar yakomaxa
Browse files

Rasmol parser WIP 3

parent cf65bfbc
No related branches found
No related tags found
No related merge requests found
...@@ -30,7 +30,11 @@ const propertiesDict = h.getPropertyRules(special_properties); ...@@ -30,7 +30,11 @@ const propertiesDict = h.getPropertyRules(special_properties);
const slash = P.MonadicParser.string('/'); const slash = P.MonadicParser.string('/');
const dot = P.MonadicParser.string('.'); const dot = P.MonadicParser.string('.');
const colon = P.MonadicParser.string(':'); const colon = P.MonadicParser.string(':');
const comma = P.MonadicParser.string(',');
const star = P.MonadicParser.string('*'); const star = P.MonadicParser.string('*');
const bra = P.MonadicParser.string('[');
const ket = P.MonadicParser.string(']');
const numbers = P.MonadicParser.regexp(/[0-9]/);
/* is Parser -> MonadicParser substitution correct? */ /* is Parser -> MonadicParser substitution correct? */
function orNull(rule: P.MonadicParser<any>) { function orNull(rule: P.MonadicParser<any>) {
...@@ -164,7 +168,20 @@ const lang = P.MonadicParser.createLanguage({ ...@@ -164,7 +168,20 @@ const lang = P.MonadicParser.createLanguage({
Expression: function (r: any) { Expression: function (r: any) {
return P.MonadicParser.alt( return P.MonadicParser.alt(
// r.NamedAtomProperties, // r.NamedAtomProperties,
// r.AtomExpression.map(atomExpressionQuery),
r.AtomSelectionMacro.map(atomSelectionQuery2), r.AtomSelectionMacro.map(atomSelectionQuery2),
// r.AtomSelectionMacroResi.map(atomSelectionQuery2),
// r.Keywords,
// r.Resno.lookahead(P.MonadicParser.regexp(/\s*(?!(LIKE|>=|<=|!=|[:^%/.=><]))/i)).map((x: any) => B.struct.generator.atomGroups({
// 'residue-test': B.core.rel.eq([B.ammp('auth_seq_id'), x])
// })),
// r.ValueQuery,
// r.Element.map((x: string) => B.struct.generator.atomGroups({
// 'atom-test': B.core.rel.eq([B.acp('elementSymbol'), B.struct.type.elementSymbol(x)])
// })),
// r.Resname.map((x: string) => B.struct.generator.atomGroups({
// 'residue-test': B.core.rel.eq([B.ammp('label_comp_id'), x])
// })),
); );
}, },
...@@ -197,12 +214,13 @@ const lang = P.MonadicParser.createLanguage({ ...@@ -197,12 +214,13 @@ const lang = P.MonadicParser.createLanguage({
orNull(propertiesDict.name).skip(dot) orNull(propertiesDict.name).skip(dot)
).map(x => { return {name: x[0] }; }), ).map(x => { return {name: x[0] }; }),
)), )),
P.MonadicParser.alt(
P.MonadicParser.seq(
orNull(propertiesDict.resi),
).map(x => { return { resi: x[0]}; }),
),
// 1-100 lys:a.ca lys:a lys lys.ca // 1-100 lys:a.ca lys:a lys lys.ca
// numbers.then(P.MonadicParser.alt(
// P.MonadicParser.alt(
// P.MonadicParser.seq(
// orNull(propertiesDict.resi),
// ).map(x => { return { resi: x[0] };})
// ))),
P.MonadicParser.alt( P.MonadicParser.alt(
P.MonadicParser.seq( P.MonadicParser.seq(
orNull(propertiesDict.resn).skip(colon), orNull(propertiesDict.resn).skip(colon),
...@@ -227,12 +245,22 @@ const lang = P.MonadicParser.createLanguage({ ...@@ -227,12 +245,22 @@ const lang = P.MonadicParser.createLanguage({
orNull(propertiesDict.name), orNull(propertiesDict.name),
).map(x => { return { resn: x[0], name: x[1] }; }), ).map(x => { return { resn: x[0], name: x[1] }; }),
P.MonadicParser.seq( P.MonadicParser.seq(
orNull(propertiesDict.resn) orNull(propertiesDict.resn),
).map(x => { return { resn: x[0] };}), ).map(x => { return { resn: x[0] };}),
), ),
); );
}, },
AtomSelectionMacroResi: function (r: any) {
return P.MonadicParser.alt(
P.MonadicParser.alt(
P.MonadicParser.seq(
orNull(propertiesDict.resi)
).map(x => { return { resi: x[0] };}),
),
);
},
ObjectProperty: () => { ObjectProperty: () => {
const w = h.getReservedWords(special_properties, special_keywords, special_operators) const w = h.getReservedWords(special_properties, special_keywords, special_operators)
.sort(h.strLenSortFn).map(h.escapeRegExp).join('|'); .sort(h.strLenSortFn).map(h.escapeRegExp).join('|');
...@@ -264,7 +292,7 @@ const lang = P.MonadicParser.createLanguage({ ...@@ -264,7 +292,7 @@ const lang = P.MonadicParser.createLanguage({
P.MonadicParser.alt( P.MonadicParser.alt(
r.ValueRange, r.ValueRange,
r.Value r.Value
).sepBy1(P.MonadicParser.comma) ).sepBy1(comma)
).map(x => { ).map(x => {
const [property, values] = x; const [property, values] = x;
const listValues: (string | number)[] = []; const listValues: (string | number)[] = [];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment