コード例 #1
0
 private Token readSpecial() throws Exception {
   String ret = null;
   try {
     ret = m_CurrChar.getString();
     read();
     while (isSpecialEndToken() == false) {
       ret += m_CurrChar.getString();
       read();
     }
     read();
     if (m_SpecialEndToken.length() == 2) read();
     ret += m_SpecialEndToken;
     Token token = new Token(ret);
     token.setImmutable();
     return token;
   } catch (Exception ex) {
     Token token = new Token(ret);
     token.setImmutable();
     return token;
   }
 }
コード例 #2
0
 private Token eatLine() throws Exception {
   m_Ret = new StringBuilder();
   m_Ret.append(m_CurrChar.getString());
   List<Token> all_ret = new ArrayList<Token>();
   boolean is_immutable = false;
   if (isSingeLineComment()) is_immutable = true;
   while (true) {
     read();
     if (isSpecialStartToken()) {
       Token curr = new Token(m_Ret.toString());
       if (is_immutable) curr.setImmutable();
       all_ret.add(curr);
       all_ret.add(readSpecial());
       is_immutable = false;
       m_Ret = new StringBuilder();
     } else if (m_InComment == false && isSingeLineComment()) {
       Token curr = new Token(m_Ret.toString());
       is_immutable = true;
       all_ret.add(curr);
       m_Ret = new StringBuilder();
     } else if (isNewLine(m_CurrChar.getString())) {
       Token curr = new Token(m_Ret.toString());
       if (is_immutable) curr.setImmutable();
       all_ret.add(curr);
       Token newline = new Token("\n");
       newline.setNewLine();
       all_ret.add(newline);
       Token ret = all_ret.get(0);
       all_ret.remove(0);
       m_NextNext.addAll(all_ret);
       is_immutable = false;
       // ignore # lines like they are comments
       // ret.setComment();
       return ret;
     }
     m_Ret.append(m_CurrChar.getString());
   }
 }
コード例 #3
0
 private Token doNext() throws Exception {
   if (isSingleLineToken()) {
     Token token = eatLine();
     m_InComment = false;
     token.setImmutable();
     return token;
   }
   if (isSpecialStartToken()) {
     return readSpecial();
   } else {
     m_Ret = new StringBuilder();
     while (isSpecialStartToken() == false && isSingleLineToken() == false) {
       m_Ret.append(m_CurrChar.getString());
       read();
     }
     Token ret = new Token(m_Ret.toString());
     return ret;
   }
 }