antlr4ts icon indicating copy to clipboard operation
antlr4ts copied to clipboard

🚧 Browser support

Open M-Adoo opened this issue 5 years ago • 4 comments

Let antlr4ts work in browser.

  • compile typescript to es5 target
  • provide umd、cjs and es bundles.
  • some file circle dependency has be resolved.

todo: commits need be rebase -i

M-Adoo avatar Mar 28 '19 02:03 M-Adoo

maybe resolved #343

M-Adoo avatar Mar 28 '19 02:03 M-Adoo

@M-Adoo thank you for trying to do this, but I found some issues.

  1. Rollup found a lot of circular dependencies:
(!) rpt2 plugin: The ongenerate hook used by plugin rpt2 is deprecated. The generateBundle hook should be used instead.
(!) rpt2 plugin: The onwrite hook used by plugin rpt2 is deprecated. The generateBundle hook should be used instead.
(!) Circular dependency: src\atn\ATN.ts -> src\dfa\DFA.ts -> src\atn\ATNConfigSet.ts -> src\atn\ATN.ts
(!) Circular dependency: src\atn\PredictionContext.ts -> src\atn\PredictionContextCache.ts -> src\atn\PredictionContext.ts
(!) Circular dependency: src\atn\ATN.ts -> src\dfa\DFA.ts -> src\dfa\DFASerializer.ts -> src\atn\ATNSimulator.ts -> src\dfa\DFAState.ts -> src\atn\ATN.ts
(!) Circular dependency: src\misc\IntervalSet.ts -> src\Lexer.ts -> src\atn\LexerATNSimulator.ts -> src\atn\ATN.ts -> src\misc\IntervalSet.ts
(!) Circular dependency: src\misc\IntervalSet.ts -> src\Lexer.ts -> src\atn\LexerATNSimulator.ts -> src\atn\ATN.ts -> src\atn\LL1Analyzer.ts -> src\misc\IntervalSet.ts
(!) Circular dependency: src\misc\IntervalSet.ts -> src\Lexer.ts -> src\atn\LexerATNSimulator.ts -> src\atn\ATN.ts -> src\atn\LL1Analyzer.ts -> src\atn\NotSetTransition.ts -> src\atn\SetTransition.ts -> src\misc\IntervalSet.ts
(!) Circular dependency: src\Lexer.ts -> src\atn\LexerATNSimulator.ts -> src\Lexer.ts
(!) Circular dependency: src\NoViableAltException.ts -> src\Parser.ts -> src\atn\ATNDeserializer.ts -> src\atn\ParserATNSimulator.ts -> src\NoViableAltException.ts
(!) Circular dependency: src\Parser.ts -> src\atn\ATNDeserializer.ts -> src\atn\ParserATNSimulator.ts -> src\ParserRuleContext.ts -> src\RuleContext.ts -> src\tree\Trees.ts -> src\Parser.ts
(!) Circular dependency: src\ParserRuleContext.ts -> src\RuleContext.ts -> src\tree\Trees.ts -> src\ParserRuleContext.ts
(!) Circular dependency: src\ParserRuleContext.ts -> src\RuleContext.ts -> src\ParserRuleContext.ts
(!) Circular dependency: src\DefaultErrorStrategy.ts -> src\NoViableAltException.ts -> src\Parser.ts -> src\DefaultErrorStrategy.ts
(!) Circular dependency: src\tree\xpath\XPath.ts -> src\tree\xpath\XPathWildcardAnywhereElement.ts -> src\tree\xpath\XPath.ts
(!) Circular dependency: src\tree\xpath\XPath.ts -> src\tree\xpath\XPathWildcardElement.ts -> src\tree\xpath\XPath.ts
(!) Circular dependency: src\Parser.ts -> src\atn\index.ts -> src\atn\ProfilingATNSimulator.ts -> src\Parser.ts
(!) Circular dependency: src\Parser.ts -> src\tree\pattern\index.ts -> src\tree\pattern\ParseTreePatternMatcher.ts -> src\Parser.ts
(!) Circular dependency: src\BailErrorStrategy.ts -> src\DefaultErrorStrategy.ts -> src\NoViableAltException.ts -> src\Parser.ts -> src\index.ts -> src\BailErrorStrategy.ts
(!) Circular dependency: src\DefaultErrorStrategy.ts -> src\NoViableAltException.ts -> src\Parser.ts -> src\index.ts -> src\DefaultErrorStrategy.ts
(!) Circular dependency: src\NoViableAltException.ts -> src\Parser.ts -> src\index.ts -> src\NoViableAltException.ts
(!) Circular dependency: src\Parser.ts -> src\index.ts -> src\Parser.ts
(!) Circular dependency: src\Parser.ts -> src\index.ts -> src\ParserInterpreter.ts -> src\Parser.ts
  1. Generated (by using the tool) Lexer and Parser files don't use the UMD bundle

Thank you so much!

albyrock87 avatar Mar 30 '19 15:03 albyrock87

@M-Adoo I'm well aware that this is a daunting task. I imagine it will take many tries to figure out a clean way to implement it even to a point where the current set of tests work. I will leave this pull request open while you continue to work on it. Due to the complexities involved and the specific goal of "supporting browsers", once we get the tests passing in the CI build (which uses Node), I would value your thoughts on how we can correctly test the code in the context of supported browsers.

sharwell avatar Mar 30 '19 21:03 sharwell

A good news is we had already used antlr4ts in browser. I will finish the rest of the work for this pr when I have time. Thanks nice job of anrlr4ts members.

M-Adoo avatar Mar 31 '19 05:03 M-Adoo