Package org.allspice.parser.parsetable

Examples of org.allspice.parser.parsetable.DefaultTranslationMapper


   * @throws StateConflict
   * @throws StrandedSymbol
   * @throws InvalidStartRule
   */
  private static DefaultTranslationMapper createMapper() throws StateConflict, InvalidStartRule, StrandedSymbol {
    DefaultTranslationMapper mapper = new DefaultTranslationMapper() ;
    mapper.addTranslation(new Rule("E'","E"),new OneTrans()) ;
    mapper.addTranslation(new Rule("E","E","+","F"),new OpTrans()) ;
    mapper.addTranslation(new Rule("E","F"),new OneTrans()) ;
    mapper.addTranslation(new Rule("F","F","*","T"),new OpTrans()) ;
    mapper.addTranslation(new Rule("F","T"),new OneTrans()) ;
    mapper.addTranslation(new Rule("T","id"),new OneTrans()) ;
    mapper.addTranslation(new Rule("T","(","E",")"),new Paren()) ;
    return mapper;
  }
View Full Code Here


   * @throws StateConflict
   * @throws StrandedSymbol
   * @throws InvalidStartRule
   */
  private static AugmentedParseTable createParseTable() throws StateConflict, InvalidStartRule, StrandedSymbol {
    DefaultTranslationMapper mapper = createMapper() ;
    Grammar g = new Grammar("E'",mapper.rules.keySet(),
        new Tree23Map<String,AssocType>(),
        new Tree23Map<String,Integer>(),
        new Tree23Map<Rule,Integer>()) ;
    return new AugmentedParseTableImpl(mapper,ParserGenerator.createParseTable(g));
View Full Code Here

   * @throws StateConflict
   * @throws StrandedSymbol
   * @throws InvalidStartRule
   */
  private AugmentedParseTable createParseTable() throws StateConflict, InvalidStartRule, StrandedSymbol {
    DefaultTranslationMapper mapper = createMapper() ;
    ImmutableMap<String,AssocType> assoc = new Tree23Map<String,AssocType>() ;
    assoc = assoc.insert("+", AssocType.right) ;
    assoc = assoc.insert("*", AssocType.right) ;
    Grammar g = new Grammar("E'",mapper.rules.keySet(),assoc,
        new Tree23Map<String,Integer>(),
View Full Code Here

   * @throws StateConflict
   * @throws StrandedSymbol
   * @throws InvalidStartRule
   */
  private DefaultTranslationMapper createMapper() throws StateConflict, InvalidStartRule, StrandedSymbol {
    DefaultTranslationMapper mapper = new DefaultTranslationMapper() ;
    mapper.addTranslation(new Rule("E'","E"),new TopTrans()) ;
    mapper.addTranslation(new Rule("E","E","+","E"),new PlusTrans()) ;
    mapper.addTranslation(new Rule("E","T"),new TermTrans()) ;
    mapper.addTranslation(new Rule("T","id"),new IdTrans()) ;
    mapper.addTranslation(new Rule("T","(","E",")"),new ParenTrans()) ;
    ImmutableMap<String,AssocType> assoc = new Tree23Map<String,AssocType>() ;
    assoc = assoc.insert("+", AssocType.right) ;
    assoc = assoc.insert("*", AssocType.right) ;
    return mapper;
  }
View Full Code Here

   * @throws StateConflict
   * @throws StrandedSymbol
   * @throws InvalidStartRule
   */
  private DefaultTranslationMapper createMapper() throws StateConflict, InvalidStartRule, StrandedSymbol {
    DefaultTranslationMapper mapper = new DefaultTranslationMapper() ;
    mapper.addTranslation(new Rule("E'","E"),new TopTrans()) ;
    mapper.addTranslation(new Rule("E","E","+","E"),new PlusTrans()) ;
    mapper.addTranslation(new Rule("E","T"),new TermTrans()) ;
    mapper.addTranslation(new Rule("T","id"),new IdTrans()) ;
    mapper.addTranslation(new Rule("T","(","E",")"),new ParenTrans()) ;
    return mapper;
  }
View Full Code Here

   * @throws StateConflict
   * @throws InvalidStartRule
   * @throws StrandedSymbol
   */
  private AugmentedParseTable createParseTable() throws StateConflict, InvalidStartRule, StrandedSymbol {
    DefaultTranslationMapper mapper = createMapper() ;
    ImmutableMap<String,AssocType> assoc = new Tree23Map<String,AssocType>() ;
    assoc = assoc.insert("+", AssocType.right) ;
    assoc = assoc.insert("*", AssocType.right) ;
    Grammar g = new Grammar("E'",mapper.rules.keySet(),assoc,
        new Tree23Map<String,Integer>(),
View Full Code Here

   * @throws StateConflict
   * @throws StrandedSymbol
   * @throws InvalidStartRule
   */
  private DefaultTranslationMapper createMapper() throws StateConflict, InvalidStartRule, StrandedSymbol {
    DefaultTranslationMapper mapper = new DefaultTranslationMapper() ;
    mapper.addTranslation(new Rule("E'","E"),new TopTrans()) ;
    mapper.addTranslation(new Rule("E","E","+","F"),new PlusTrans()) ;
    mapper.addTranslation(new Rule("E","F"),new FacTrans()) ;
    mapper.addTranslation(new Rule("F","F","*","T"),new TimesTrans()) ;
    mapper.addTranslation(new Rule("F","T"),new TermTrans()) ;
    mapper.addTranslation(new Rule("T","id"),new IdTrans()) ;
    mapper.addTranslation(new Rule("T","(","E",")"),new ParenTrans()) ;
    return mapper;
  }
View Full Code Here

   * @throws StateConflict
   * @throws StrandedSymbol
   * @throws InvalidStartRule
   */
  private AugmentedParseTable createParseTable() throws StateConflict, InvalidStartRule, StrandedSymbol {
    DefaultTranslationMapper mapper = createMapper();
    Grammar g = new Grammar("E'",mapper.rules.keySet(),
        new Tree23Map<String,AssocType>(),
        new Tree23Map<String,Integer>(),
        new Tree23Map<Rule,Integer>()) ;
    return new AugmentedParseTableImpl(mapper,ParserGenerator.createParseTable(g));
View Full Code Here

      new Rule("E","E","id")),
      new Tree23Map<String,AssocType>(),
      new Tree23Map<String,Integer>(),
      new Tree23Map<Rule,Integer>()) ;
    ParseTable table = ParserGenerator.createParseTable(g);
    return new AugmentedParseTableImpl(new DefaultTranslationMapper(),table) ;
  }
View Full Code Here

    }
  }
 
  public static Pgen parsePGEN(Reader r) throws SyntaxError {
    Pgen parsedg;
    DefaultTranslationMapper mapper = new DefaultTranslationMapper() ;
    Grammar g ;
    mapper.addTranslation(new Rule(FILE),new CreateGrammarTrans()) ;
    mapper.addTranslation(new Rule(FILE,FILE,TYPE,GENERIC_TYPE,SYMLIST,";"),new AddTypeTrans()) ;
    mapper.addTranslation(new Rule(FILE,FILE,RULEDEF),new AddRuleDefToFile()) ;
    mapper.addTranslation(new Rule(FILE,FILE,"(",RULEBLOCK,")"),new AddEquPrecToFile()) ;
    mapper.addTranslation(new Rule(FILE,FILE,START,SYM),new CreateStartTrans()) ;
    mapper.addTranslation(new Rule(FILE,FILE,EXTEND,GENERIC_TYPE),new ExtendsTrans()) ;
    mapper.addTranslation(new Rule(FILE,FILE,IMPORT,JAVATYPE),new ImportTrans()) ;
    mapper.addTranslation(new Rule(FILE,FILE,IMPORT,JAVATYPE,".","*"),new ImportTransStar()) ;
    mapper.addTranslation(new Rule(FILE,FILE,AMBIG),new Ambig()) ;
    mapper.addTranslation(new Rule(RULEBLOCK),new EmptyRuleBlock()) ;
    mapper.addTranslation(new Rule(RULEBLOCK,RULEBLOCK,RULEDEF),new AddRuleDef()) ;
    mapper.addTranslation(new Rule(RULEDEF,SYM,":",RHS,";"),new CreateRuleTrans()) ;
    mapper.addTranslation(new Rule(ATTRS),new NewAttrTrans()) ;
    mapper.addTranslation(new Rule(ATTRS,NON),new AddNoneTrans()) ;
    mapper.addTranslation(new Rule(ATTRS,LEFT),new AddLeftTrans()) ;
    mapper.addTranslation(new Rule(ATTRS,RIGHT),new AddRightTrans()) ;
    mapper.addTranslation(new Rule(RHS),new EmptyRhsTrans()) ;
    mapper.addTranslation(new Rule(RHS,RHS,CODE,VAR_OPT),new BuildNoTrans()) ;
    mapper.addTranslation(new Rule(RHS,RHS,SYM,ATTRS,VAR_OPT),new BuildRhsTrans()) ;
    mapper.addTranslation(new Rule(SYMLIST),new EmptySymList()) ;
    mapper.addTranslation(new Rule(SYMLIST,SYMLIST,SYM),new BuildSymList()) ;
    mapper.addTranslation(new Rule(SYM,QUOTEDSTRING),new MakeIdTrans()) ;
    mapper.addTranslation(new Rule(SYM,ID),new MakeIdTrans()) ;
    mapper.addTranslation(new Rule(VAR_OPT),new EmptyVar()) ;
    mapper.addTranslation(new Rule(VAR_OPT,"=",ID),new IdVar()) ;
    mapper.addTranslation(new Rule(JAVATYPE,ID),new TypeFromId()) ;
    mapper.addTranslation(new Rule(JAVATYPE,JAVATYPE,".",ID),new TypeByConstruction()) ;
    mapper.addTranslation(new Rule(GENERIC_TYPE,JAVATYPE),new SimpleType()) ;
    mapper.addTranslation(new Rule(GENERIC_TYPE,JAVATYPE,GENERIC),new GenericType()) ;
    try {
      g = new Grammar(S,new ConcatCollection<Rule>(mapper.rules.keySet(),new Rule(S,FILE)),new Tree23Map<String,AssocType>(),
          new Tree23Map<String,Integer>(),
          new Tree23Map<Rule,Integer>()) ;
    } catch (InvalidStartRule e) {
View Full Code Here

TOP

Related Classes of org.allspice.parser.parsetable.DefaultTranslationMapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.