Kennt sich jemand mit dem Parsergenerator Cup aus? (http://www.cs.princeton.edu/~appel/modern/java/CUP/)
Im Manual wird die Option -nopositions nur kurz erläutert:
This option keeps CUP from generating code to propagate the left and right hand values of terminals to non-terminals, and then from non-terminals to other terminals. If the left and right values aren’t going to be used by the parser, then it will save some runtime computation to not generate these position propagations. This option also keeps the left and right label variables from being generated, so any reference to these will cause an error.
Meine erste Vermutung war, dass folgende Regeln:
(kleine Buchstaben = non-terminals;
grosse Buchstaben = terminals)
a -> b
b -> A
Zu:
a -> A
optimert werden.
Der Dump zeigt aber keine Optimierung:
===== Terminals =====
[0]EOF [1]error [2]A
===== Non terminals =====
[0]$START [1]a [2]b
===== Productions =====
[0] a ::= b
[1] $START ::= a EOF
[2] b ::= A
===== Viable Prefix Recognizer =====
START lalr\_state [0]: {
[b ::= (\*) A , {EOF }]
[$START ::= (\*) a EOF , {EOF }]
[a ::= (\*) b , {EOF }]
}
transition on a to state [3]
transition on A to state [2]
transition on b to state [1]
-------------------
lalr\_state [1]: {
[a ::= b (\*) , {EOF }]
}
-------------------
lalr\_state [2]: {
[b ::= A (\*) , {EOF }]
}
-------------------
lalr\_state [3]: {
[$START ::= a (\*) EOF , {EOF }]
}
transition on EOF to state [4]
-------------------
lalr\_state [4]: {
[$START ::= a EOF (\*) , {EOF }]
}
-------------------
-------- ACTION\_TABLE --------
From state #0
[term 2:SHIFT(to state 2)]
From state #1
[term 0:REDUCE(with prod 0)]
From state #2
[term 0:REDUCE(with prod 2)]
From state #3
[term 0:SHIFT(to state 4)]
From state #4
[term 0:REDUCE(with prod 1)]
------------------------------
-------- REDUCE\_TABLE --------
From state #0
[non term 1-\>state 3] [non term 2-\>state 1]
From state #1
From state #2
From state #3
From state #4
-----------------------------
Hat jemand eine Ahnung was diese Option bedeuten könnte?
Wenn ja könnte jemand ein Beispiel angeben in dem diese Option verdeutlicht wird.
Gruß Christian