We are currently developing a JavaScript (Ecma-262) editor, including a Dynamic lexical parser and a semantic parser generated by the SyntaxEditor Parser Generator.
We're about 90% through implementing the language and we hit a couple of interesting snags in the language:
- Automatic Semicolon Insertion (ASI)
- Various Non-Terminal Ambiguities
- Left recursion
Most of the ambiguities and recursion issues we were able to factor out by modifying the grammar accordingly. We have two remaining ambiguities, as well as ASI left to implement in the grammar.
We determined that the best approach for implementing both ASI and our two remaining ambiguities would be through simple backtracking (i.e. try one alternation, and if it fails, backtrack to the start point of that non-terminal, and try the second alternation).
We're a little puzzled how we can implement backtracking from within the semantic parser. It would seem that ReadReverse would do the trick, but the stream is not accessible from within the semantic parser.
Any tips?
We're about 90% through implementing the language and we hit a couple of interesting snags in the language:
- Automatic Semicolon Insertion (ASI)
- Various Non-Terminal Ambiguities
- Left recursion
Most of the ambiguities and recursion issues we were able to factor out by modifying the grammar accordingly. We have two remaining ambiguities, as well as ASI left to implement in the grammar.
We determined that the best approach for implementing both ASI and our two remaining ambiguities would be through simple backtracking (i.e. try one alternation, and if it fails, backtrack to the start point of that non-terminal, and try the second alternation).
We're a little puzzled how we can implement backtracking from within the semantic parser. It would seem that ReadReverse would do the trick, but the stream is not accessible from within the semantic parser.
Any tips?