rzel / mini-java

Automatically exported from code.google.com/p/mini-java
0 stars 0 forks source link

Add class SyntaxSpec #20

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
A SyntaxSpec represents a syntax specification which contains a set of
production rules. Client can query rules by providinig dfa(nfa) states.
SyntaxSpec can also create a DFA which represents the syntax, and will be
used by Parser when doing parsing.

Activity Flow:
1. Read in lines from a given Stream
2. Create rules and call parse() on those lines
3. For each item, add transitions
3.5 For each "END" symbol, add mapping entry from "END" to the Rule
4. Create a dfa(nfa) state for the RHS if there's none (InitialState for
"START"
5. For each rule, walkthrough the LHS, add epsilon transitions from it to
its corresponding Non-terminal dfa(nfa) state if it's a non-terminal symbol
6. Call createDFA() on the NFA and returns the DFA

Original issue reported on code.google.com by lemontree.cool on 7 Sep 2008 at 1:43

GoogleCodeExporter commented 9 years ago
Remove step 3.5 and add step 6.5 as follow:
6.5 Run the DFA with each rule as input, and record the result state

NOTE: we don't need to add an "END" symbol actually; just one more transition 
should
be sufficient

Original comment by lemontree.cool on 7 Sep 2008 at 1:47

GoogleCodeExporter commented 9 years ago

Original comment by lemontree.cool on 30 Sep 2008 at 11:54