コード例 #1
0
  public Map<String, GrammarRule> getParsers() {
    if (parsers == null) {
      // org.coreasm.engine.parser.Parser parser = capi.getParser();
      parsers = new HashMap<String, GrammarRule>();

      Parser<Node> stringParser =
          Terminals.StringLiteral.PARSER
              .token()
              .map(
                  new org.codehaus.jparsec.functors.Map<Token, Node>() {
                    @Override
                    public Node map(Token from) {
                      return new StringNode(
                          StringElement.processEscapeCharacters(from.toString()),
                          new ScannerInfo(from));
                    }
                  });

      refStringTermParser.set(stringParser);
      parsers.put(
          "ConstantTerm",
          new GrammarRule("StringConstantTerm", "STRING", refStringTermParser.lazy(), PLUGIN_NAME));
    }

    return parsers;
  }
コード例 #2
0
 /*
  * @see org.coreasm.engine.plugin.ParserPlugin#getParser(java.lang.String)
  */
 public Parser<Node> getParser(String nonterminal) {
   if (nonterminal.equals("StringTerm")) return refStringTermParser.lazy();
   else return null;
 }