⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmm.jj

📁 是Google提供的一个 Windows 应用程序;用户可以借助于该程序
💻 JJ
字号:
/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. .\cmm.jj */
/*@egen*//**
* JJTree file
*/
options {
  JDK_VERSION = "1.5";
}

PARSER_BEGIN(Cmm)
package cmm;
 
public class Cmm/*@bgen(jjtree)*/implements CmmTreeConstants/*@egen*/ {/*@bgen(jjtree)*/
  protected static JJTCmmState jjtree = new JJTCmmState();

/*@egen*/
  public static void main(String args[]){
    System.out.println("Reading from standard input...");
    new Cmm(System.in);
    try {
      SimpleNode n = Cmm.Start();
      n.dump("");
      System.out.println("Thank you!");
    } catch (Exception e) {
      System.out.println("Oops.");
      System.out.println(e.getMessage());
    }
  }
}   
PARSER_END(Cmm)
 
SKIP :
{
  " "
| "\t"
| "\n"
| "\r"
| <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
| <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/">
}
  
TOKEN:{
  <INT:(["0"-"9"])+>
       }

TOKEN:{
  <REAL:(["0"-"9"])*"." (["0"-"9"])+>
       }

TOKEN:{
  <PLUSMINUS:"+"|"-"> 
       }

TOKEN:{
  <MULTIPLYDIVIDE:"*"|"/"> 
       }

TOKEN:{
    <KEYWORD_INT:"int">
   |<KEYWORD_REAL:"real">
   |<KEYWORD_IF:"if">
   |<KEYWORD_ELSE:"else">
   |<KEYWORD_WHILE:"while">
   |<KEYWORD_READ:"read">
   |<KEYWORD_WRITE:"write">
   |<KEYWORD_BEGIN:"begin">
   |<KEYWORD_END:"end">
       }
       
TOKEN:{
  <WORD:("<"|"<>"|"==")>
       }

TOKEN:{
   <ID:["a"-"z","A"-"Z"](((["a"-"z","A"-"Z","0"-"9","_"])*)((["a"-"z","A"-"Z","0"-"9"])+))*>
       }

TOKEN : 
{
	< ARRAY: <ARRAYIDENTIFIER><LBRACKET><PLUSINTEGER><RBRACKET>>
|	< #ARRAYIDENTIFIER: <ARRAYLETTER> (<ARRAYLETTER>|<ARRAYDIGIT>|<ARRAYUNDERLINE>)* (<ARRAYLETTER>|<ARRAYDIGIT>)* >
|	< #ARRAYLETTER: ["a"-"z","A"-"Z"] >
|	< #ARRAYDIGIT: ["0"-"9"] >
|	< #ARRAYUNDERLINE: ["_"] >
|	< #PLUSINTEGER: ["1"-"9"](["0"-"9"])* >
|	< #LBRACKET: "[" >
|	< #RBRACKET: "]" >
}

SimpleNode Start():{/*@bgen(jjtree) Start */
  SimpleNode jjtn000 = new SimpleNode(JJTSTART);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/}
{/*@bgen(jjtree) Start */
  try {
/*@egen*/
  Program()/*@bgen(jjtree)*/
  {
    jjtree.closeNodeScope(jjtn000, true);
    jjtc000 = false;
  }
/*@egen*/ 
  { return jjtn000; }/*@bgen(jjtree)*/
  } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      throw (RuntimeException)jjte000;
    }
    if (jjte000 instanceof ParseException) {
      throw (ParseException)jjte000;
    }
    throw (Error)jjte000;
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
  }
/*@egen*/
}

void Program():{/*@bgen(jjtree) Program */
  SimpleNode jjtn000 = new SimpleNode(JJTPROGRAM);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/ } 
{/*@bgen(jjtree) Program */
   try {
/*@egen*/
   (VarDeclare())* Sentence()/*@bgen(jjtree)*/
   } catch (Throwable jjte000) {
     if (jjtc000) {
       jjtree.clearNodeScope(jjtn000);
       jjtc000 = false;
     } else {
       jjtree.popNode();
     }
     if (jjte000 instanceof RuntimeException) {
       throw (RuntimeException)jjte000;
     }
     if (jjte000 instanceof ParseException) {
       throw (ParseException)jjte000;
     }
     throw (Error)jjte000;
   } finally {
     if (jjtc000) {
       jjtree.closeNodeScope(jjtn000, true);
     }
   }
/*@egen*/
}

void VarDeclare():{/*@bgen(jjtree) VarDeclare */
  SimpleNode jjtn000 = new SimpleNode(JJTVARDECLARE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/}
{/*@bgen(jjtree) VarDeclare */
  try {
/*@egen*/
  (<KEYWORD_INT>|<KEYWORD_REAL>)(<ID>|<ARRAY>) (","(<ID>|<ARRAY>))* ";"/*@bgen(jjtree)*/
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
  }
/*@egen*/
}

void Sentence():{/*@bgen(jjtree) Sentence */
  SimpleNode jjtn000 = new SimpleNode(JJTSENTENCE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/ }
{/*@bgen(jjtree) Sentence */
  try {
/*@egen*/
  Complex()|Evaluate()|IfSentence()|WhileSentence()|WriteSentence()|ReadSentence()/*@bgen(jjtree)*/
  } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      throw (RuntimeException)jjte000;
    }
    if (jjte000 instanceof ParseException) {
      throw (ParseException)jjte000;
    }
    throw (Error)jjte000;
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
  }
/*@egen*/
}

