Exemplo n.º 1
0
  /**
   * Generate the nextToken rule. nextToken is a synthetic lexer rule that is the implicit OR of all
   * user-defined lexer rules.
   */
  public void genNextToken() {
    println("");
    println("/** Lexer nextToken rule:");
    println(" *  The lexer nextToken rule is synthesized from all of the user-defined");
    println(" *  lexer rules.  It logically consists of one big alternative block with");
    println(" *  each user-defined rule being an alternative.");
    println(" */");

    // Create the synthesized rule block for nextToken consisting
    // of an alternate block containing all the user-defined lexer rules.
    RuleBlock blk = MakeGrammar.createNextTokenRule(grammar, grammar.rules, "nextToken");

    // Define the nextToken rule symbol
    RuleSymbol nextTokenRs = new RuleSymbol("mnextToken");
    nextTokenRs.setDefined();
    nextTokenRs.setBlock(blk);
    nextTokenRs.access = "private";
    grammar.define(nextTokenRs);

    /*
    // Analyze the synthesized block
    if (!grammar.theLLkAnalyzer.deterministic(blk))
    {
    	println("The grammar analyzer has determined that the synthesized");
    	println("nextToken rule is non-deterministic (i.e., it has ambiguities)");
    	println("This means that there is some overlap of the character");
    	println("lookahead for two or more of your lexer rules.");
    }
    */

    genCommonBlock(blk);
  }