How to use the chevrotain.GAstVisitor 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 jhipster / jhipster-core / lib / dsl / self_checks / token_collector_visitor.js View on Github external
* for more information.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

const GAstVisitor = require('chevrotain').GAstVisitor;

class TokenCollectorVisitor extends GAstVisitor {
  constructor() {
    super();
    this.actualTokens = [];
  }

  visitTerminal(node) {
    this.actualTokens.push(node.terminalType);
  }

  visitRepetitionMandatoryWithSeparator(node) {
    this.actualTokens.push(node.separator);
  }

  visitRepetitionWithSeparator(node) {
github jhipster / jhipster-core / lib / dsl / self_checks.js View on Github external
* you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

const _ = require('lodash');
const chevrotain = require('chevrotain');

const GAstVisitor = chevrotain.GAstVisitor;
const Lexer = chevrotain.Lexer;

/**
 * This module includes reflective checks on the DSL implementation.
 * to increase correctness and reduce the TCO.
 */
module.exports = {
  findRedundantTokens,
  checkConfigKeys
};

class TokenCollectorVisitor extends GAstVisitor {
  constructor() {
    super();
    this.actualTokens = [];
  }