retsac

Text lexer and parser. Compiler frontend framework.

MIT License

Downloads
582
Stars
7
Committers
2

Bot releases are hidden (Show)

retsac - v0.9.0 Latest Release

Published by DiscreteTom over 1 year ago

Highlight Features

This version's main target is to optimize the performance.

Tested with dt0, the time spent on parser building reduced 26% (~130ms => ~95ms).

retsac - v0.8.0

Published by DiscreteTom over 1 year ago

Highlight Features

  • Add high-level resolver APIs: builder.priority/leftSA/rightSA.
  • Add builder.use to apply custom decorators.
  • builder.resolveRS/resolveRR support *+?.
  • Provide versioned documentation.

Breaking Changes

  • ParserBuilder.checkSymbols is now private, use options in ParserBuilder.build instead.
  • Remove AdvancedBuilder.expand, make AdvancedBuilder extend ParserBuilder, they both implement IParserBuilder.
retsac - v0.7.0

Published by DiscreteTom over 1 year ago

Breaking Changes

ParserBuilder.generateResolvers/checkConflicts is now private, and ParserBuilder.checkAll is removed. Use options in ParserBuilder.build instead.

Highlight Features

  • Add debug option to AdvancedBuilder.expand.
  • Auto resolve R-S conflicts when AdvancedBuilder.expand.
  • Allow '*' as the next when resolve RS/RR conflicts.
  • Optimize performance.
retsac - v0.6.0

Published by DiscreteTom over 1 year ago

Highlight Features

Add ELR.AdvancedBuilder to support meta characters like +*? when defining grammar rules!

retsac - v0.5.0

Published by DiscreteTom over 1 year ago

Highlight Features

  • Add ASTNode.traverse and DefinitionContext.traverser to make it super easy to invoke a top-down traverse after the AST is built.
  • Add ASTNode.$ to query children by its type name or literal value.
retsac - v0.4.0-beta.3

Published by DiscreteTom over 1 year ago

Highlight Features

  • Add DefinicionContext.rollback so you can rollback global state when re-lex. (ELR parser only)
  • Add parser.commit to commit existing changes to prevent re-lex. (ELR parser only)
retsac - v0.4.0-beta.2

Published by DiscreteTom over 1 year ago

Highlight Features

Introducing ELR(Expectational LR) Parser

  • The ELR parser will actively use the Lexer to lex the input string to tokens according to the grammar rules.
  • Re-Lex: If the lexed token can't be accepted, the ELR parser will try to restore & re-lex input.

Lexer

  • Add Lexer.trimStart/clone/dryClone/take.
retsac - v0.4.0-beta.1

Published by DiscreteTom almost 2 years ago

Highlight Features

  • LR parser support conflict detection (for reduce-shift conflicts and reduce-reduce conflicts), and will try to auto resolve those conflicts by LR-1 peeking.
  • Add ParserBuilder.generateResolver to generate code to manually resolve conflicts which can not be auto resolved.
  • DFA will cache computed states on the fly to optimize performance. You can also use DFA.calculateAllStates to calculate and cache all states ahead of time.
  • ASTNode can be serialized to a JSON object to co-work with other tools (e.g. compiler backend libs).

TODO

  • Optimize errors and output.
  • Add wiki and Chinese documents.
  • Optimize test code.

CHANGELOG

For detailed information, see CHANGELOG.