Package lexer

Examples of lexer.Lexer.addRule()


 
  public static void main(String[] args) {
    Lexer lexer = new Lexer();
    final Type<Integer> integer = new Type<>("Integer");
    final Type<Double> decimal = new Type<>("Decimal");
    lexer.addRule("Integer", new Rule<Integer>("[0-9]+", integer, new Action<Integer>() {
      @Override
      public Token action(Matcher matcher, Lexer lexer, Type<Integer> type) {
        return new Token(new Integer(matcher.group()), type);
      }
    }));
View Full Code Here


      @Override
      public Token action(Matcher matcher, Lexer lexer, Type<Integer> type) {
        return new Token(new Integer(matcher.group()), type);
      }
    }));
    lexer.addRule("Decimal", new Rule<Double>("([0-9]+\\.[0-9]*|[0-9]*\\.[0-9]+)", decimal, new Action<Double>() {
      @Override
      public Token action(Matcher matcher, Lexer lexer, Type<Double> type) {
        return new Token(new Double(matcher.group()), type);
      }
    }));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.