void Complex():{/*@bgen(jjtree) Complex */
  SimpleNode jjtn000 = new SimpleNode(JJTCOMPLEX);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/}
{/*@bgen(jjtree) Complex */
  try {
/*@egen*/
  <KEYWORD_BEGIN> Sentence()(Sentence())*<KEYWORD_END>/*@bgen(jjtree)*/
  } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      throw (RuntimeException)jjte000;
    }
    if (jjte000 instanceof ParseException) {
      throw (ParseException)jjte000;
    }
    throw (Error)jjte000;
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
  }
/*@egen*/
}

void Evaluate():{/*@bgen(jjtree) Evaluate */
  SimpleNode jjtn000 = new SimpleNode(JJTEVALUATE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/}
{/*@bgen(jjtree) Evaluate */
  try {
/*@egen*/
  (<ID>|<ARRAY>) "=" Expression() ";"/*@bgen(jjtree)*/
  } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      throw (RuntimeException)jjte000;
    }
    if (jjte000 instanceof ParseException) {
      throw (ParseException)jjte000;
    }
    throw (Error)jjte000;
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
  }
/*@egen*/
}

void Expression():{/*@bgen(jjtree) Expression */
  SimpleNode jjtn000 = new SimpleNode(JJTEXPRESSION);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/}
{/*@bgen(jjtree) Expression */
  try {
/*@egen*/
  Item()(<PLUSMINUS> Item())*/*@bgen(jjtree)*/
  } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      throw (RuntimeException)jjte000;
    }
    if (jjte000 instanceof ParseException) {
      throw (ParseException)jjte000;
    }
    throw (Error)jjte000;
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
  }
/*@egen*/
}

void Item():{/*@bgen(jjtree) Item */
  SimpleNode jjtn000 = new SimpleNode(JJTITEM);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/}
{/*@bgen(jjtree) Item */
  try {
/*@egen*/
  Factor()(<MULTIPLYDIVIDE> Factor())*/*@bgen(jjtree)*/
  } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      throw (RuntimeException)jjte000;
    }
    if (jjte000 instanceof ParseException) {
      throw (ParseException)jjte000;
    }
    throw (Error)jjte000;
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
  }
/*@egen*/ 
}

void Factor():{/*@bgen(jjtree) Factor */
  SimpleNode jjtn000 = new SimpleNode(JJTFACTOR);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/}
{/*@bgen(jjtree) Factor */
  try {
/*@egen*/
  <ID>|<ARRAY>|<INT>|<REAL>|("(" Expression() ")")/*@bgen(jjtree)*/
  } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      throw (RuntimeException)jjte000;
    }
    if (jjte000 instanceof ParseException) {
      throw (ParseException)jjte000;
    }
    throw (Error)jjte000;
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
  }
/*@egen*/
}

void IfSentence():{/*@bgen(jjtree) IfSentence */
  SimpleNode jjtn000 = new SimpleNode(JJTIFSENTENCE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/}
{/*@bgen(jjtree) IfSentence */
  try {
/*@egen*/
  <KEYWORD_IF> "("Condition()")" Sentence() (LOOKAHEAD(1) <KEYWORD_ELSE> Sentence())*/*@bgen(jjtree)*/
  } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      throw (RuntimeException)jjte000;
    }
    if (jjte000 instanceof ParseException) {
      throw (ParseException)jjte000;
    }
    throw (Error)jjte000;
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
  }
/*@egen*/
}

void WhileSentence():{/*@bgen(jjtree) WhileSentence */
  SimpleNode jjtn000 = new SimpleNode(JJTWHILESENTENCE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/}
{/*@bgen(jjtree) WhileSentence */
  try {
/*@egen*/
  <KEYWORD_WHILE> "("Condition()")" Sentence()/*@bgen(jjtree)*/
  } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      throw (RuntimeException)jjte000;
    }
    if (jjte000 instanceof ParseException) {
      throw (ParseException)jjte000;
    }
    throw (Error)jjte000;
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
  }
/*@egen*/
}

void Condition():{/*@bgen(jjtree) Condition */
  SimpleNode jjtn000 = new SimpleNode(JJTCONDITION);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/}
{/*@bgen(jjtree) Condition */
  try {
/*@egen*/
  Expression()<WORD> Expression()/*@bgen(jjtree)*/
  } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      throw (RuntimeException)jjte000;
    }
    if (jjte000 instanceof ParseException) {
      throw (ParseException)jjte000;
    }
    throw (Error)jjte000;
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
  }
/*@egen*/
}

void WriteSentence():{/*@bgen(jjtree) WriteSentence */
  SimpleNode jjtn000 = new SimpleNode(JJTWRITESENTENCE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/}
{/*@bgen(jjtree) WriteSentence */
  try {
/*@egen*/ 
  <KEYWORD_WRITE> "(" Expression() (Expression())* ")" ";"/*@bgen(jjtree)*/
  } catch (Throwable jjte000) {
    if (jjtc000) {
      jjtree.clearNodeScope(jjtn000);
      jjtc000 = false;
    } else {
      jjtree.popNode();
    }
    if (jjte000 instanceof RuntimeException) {
      throw (RuntimeException)jjte000;
    }
    if (jjte000 instanceof ParseException) {
      throw (ParseException)jjte000;
    }
    throw (Error)jjte000;
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
  }
/*@egen*/
}

void ReadSentence():{/*@bgen(jjtree) ReadSentence */
  SimpleNode jjtn000 = new SimpleNode(JJTREADSENTENCE);
  boolean jjtc000 = true;
  jjtree.openNodeScope(jjtn000);
/*@egen*/}
{/*@bgen(jjtree) ReadSentence */
  try {
/*@egen*/
  <KEYWORD_READ> "(" <ID>|<ARRAY> (","<ID>|<ARRAY>)* ")" ";"/*@bgen(jjtree)*/
  } finally {
    if (jjtc000) {
      jjtree.closeNodeScope(jjtn000, true);
    }
  }
/*@egen*/
}




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -