Today I want to talk about GLR parsing and the internals of the JS++ parser.
The Problem
In JS++, there is the potential for code to be “ambiguous”. For instance, consider the following example:
Foo<bar> baz;
There are two interpretations for the above statement:
1. A comparison operation: Foo
is less than bar
is greater than baz
.
2. A variable declaration with type Foo<bar>
(where Foo
is a generic type with type argument bar
)
Since JS++ is a superset of the JavaScript programming language, we would naturally expect the first case since JS++ inherited this from JavaScript. However, in order to achieve a concise syntax for generic types, we also need to consider how we can enable the second case.
Continue reading “Compiler Architecture: GLR Parsing and Disambiguation”