Package fri.patterns.interpreter.parsergenerator.builder

Examples of fri.patterns.interpreter.parsergenerator.builder.SerializedParser


    for (int i = 1; i < args.length; i++)
      input = input+" "+args[i];

    System.err.println("Calculating input >"+input+"<");

    Parser parser = new SerializedParser().get(rules, "Calculator");
    boolean ok = parser.parse(input, new Calculator());
    System.err.println("Parse return "+ok+", result: "+parser.getResult());
   
    /* Variant without SerializedParser:
    SyntaxSeparation separation = new SyntaxSeparation(new Syntax(rules));  // takes away IGNORED
View Full Code Here


        return super.newStrategy();
      }
    };

    // override the Parser builder to install the new Lexer implementation
    SerializedParser builder = new SerializedParser()  {
      protected SerializedLexer newSerializedLexer()  // override SerializedLexer factory method
        throws Exception
      {
        return new SerializedLexer()  {
          protected LexerBuilder newLexerBuilder(Syntax syntax, List ignoredSymbols// override LexerBuilder factory method
            throws LexerException, SyntaxException
          {
            return new LexerBuilder(syntax, ignoredSymbols)  {
              public Lexer getLexer()  {  // override Lexer factory method
                return new OverrideLexer(ignoredSymbols, charConsumers);
              }
            };
          }
        };
      }
    };
   
    String [][] syntaxInput = {
      { "Start", "\"Hello\"", "\"World\"" },
      { Token.IGNORED, "`whitespaces`" },
    };
   
    Parser parser = builder.get(syntaxInput);
    boolean ok = parser.parse("Hello World");
    System.err.println("Parsing was "+ok);
  }
View Full Code Here

  };
 
  public static void main(String [] args)
    throws Exception
  {
    Parser parser = new SerializedParser().get(SLRParserTables.class, syntax, "HelloWorld2")// generates "$HOME/.friware/parsers/HelloWorld2Parser.ser"
    parser.setInput("\tHello \r\n\tWorld\n")// give the lexer some very complex input :-)
    parser.parse(new PrintSemantic())// start parsing with a print-semantic
  }
View Full Code Here

TOP

Related Classes of fri.patterns.interpreter.parsergenerator.builder.SerializedParser

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.