Repository navigation
Lexer Semantic Builder
We want an easy way to define complex tokens, possibly with recursion and complex data types. Building a DFA supporting this all is often a bad practise:
- States grows, minimization becomes harder
- Slower generation and compilation time
- DFA runtime and types become complex to maintain
- Hard to maintain correctly that complex logic
- Errors are the worst possible
Token construction is moved to Action and LR-like tables
Initially the concept was using SHIFT and REDUCE commands in a separate table, but the concept moved to BEGIN, END and REDUCE commands DFA state may point to LR state by index <DFA.size() + LR state>. It can point to BEGIN command to capture something, END to stop capturing this and REDUCE to push all captured content as token known by REDUCE command
An action table can be pointed by <DFA.size() + LR.size() + Action state> This is large switch function where it can execute semantic actions, potentially allowing context sensitive lexing and some advanced token construction ways. This also would be used for errors inside lexer (e.g action state calls fail function)