Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
motion-grammar-example
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JastAdd
motion-grammar-example
Commits
2fa3fee4
Commit
2fa3fee4
authored
3 years ago
by
Johannes Mey
Browse files
Options
Downloads
Patches
Plain Diff
update main doc page
parent
56f21b90
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
pages/docs/index.md
+5
-30
5 additions, 30 deletions
pages/docs/index.md
with
5 additions
and
30 deletions
pages/docs/index.md
+
5
−
30
View file @
2fa3fee4
...
...
@@ -8,37 +8,12 @@ The motion grammar describes the Load/Unload scenario from Dantam[^1]. The point
to show how motion grammars work, but rather the expressiveness of a CFG (compared to a regular grammar), but it is very
simple, so it serves as a starting point.
##
Grammar
##
Motion Grammars in JastAdd

The grammar comprises three parts.
`MotionGrammar`
contains generic nonterminals present in every motion
grammar,
`LoadUnload`
has the actual nonterminals of the grammar, and
`World`
describes the context within which the
grammar is parsed.
## Execution (Parsing) and Implementation Details
Currently, the parser reads a sequence of
`Load`
,
`Unload`
, and
`Full`
tokens and loads a
`Container`
with up to ten
elements.
There are no attributes used so far, but at each point where a semantic action takes place, the AST is printed to a
file in
`src/gen/resources/diagrams/parsing`
, demonstrating the "available" part of the AST, which could be used by
attributes. This trace is shown
[
here
](
/load-parsing
)
.
Detailed notes:
-
Tokens can have semantic actions. This might be a difference to the original motion grammar concept, but could easily
be simulated by adding another nonterminal enclosing each token.
-
The
`Load`
token currently can always be parsed. This is problematic, since it requires a fixed order in the parser
rule for
`T`
. A workaround would be to introduce a new token
`NotFull`
before the load token.
-
The parser
`Worldparser.java`
uses three kinds of parse methods:
-
`parseT`
distinguishes an abstract rule. This only works like this if the abstract rule does
*not*
have any
elements, which can be achieved by a simple transformation, but maybe breaks the attribute part of the grammar.
This method needs a lookahead, which is done by a peek method. The peek method actually parses the next token and
keeps it in a cache, which is read by the token parse method later.
-
`parseT1`
and
`parseT2`
do not need lookahead.
-
`parseLoad`
,
`parseUnload`
, and
`parseFull`
parse tokens.
-
There are no thoughts on parsing lists and optional children yet.
A JastAdd motion grammar comprises three parts.
`MotionGrammar`
contains generic nonterminals present in every motion
grammar, a second, use-case-specific grammar has the actual nonterminals of the grammar as well as additonal information
to construct a parser, and finally a third
*context grammar*
that describes the context within which the motion grammar
is parsed.
## Bibliogaphy
...
...
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