How to use the chevrotain.Parser.performSelfAnalysis function in chevrotain

To help you get started, we’ve selected a few chevrotain examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nusmodifications / nusmods / api / gulp-tasks / local / genReqTree / parseString.js View on Github external
),
    );

    // parenthesisExpression has the highest precedence and thus it appears
    // in the "lowest" leaf in the expression ParseTree.
    this.RULE('parenthesisExpression', () => {
      this.CONSUME(LeftBracket);
      const expValue = this.SUBRULE(this.parse);
      this.CONSUME(RightBracket);
      return expValue;
    });

    // very important to call this after all the rules have been defined.
    // otherwise the parser may not work correctly as it will lack information
    // derived during the self analysis phase.
    Parser.performSelfAnalysis(this);
  }
github christianvoigt / argdown / packages / argdown-core / src / parser.ts View on Github external
constructor() {
    super(lexer.tokenList, {
      errorMessageProvider: errorMessageProvider,
      recoveryEnabled: true,
      outputCst: false
    });
    // very important to call this after all the rules have been defined.
    // otherwise the parser may not work correctly as it will lack information
    // derived during the self analysis phase.
    Parser.performSelfAnalysis(this);
  }
  //caches
github christianvoigt / argdown / packages / argdown-parser / src / ArgdownParser.js View on Github external
$.freestyleText = $.RULE("freestyleText", () => {
            let children = [];
            $.AT_LEAST_ONE(() => $.OR([{
                ALT: () => children.push($.CONSUME(lexer.Freestyle))
            }, {
                ALT: () => children.push($.CONSUME(lexer.UnusedControlChar))
            }]));
            return {
                name: "freestyleText",
                children: children
            };
        });
        // very important to call this after all the rules have been defined.
        // otherwise the parser may not work correctly as it will lack information
        // derived during the self analysis phase.
        Parser.performSelfAnalysis(this);
    }
github jhipster / jhipster-core / lib / dsl / poc / parser.js View on Github external
$.SUBRULE($.entityList);
      $.OPTION(() => {
        $.SUBRULE($.exclusion);
      });
    });

    $.RULE('comment', () => {
      $.OPTION(() => {
        $.CONSUME(t.COMMENT);
      });
    });

    // very important to call this after all the rules have been defined.
    // otherwise the parser may not work correctly as it will lack information
    // derived during the self analysis phase.
    Parser.performSelfAnalysis(this);
  }
}
github kevinastone / atom-grammar-test / lib / grammar.js View on Github external
} },
        { ALT: () => {
          const scopes = $.OR4([
            { ALT: () => {
              $.CONSUME2(OpenParens);
              const innerScopes = $.SUBRULE3($.scopes);
              $.CONSUME2(CloseParens);
              return innerScopes;
            } },
            { ALT: () => $.SUBRULE($.scopes) },
          ]);
          return ['@', scopes];
        } },
      ]));

      Parser.performSelfAnalysis(this);
    }
  }
github SAP / chevrotain / examples / parser / webpack / src / grammar_only_es6_import.js View on Github external
const $ = this

        $.RULE("array", () => {
            $.CONSUME(LSquare)
            $.OPTION(() => {
                $.CONSUME(Integer)
                $.MANY(() => {
                    $.CONSUME(Comma)
                    $.CONSUME2(Integer)
                })
            })
            $.CONSUME(RSquare)
        })

        Parser.performSelfAnalysis(this)
    }
}
github SAP / chevrotain / examples / parser / webpack / src / grammar_only_commonjs_require.js View on Github external
super(input, tokens.allTokens)
        const $ = this

        $.RULE("array", () => {
            $.CONSUME(tokens.LSquare)
            $.OPTION(() => {
                $.CONSUME(tokens.Integer)
                $.MANY(() => {
                    $.CONSUME(tokens.Comma)
                    $.CONSUME2(tokens.Integer)
                })
            })
            $.CONSUME(tokens.RSquare)
        })

        Parser.performSelfAnalysis(this)
    }
}
github dapetcu21 / atom-autocomplete-lua / js / parser.js View on Github external
this.statement = $.RULE('statement', () => {
      return $.OR([
        {ALT: () => $.SUBRULE($.return)}
      ])
    })

    this.block = $.RULE('block', () => {
      const statements = $.MANY(() => {
        const statement = $.SUBRULE($.statement)
        $.OPTION(() => { $.CONSUME(Semicolon) })
        return statement
      })
      return statements.reduceRight(cons, empty)
    })

    Parser.performSelfAnalysis(this)
  }
}
github SAP / chevrotain / examples / language_services / src / examples / json / parser.ts View on Github external
constructor(input:IToken[]) {
        super(input, allTokens)
        Parser.performSelfAnalysis(this)
    }
github RokuRoad / bright / src / Parser.ts View on Github external
constructor(input: IToken[]) {
    super(input, ALL_TOKENS, {
      outputCst: true,
      recoveryEnabled: false
    })
    Parser.performSelfAnalysis(this)
  }
}