Package org.jamesii.model.carules.reader.antlr.parser

Examples of org.jamesii.model.carules.reader.antlr.parser.CaruleLexer


    String source = (String) document.getContent();

    camodel_return info = null;

    CaruleLexer lexer;
    // try to parse text to record of model information rules, states and so on
    CommonTokenStream tokenStream =
        new CommonTokenStream(lexer =
            new CaruleLexer(new ANTLRStringStream(source)));
    CaruleParser parser = new CaruleParser(tokenStream);
    try {
      info = parser.camodel();
    } catch (RecognitionException e) {
      info = new camodel_return();
    }

    // merge lexer problems with parser problems
    List<CAProblemToken> problems =
        new ArrayList<>(info.problems);
    for (CAProblemToken t : lexer.getProblemTokens()) {
      problems.add(t);
    }
    Collections.sort(problems);
    info.problems = problems;
View Full Code Here


    try {
      synchronized (tokens) {
        tokens.clear();

        try {
          CaruleLexer lexer = new CaruleLexer(new ANTLRReaderStream(input));

          int pos = 0;
          Token s;
          s = lexer.nextToken();
          String sState = null;
          while (s != null && s.getType() != -1) {
            String state = s.getText();

            pos += state.length();
            if (s.getType() == CaruleLexer.ID
                && (sState == null || sState.equals(state))) {
              if (pos - state.length() <= cPos && pos >= cPos) {
                sState = state;
              }
              CAStateToken t = new CAStateToken(pos - state.length(), state);
              tokens.add(t);
            }
            s = lexer.nextToken();
          }

          // now delete all CAStateTokens not representing sState
          for (int i = tokens.size() - 1; i >= 0; i--) {
            if (sState == null || !sState.equals(tokens.get(i).getState())) {
View Full Code Here

  }

  @Override
  protected void run(Reader input, int cPos) {
    try {
      CaruleLexer lexer;
      TokenStream stream =
          new CommonTokenStream(lexer =
              new CaruleLexer(new ANTLRReaderStream(input)));
      CaruleParser p = new CaruleParser(stream);
      camodel_return ca = p.camodel();
      synchronized (tokens) {
        tokens.clear();
        tokenActionsCache.clear();
        for (CAProblemToken t : lexer.getProblemTokens()) {
          tokens.add(t);
        }
        tokens.addAll(ca.problems);
        Collections.sort(tokens);
        for (final CAProblemToken t : tokens) {
View Full Code Here

TOP

Related Classes of org.jamesii.model.carules.reader.antlr.parser.CaruleLexer

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.