Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
ddf2733d
Commit
ddf2733d
authored
2 years ago
by
yakomaxa
Browse files
Options
Downloads
Patches
Plain Diff
Rasmol parser WIP 3
parent
cf65bfbc
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mol-script/transpilers/rasmol/parser.ts
+38
-10
38 additions, 10 deletions
src/mol-script/transpilers/rasmol/parser.ts
with
38 additions
and
10 deletions
src/mol-script/transpilers/rasmol/parser.ts
+
38
−
10
View file @
ddf2733d
...
@@ -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
)[]
=
[];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment