LLK

Features

Features

  • LL(k) lexer
  • LLK user LL(k) rules for lexer. There are a number of optimizations in syntax and code generation that make it more efficent. For example, code generator keep track of the verified depth in lookaheads and simply consume the token instead of doing a match again, whenever that is possible.
  • Context switching Lexer
  • Since v0.4, LLK provide support for context switching in the lexer.
  • Builtin AST construction
  • LLK provide builtin support AST tree building as part of the grammar syntax and avoid having to create nodes in user acton (most of the time). Each rule or grammar element can declared a node type, with rules or elements referenced as children. Elements not annotated with a node type are simply discarded. Nodes can also be created conditionally base on runtime condition.
  • Dedicated lookahead methods
  • LLK generate another set of simpler methods for syntactic lookaheads. That avoid expensive exceptions, parameter passings and initialization overheads as oppose to embedding the lookaheads into the normal rule methods.
  • Support large bitset
  • LLK generate bitset as static member of a nested type and allow any number of large bitsets.
  • CharSet/TokenSet syntax
  • LLK allow specifying multiple tokens in a single unit eg. <'\r','\n', '\x2028','\x2029'>. TokenSet can also be given an alias name, so that it can be referenced in the grammar as well as in user action. TokenSet can also has an excluded set or be inverted.
  • Embedded semantic predicts and user actions in syntactic lookahead method
  • LLK typically strip all user actions and local variables from the syntactic lookahead method since they typically are not supposed to be evaluated during lookahead. However, there are occassions that syntactic lookahead method required user action and local variables, typically for embedded semantic predicts. LLK provide constructs to allow parameter passing, local variables and user actions in syntactic lookahead methods, see grammar syntax section for details.
  • LT(0) and reusable label
  • LLK allow LT(0) to retreive the token just matched and avoid using labels.
  • LLK also allow label eg. t:<IDENTIFIER>. LLK automatically declare and initialize the label to a default value. Label can be reused at multiple elements as long as the type are compatible.
  • See also the release notes for each version for additional new features.