Package java_cup.runtime

Examples of java_cup.runtime.Symbol


            ECATokenLexer lexer = new ECATokenLexer(new StringReader(ruleScript.getRuleText()));
            lexer.setStartLine(getLine());
            lexer.setFile(file);
            parser = new ECAGrammarParser(lexer);
            parser.setFile(file);
            Symbol parse = (debugParse ? parser.debug_parse() : parser.parse());
            if (parser.getErrorCount() != 0) {
                String message = "rule " + ruleScript.getName();
                message += parser.getErrors();
                throw new ParseException(message);
            }
View Full Code Here


    public Bag parse ( String s ) {
        try {
            JSONLex scanner = new JSONLex(new StringReader(s));
            JSONParser parser = new JSONParser(scanner);
            Symbol sym = parser.parse();
            return new Bag((MRData)sym.value);
        } catch (Exception e) {
            System.err.println(e);
            return new Bag();
        }
View Full Code Here

    }

    /** skip until the beginning of a split element */
    boolean skip () throws IOException {
        while (true) {
            Symbol s = scanner.next_token();
            if (s.sym == jsym.EOF || (!in_memory && start+scanner.char_pos() >= end))
                return false;
            if (s.sym == jsym.STRING && is_start_tag((String)s.value)) {
                String tag = (String)s.value;
                if (scanner.next_token().sym == jsym.COLON) {
View Full Code Here

    /** store one split element into the buffer; may cross split boundaries */
    boolean store () throws IOException {
        int nest = 0;
        while (true) {
            Symbol s = scanner.next_token();
            if (s.sym == jsym.EOF)
                return false;
            if (s.sym == jsym.O_BEGIN || s.sym == jsym.A_BEGIN)
                nest++;
            else if (s.sym == jsym.O_END || s.sym == jsym.A_END)
View Full Code Here

      zzMarkedPos = zzMarkedPosL;

      switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
        case 28:
          { yybegin(MDSTART);
    return new Symbol (ParserSym.MUDECL, yytext());
          }
        case 101: break;
        case 50:
          { yybegin(ATTRVALLIT_SQM);
    CRcount++;
          }
        case 102: break;
        case 49:
          { yybegin(ATTRVALLIT_SQM);
    NLcount++;
          }
        case 103: break;
        case 18:
          { yybegin(ATTRVAL);
          }
        case 104: break;
        case 32:
          { yybegin(COMMENT);
    return new Symbol (ParserSym.LEXERR,yytext());
          }
        case 105: break;
        case 43:
          { yybegin(ATTRVALSTART);
    return new Symbol (ParserSym.LEXERR,yytext());
          }
        case 106: break;
        case 98:
          { yybegin(CDATA);
         appendText(LexerTextType.ENTITY_SEMI);
          }
        case 107: break;
        case 62:
          { yybegin(CDATA_ENDTAG_START);
    return new Symbol (ParserSym.LEXERR,yytext());
          }
        case 108: break;
        case 96:
          { yybegin(ATTRVALLIT_DQM);
    return new Symbol (ParserSym.ATTRVAL_LIT, replaceEntity(true));
          }
        case 109: break;
        case 7:
          { yybegin(YYINITIAL);
    appendText(LexerTextType.LINE_TERMINATOR)
    CRcount++;
          }
        case 110: break;
        case 6:
          { yybegin(YYINITIAL);
    appendText(LexerTextType.LINE_TERMINATOR)
    NLcount++;
          }
        case 111: break;
        case 61:
          { yybegin(CDATA);
      appendText(LexerTextType.TEXT);
          }
        case 112: break;
        case 59:
          { yybegin(CDATA);
               NLcount++;
         appendText(LexerTextType.LINE_TERMINATOR);
          }
        case 113: break;
        case 31:
          { yybegin(MD);
    CRcount++;
          }
        case 114: break;
        case 30:
          { yybegin(MD);
    NLcount++;
          }
        case 115: break;
        case 9:
          { yybegin(ATTR);   
    return new Symbol (ParserSym.LEXERR,yytext());
          }
        case 116: break;
        case 38:
          { yybegin(ATTREQUALS);
          }
        case 117: break;
        case 100:
          { if (yytext().equalsIgnoreCase(currentCDATAClosingTag)) {
                         yypushback(yytext().length()-2);                        
                         yybegin(CDATA_ENDTAG_START);
                         String aux = buffer.toString();
                        
                         if(aux.endsWith("\r\n")){
                           aux=aux.substring(0,aux.length()-2);
                         }
                         else if(aux.endsWith("\n") || aux.endsWith("\r")){
                           aux=aux.substring(0,aux.length()-1);
                         }
                         flushBufferedText(); // for initialization purposes
                         return new Symbol (ParserSym.TEXT, new HTMLText(aux, offsetCDATA, false, false));                      
               } else {
                       yybegin(CDATA);
             appendText(LexerTextType.TEXT);          
               }
          }
        case 118: break;
        case 85:
          { yybegin(CDATA);
               CRNLcount++;
         appendText(LexerTextType.LINE_TERMINATOR);
          }
        case 119: break;
        case 5:
          { yybegin(YYINITIAL);
    appendText(LexerTextType.SPACE);
          }
        case 120: break;
        case 35:
          { yybegin(CHECK_IF_CDATA);   
    syncronizeSent=false;   
    return new Symbol (ParserSym.TAG_CLOSE, yychar, yyline, new Character(yytext().charAt(0)));
          }
        case 121: break;
        case 14:
          { yybegin(YYINITIAL);
    return new Symbol (ParserSym.TAG_CLOSE, yychar, yyline, new Character(yytext().charAt(0)));
          }
        case 122: break;
        case 93:
          { yybegin(YYINITIAL);
    appendText(LexerTextType.ENTITY_SEMI);
          }
        case 123: break;
        case 23:
          { yybegin(ENDTAG);
    return new Symbol (ParserSym.LEXERR,yytext());
          }
        case 124: break;
        case 74:
          { yybegin(ATTRVAL);
    CRNLcount++;
          }
        case 125: break;
        case 1:
          { yybegin(COMMENT);
    return new Symbol (ParserSym.COMM_CONTENT, yytext());
          }
        case 126: break;
        case 37:
          { yybegin(ATTREQUALS);
    return new Symbol (ParserSym.LEXERR,yytext());
          }
        case 127: break;
        case 17:
          { yybegin(ATTRVALSTART);
    return new Symbol (ParserSym.ATTRVAL_NUM, yytext());
          }
        case 128: break;
        case 88:
          { yybegin(YYINITIAL);
    return new Symbol (ParserSym.EMPTY_TAG, yytext());
          }
        case 129: break;
        case 57:
          { yybegin(CDATA);
         appendText(LexerTextType.TEXT);
          }
        case 130: break;
        case 81:
          { yybegin(ATTRVALLIT_DQM);
    return new Symbol (ParserSym.ATTRVAL_LIT, replaceEntity(false));
          }
        case 131: break;
        case 20:
          { yybegin(ATTRVAL);
    CRcount++;
          }
        case 132: break;
        case 19:
          { yybegin(ATTRVAL);
    NLcount++;
          }
        case 133: break;
        case 40:
          { yybegin(ATTREQUALS);
    CRcount++;
          }
        case 134: break;
        case 10:
          { yybegin(ATTREQUALS);
    return new Symbol (ParserSym.ATTR_NAME, yytext());
          }
        case 135: break;
        case 39:
          { yybegin(ATTREQUALS);
    NLcount++;
          }
        case 136: break;
        case 64:
          { yypushback(yytext().length());
   
    if(!syncronizeSent){
      syncronizeSent=true;
      return new Symbol (ParserSym.SYNC, yytext());     
    }
       
    if (cup.action_obj.isLastStartTagCreatedOk() && currentCDATAClosingTag!=null) {
      textState = LexerTextStateType.CDATA;
      yybegin(CDATA);
    } else {     
      yybegin(YYINITIAL);
    }
          }
        case 137: break;
        case 75:
          { yybegin(ATTRVALSTART);
    return new Symbol (ParserSym.ATTRVAL_NMTK, replaceEntity(false));
          }
        case 138: break;
        case 65:
          { yybegin(YYINITIAL);
    return new Symbol (ParserSym.LEXERR_EXPECTED_TAG_NAME,yytext());
          }
        case 139: break;
        case 91:
          { yybegin(TAG_IGNORE_ATTS);
    CRNLcount++;
          }
        case 140: break;
        case 90:
          { yybegin(IGNORED_Q_TAG);
          }
        case 141: break;
        case 63:
          { yybegin(CDATA_ENDTAG_START)
    return new Symbol (ParserSym.END_TAG_NAME, offsetCDATA, yyline, yytext());
          }
        case 142: break;
        case 70:
          { yybegin(YYINITIAL);
    appendText(LexerTextType.LINE_TERMINATOR)
    CRNLcount++;
          }
        case 143: break;
        case 82:
          { yybegin(ATTRVALLIT_SQM);
    CRNLcount++;
          }
        case 144: break;
        case 79:
          { yybegin(ATTREQUALS);
    CRNLcount++;
          }
        case 145: break;
        case 72:
          { yybegin(ATTR);
    CRNLcount++;
          }
        case 146: break;
        case 33:
          { yybegin(STARTTAG);
    return new Symbol (ParserSym.LEXERR,yytext());
          }
        case 147: break;
        case 71:
          { yybegin(YYINITIAL);
    appendText(LexerTextType.ENTITY_NO_SEMI);
          }
        case 148: break;
        case 2:
          { yybegin(ATTRVALLIT_DQM);
    return new Symbol (ParserSym.ATTRVAL_LIT, yytext());
          }
        case 149: break;
        case 60:
          { yybegin(CDATA);
               CRcount++;
         appendText(LexerTextType.LINE_TERMINATOR);
          }
        case 150: break;
        case 83:
          { yybegin(ATTRVALLIT_SQM);
    return new Symbol (ParserSym.ATTRVAL_LIT, replaceEntity(false));
          }
        case 151: break;
        case 99:
          { yybegin(ENDTAG);
    String tagName = yytext().substring(2);
    return new Symbol (ParserSym.END_TAG_NAME, yychar, yyline, tagName);
          }
        case 152: break;
        case 76:
          { yybegin(ENDTAG);
    CRNLcount++;
          }
        case 153: break;
        case 53:
          { yybegin(YYINITIAL);
  yypushback(yytext().length())
  return new Symbol (ParserSym.TAG_SLASH_CLOSE, yytext());
          }
        case 154: break;
        case 16:
          { yybegin(ATTRVALSTART);
    return new Symbol (ParserSym.ATTRVAL_NMTK, yytext());
          }
        case 155: break;
        case 22:
          { yybegin(ATTRVALLIT_SQM);
    return new Symbol (ParserSym.SQM, new Character(yytext().charAt(0)));
          }
        case 156: break;
        case 80:
          { yybegin(ATTRVALLIT_DQM);
    CRNLcount++;
          }
        case 157: break;
        case 77:
          { yybegin(COMMENT);
    return new Symbol (ParserSym.COMM, yytext());
          }
        case 158: break;
        case 47:
          { yybegin(ATTR);
    return new Symbol (ParserSym.DQM, new Character(yytext().charAt(0)));
          }
        case 159: break;
        case 73:
          { yybegin(ATTRVALSTART);
    return new Symbol (ParserSym.ATTRVAL_NUMTK, yytext());
          }
        case 160: break;
        case 86:
          { yybegin(CDATA);
         appendText(LexerTextType.ENTITY_NO_SEMI);          
         // to collapse next LINE TERMINATOR (same as RI)
         terminatorSkipped = false;
          }
        case 161: break;
        case 36:
          { yybegin(TAG_IGNORE_ATTS);
    return new Symbol (ParserSym.LEXERR,yytext());
          }
        case 162: break;
        case 4:
          { yybegin(YYINITIAL);
    appendText(LexerTextType.TEXT);
          }
        case 163: break;
        case 56:
          { yybegin(YYINITIAL);
  return new Symbol (ParserSym.TAG_SLASH_CLOSE, yytext());
          }
        case 164: break;
        case 94:
          { yybegin(ATTRVALSTART);
    return new Symbol (ParserSym.ATTRVAL_NMTK, replaceEntity(true));
          }
        case 165: break;
        case 41:
          { yybegin(ATTRVAL);
    return new Symbol (ParserSym.EQUALS, new Character(yytext().charAt(0)));
          }
        case 166: break;
        case 15:
          { yybegin(TAG_TRAILINGWS);
          }
        case 167: break;
        case 26:
          { yybegin(ENDTAG);
    CRcount++;
          }
        case 168: break;
        case 95:
          { yybegin(YYINITIAL);
    return new Symbol (ParserSym.TAG_COMM_CLOSE, yytext());
          }
        case 169: break;
        case 24:
          { yybegin(ENDTAG);
          }
        case 170: break;
        case 25:
          { yybegin(ENDTAG);
    NLcount++;
          }
        case 171: break;
        case 44:
          { yybegin(ATTRVALLIT_DQM);
          }
        case 172: break;
        case 13:
          { yybegin(ATTR);
    CRcount++;
          }
        case 173: break;
        case 89:
          { yybegin(MD);
    return new Symbol (ParserSym.TAG_OPEN_EXM, yychar, yyline, yytext());
          }
        case 174: break;
        case 12:
          { yybegin(ATTR);
    NLcount++;
          }
        case 175: break;
        case 58:
          { yybegin(CDATA);
         appendText(LexerTextType.SPACE);
          }
        case 176: break;
        case 92:
          { yybegin(YYINITIAL);
          }
        case 177: break;
        case 84:
          { yybegin(TAG_TRAILINGWS);
  CRNLcount++;
          }
        case 178: break;
        case 46:
          { yybegin(ATTRVALLIT_DQM);
    CRcount++;
          }
        case 179: break;
        case 45:
          { yybegin(ATTRVALLIT_DQM);
    NLcount++;
          }
        case 180: break;
        case 87:
          { String tagName = yytext().substring(1).toLowerCase();
    Element e = dtd.elementHash.get(tagName);
    if (e != null && ((e.getType() == DTDConstants.CDATA) || e.isScript())) {
      currentCDATAClosingTag = "</" + tagName + ">";
      yybegin(TAG_IGNORE_ATTS);
    } else {
      if (isPreformatted(tagName)) {
        textState = LexerTextStateType.PREFORMATTED;
      }
      currentCDATAClosingTag = null;
      yybegin(STARTTAG);     
    }   
    return new Symbol (ParserSym.TAG_NAME, yychar, yyline, yytext().substring(1, yytext().length()));
          }
        case 181: break;
        case 3:
          { yybegin(ATTRVALLIT_SQM);
    return new Symbol (ParserSym.ATTRVAL_LIT, yytext());
          }
        case 182: break;
        case 68:
          { yybegin(TAG_IGNORE_ATTS);
    CRcount++;
          }
        case 183: break;
        case 29:
          { yybegin(MD);
          }
        case 184: break;
        case 55:
          { yybegin(TAG_TRAILINGWS);
  CRcount++;
          }
        case 185: break;
        case 42:
          { yybegin(ATTRVALSTART);
    return new Symbol (ParserSym.DQM, new Character(yytext().charAt(0)));
          }
        case 186: break;
        case 67:
          { yybegin(TAG_IGNORE_ATTS);
    NLcount++;
          }
        case 187: break;
        case 54:
          { yybegin(TAG_TRAILINGWS);
  NLcount++;
          }
        case 188: break;
        case 21:
          { yybegin(ATTRVALLIT_DQM);
    return new Symbol (ParserSym.DQM, new Character(yytext().charAt(0)));
          }
        case 189: break;
        case 27:
          { yybegin(MD);
    return new Symbol (ParserSym.LEXERR,yytext());
          }
        case 190: break;
        case 11:
          { yybegin(ATTR);
          }
        case 191: break;
        case 8:
          { HTMLText textToken = flushBufferedText();
    yypushback(1);   
    yybegin(YYINITIAL_NOTEXT);
    if (textToken != null) {
      return new Symbol (ParserSym.TEXT, textToken);
    }
          }
        case 192: break;
        case 48:
          { yybegin(ATTRVALLIT_SQM);
          }
        case 193: break;
        case 51:
          { yybegin(ATTR);
    return new Symbol (ParserSym.SQM, new Character(yytext().charAt(0)));
          }
        case 194: break;
        case 97:
          { yybegin(ATTRVALLIT_SQM);
    return new Symbol (ParserSym.ATTRVAL_LIT, replaceEntity(true));
          }
        case 195: break;
        case 66:
          { yybegin(TAG_IGNORE_ATTS);
          }
        case 196: break;
        case 52:
          { yybegin(MDSTART);
    return new Symbol (ParserSym.MUDECL_CONTENT, yytext());
          }
        case 197: break;
        case 78:
          { yybegin(MD);
    CRNLcount++;
          }
        case 198: break;
        case 34:
          { yybegin(CHECK_IF_CDATA);
    return new Symbol (ParserSym.TAG_OPEN, new Character(yytext().charAt(0)));
          }
        case 199: break;
        case 69:
          {
          }
        case 200: break;
        default:
          if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
            zzAtEOF = true;
            zzDoEOF();
              {     if (buffer.length() > 0 ) {
      String aux = buffer.toString();
       buffer= new StringBuilder();
       return new Symbol (ParserSym.TEXT, new HTMLText(aux, offsetCDATA, false, false));
  }
  if(yystate()==CDATA){
    yybegin(YYINITIAL);
      return new Symbol(ParserSym.EOF_LITERAL,currentCDATAClosingTag.substring(2,currentCDATAClosingTag.length()-1 ));
    }   
  return new Symbol (ParserSym.EOF,yytext());
}
          }
          else {
            zzScanError(ZZ_NO_MATCH);
          }
View Full Code Here

        String fullText = "BIND\n" + text + "\nIF TRUE DO NOTHING";
        try {
            ECATokenLexer lexer = new ECATokenLexer(new StringReader(fullText));
            ECAGrammarParser parser = new ECAGrammarParser(lexer);
            Symbol event_parse = parser.parse();
            ParseNode eventTree = (ParseNode)event_parse.value;
            Event event = new Event(rule, eventTree);
            return event;
        } catch (Exception e) {
            throw new ParseException("org.jboss.byteman.rule.Event : error parsing event\n" + text, e);
View Full Code Here

        }
        String fullText = "BIND NOTHING IF TRUE DO \n" + text;
        try {
            ECATokenLexer lexer = new ECATokenLexer(new StringReader(text));
            ECAGrammarParser parser = new ECAGrammarParser(lexer);
            Symbol parse = parser.parse();
            ParseNode parseTree = (ParseNode)parse.value;
            ParseNode actionTree = (ParseNode)parseTree.getChild(3);
            Action action = new Action(rule, actionTree);
            return action;
        } catch (Exception e) {
View Full Code Here

        }
        String fulltext = "BIND NOTHING IF \n" + text + "\n DO NOTHING";
        try {
            ECATokenLexer lexer = new ECATokenLexer(new StringReader(text));
            ECAGrammarParser parser = new ECAGrammarParser(lexer);
            Symbol condition_parse = parser.parse();
            ParseNode conditionTree = (ParseNode) condition_parse.value;
            Condition condition = new Condition(rule, conditionTree);
            return condition;
        } catch (Exception e) {
            throw new ParseException("org.jboss.byteman.rule.Condition : error parsing condition\n" + text, e);
View Full Code Here

            ECATokenLexer lexer = new ECATokenLexer(new StringReader(ruleScript.getRuleText()));
            lexer.setStartLine(getLine());
            lexer.setFile(file);
            parser = new ECAGrammarParser(lexer);
            parser.setFile(file);
            Symbol parse = (debugParse ? parser.debug_parse() : parser.parse());
            if (parser.getErrorCount() != 0) {
                String message = "rule " + ruleScript.getName();
                message += parser.getErrors();
                throw new ParseException(message);
            }
View Full Code Here

  private int checkFirstTokenLength(int start, int end) {
    int length = 0;
    try {
      scan(start, end);
      Symbol token = (Symbol) tokens.get(0);
      length = token.right - token.left;
    } catch (Exception e) {
      Logger.logException(e);
    }
    return length;
View Full Code Here

TOP

Related Classes of java_cup.runtime.Symbol

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.