Skip to content
Snippets Groups Projects
Commit 2fa3fee4 authored by Johannes Mey's avatar Johannes Mey
Browse files

update main doc page

parent 56f21b90
No related branches found
No related tags found
No related merge requests found
......@@ -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
![](diagrams/grammar/uml.png)
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment