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

📄 java1.0.2ls.jj

📁 java 编译器java复杂编译器,可以编译java文件的类库
💻 JJ
📖 第 1 页 / 共 2 页
字号:
/* * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * California 95054, U.S.A. All rights reserved.  Sun Microsystems, Inc. has * intellectual property rights relating to technology embodied in the product * that is described in this document. In particular, and without limitation, * these intellectual property rights may include one or more of the U.S. * patents listed at http://www.sun.com/patents and one or more additional * patents or pending patent applications in the U.S. and in other countries. * U.S. Government Rights - Commercial software. Government users are subject * to the Sun Microsystems, Inc. standard license agreement and applicable * provisions of the FAR and its supplements.  Use is subject to license terms. * Sun,  Sun Microsystems,  the Sun logo and  Java are trademarks or registered * trademarks of Sun Microsystems, Inc. in the U.S. and other countries.  This * product is covered and controlled by U.S. Export Control laws and may be * subject to the export or import laws in other countries.  Nuclear, missile, * chemical biological weapons or nuclear maritime end uses or end users, * whether direct or indirect, are strictly prohibited.  Export or reexport * to countries subject to U.S. embargo or to entities identified on U.S. * export exclusion lists, including, but not limited to, the denied persons * and specially designated nationals lists is strictly prohibited. */options {  JAVA_UNICODE_ESCAPE = true;}PARSER_BEGIN(JavaParser)public class JavaParser {  public static void main(String args[]) {    JavaParser parser;    if (args.length == 0) {      System.out.println("Java Parser Version 1.0.2:  Reading from standard input . . .");      parser = new JavaParser(System.in);    } else if (args.length == 1) {      System.out.println("Java Parser Version 1.0.2:  Reading from file " + args[0] + " . . .");      try {        parser = new JavaParser(new java.io.FileInputStream(args[0]));      } catch (java.io.FileNotFoundException e) {        System.out.println("Java Parser Version 1.0.2:  File " + args[0] + " not found.");        return;      }    } else {      System.out.println("Java Parser Version 1.0.2:  Usage is one of:");      System.out.println("         java JavaParser < inputfile");      System.out.println("OR");      System.out.println("         java JavaParser inputfile");      return;    }    try {      parser.CompilationUnit();      System.out.println("Java Parser Version 1.0.2:  Java program parsed successfully.");    } catch (ParseException e) {      System.out.println("Java Parser Version 1.0.2:  Encountered errors during parse.");    }  }}PARSER_END(JavaParser)/* WHITE SPACE */SKIP :{  " "| "\t"| "\n"| "\r"| "\f"}/* COMMENTS */MORE :{  "//" : IN_SINGLE_LINE_COMMENT|  <"/**" ~["/"]> { input_stream.backup(1); } : IN_FORMAL_COMMENT|  "/*" : IN_MULTI_LINE_COMMENT}<IN_SINGLE_LINE_COMMENT>SPECIAL_TOKEN :{  <SINGLE_LINE_COMMENT: "\n" | "\r" | "\r\n" > : DEFAULT}<IN_SINGLE_LINE_COMMENT>MORE :{  < ~[] >}<IN_FORMAL_COMMENT>SPECIAL_TOKEN :{  <FORMAL_COMMENT: "*/" > : DEFAULT}<IN_MULTI_LINE_COMMENT>SPECIAL_TOKEN :{  <MULTI_LINE_COMMENT: "*/" > : DEFAULT}<IN_FORMAL_COMMENT,IN_MULTI_LINE_COMMENT>MORE :{  < ~[] >}/* RESERVED WORDS AND LITERALS */TOKEN :{  < ABSTRACT: "abstract" >| < BOOLEAN: "boolean" >| < BREAK: "break" >| < BYTE: "byte" >| < CASE: "case" >| < CATCH: "catch" >| < CHAR: "char" >| < CLASS: "class" >| < CONST: "const" >| < CONTINUE: "continue" >| < _DEFAULT: "default" >| < DO: "do" >| < DOUBLE: "double" >| < ELSE: "else" >| < EXTENDS: "extends" >| < FALSE: "false" >| < FINAL: "final" >| < FINALLY: "finally" >| < FLOAT: "float" >| < FOR: "for" >| < GOTO: "goto" >| < IF: "if" >| < IMPLEMENTS: "implements" >| < IMPORT: "import" >| < INSTANCEOF: "instanceof" >| < INT: "int" >| < INTERFACE: "interface" >| < LONG: "long" >| < NATIVE: "native" >| < NEW: "new" >| < NULL: "null" >| < PACKAGE: "package">| < PRIVATE: "private" >| < PROTECTED: "protected" >| < PUBLIC: "public" >| < RETURN: "return" >| < SHORT: "short" >| < STATIC: "static" >| < SUPER: "super" >| < SWITCH: "switch" >| < SYNCHRONIZED: "synchronized" >| < THIS: "this" >| < THROW: "throw" >| < THROWS: "throws" >| < TRANSIENT: "transient" >| < TRUE: "true" >| < TRY: "try" >| < VOID: "void" >| < VOLATILE: "volatile" >| < WHILE: "while" >}/* LITERALS */TOKEN :{  < INTEGER_LITERAL:        <DECIMAL_LITERAL> (["l","L"])?      | <HEX_LITERAL> (["l","L"])?      | <OCTAL_LITERAL> (["l","L"])?  >|  < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >|  < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >|  < #OCTAL_LITERAL: "0" (["0"-"7"])* >|  < FLOATING_POINT_LITERAL:        (["0"-"9"])+ "." (["0"-"9"])* (<EXPONENT>)? (["f","F","d","D"])?      | "." (["0"-"9"])+ (<EXPONENT>)? (["f","F","d","D"])?      | (["0"-"9"])+ <EXPONENT> (["f","F","d","D"])?      | (["0"-"9"])+ (<EXPONENT>)? ["f","F","d","D"]  >|  < #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >|  < CHARACTER_LITERAL:      "'"      (   (~["'","\\","\n","\r"])        | ("\\"            ( ["n","t","b","r","f","\\","'","\""]            | ["0"-"7"] ( ["0"-"7"] )?            | ["0"-"3"] ["0"-"7"] ["0"-"7"]            )          )      )      "'"  >|  < STRING_LITERAL:      "\""      (   (~["\"","\\","\n","\r"])        | ("\\"            ( ["n","t","b","r","f","\\","'","\""]            | ["0"-"7"] ( ["0"-"7"] )?            | ["0"-"3"] ["0"-"7"] ["0"-"7"]            )          )      )*      "\""  >}/* IDENTIFIERS */TOKEN :{  < IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)* >|  < #LETTER:      [       "\u0024",       "\u0041"-"\u005a",       "\u005f",       "\u0061"-"\u007a",       "\u00c0"-"\u00d6",       "\u00d8"-"\u00f6",       "\u00f8"-"\u00ff",       "\u0100"-"\u1fff",       "\u3040"-"\u318f",       "\u3300"-"\u337f",       "\u3400"-"\u3d2d",       "\u4e00"-"\u9fff",       "\uf900"-"\ufaff"      ]  >|  < #DIGIT:      [       "\u0030"-"\u0039",       "\u0660"-"\u0669",       "\u06f0"-"\u06f9",       "\u0966"-"\u096f",       "\u09e6"-"\u09ef",       "\u0a66"-"\u0a6f",       "\u0ae6"-"\u0aef",       "\u0b66"-"\u0b6f",       "\u0be7"-"\u0bef",       "\u0c66"-"\u0c6f",       "\u0ce6"-"\u0cef",       "\u0d66"-"\u0d6f",       "\u0e50"-"\u0e59",       "\u0ed0"-"\u0ed9",       "\u1040"-"\u1049"      ]  >}TOKEN : /* SEPARATORS */{  < LPAREN: "(" >| < RPAREN: ")" >| < LBRACE: "{" >| < RBRACE: "}" >| < LBRACKET: "[" >| < RBRACKET: "]" >| < SEMICOLON: ";" >| < COMMA: "," >| < DOT: "." >}TOKEN : /* OPERATORS */{  < ASSIGN: "=" >| < GT: ">" >| < LT: "<" >| < BANG: "!" >| < TILDE: "~" >| < HOOK: "?" >| < COLON: ":" >| < EQ: "==" >| < LE: "<=" >| < GE: ">=" >| < NE: "!=" >| < SC_OR: "||" >| < SC_AND: "&&" >| < INCR: "++" >| < DECR: "--" >| < PLUS: "+" >| < MINUS: "-" >| < STAR: "*" >| < SLASH: "/" >| < BIT_AND: "&" >| < BIT_OR: "|" >| < XOR: "^" >| < REM: "%" >| < LSHIFT: "<<" >| < RSIGNEDSHIFT: ">>" >| < RUNSIGNEDSHIFT: ">>>" >| < PLUSASSIGN: "+=" >| < MINUSASSIGN: "-=" >| < STARASSIGN: "*=" >| < SLASHASSIGN: "/=" >| < ANDASSIGN: "&=" >| < ORASSIGN: "|=" >| < XORASSIGN: "^=" >| < REMASSIGN: "%=" >| < LSHIFTASSIGN: "<<=" >| < RSIGNEDSHIFTASSIGN: ">>=" >| < RUNSIGNEDSHIFTASSIGN: ">>>=" >}/***************************************** * THE JAVA LANGUAGE GRAMMAR STARTS HERE * *****************************************//* * Program structuring syntax follows. */void CompilationUnit() :{}{  [ PackageDeclaration() ]  ( ImportDeclaration() )*  ( TypeDeclaration() )*  <EOF>}void PackageDeclaration() :{}{  "package" Name() ";"}void ImportDeclaration() :{}{  "import" Name() [ "." "*" ] ";"}void TypeDeclaration() :{}{  LOOKAHEAD( ( "abstract" | "final" | "public" )* "class" )  ClassDeclaration()|  InterfaceDeclaration()|  ";"}/* * Declaration syntax follows. */void ClassDeclaration() :{}{  ( "abstract" | "final" | "public" )*  "class" <IDENTIFIER> [ "extends" Name() ] [ "implements" NameList() ]  "{" ( ClassBodyDeclaration() )* "}"}void ClassBodyDeclaration() :{}{  LOOKAHEAD(2)  StaticInitializer()|  LOOKAHEAD( [ "public" | "protected" | "private" ] Name() "(" )  ConstructorDeclaration()|  LOOKAHEAD( MethodDeclarationLookahead() )  MethodDeclaration()|  FieldDeclaration()}// This production is to determine lookahead only.void MethodDeclarationLookahead() :{}{  ( "public" | "protected" | "private" | "static" | "abstract" | "final" | "native" | "synchronized" )*  ResultType() <IDENTIFIER> "("}void InterfaceDeclaration() :{}{  ( "abstract" | "public" )*  "interface" <IDENTIFIER> [ "extends" NameList() ]  "{" ( InterfaceMemberDeclaration() )* "}"}void InterfaceMemberDeclaration() :{}{  LOOKAHEAD( MethodDeclarationLookahead() )  MethodDeclaration()|  FieldDeclaration()}void FieldDeclaration() :{}{  ( "public" | "protected" | "private" | "static" | "final" | "transient" | "volatile" )*  Type() VariableDeclarator() ( "," VariableDeclarator() )* ";"}void VariableDeclarator() :{}{  VariableDeclaratorId() [ "=" VariableInitializer() ]}void VariableDeclaratorId() :{}{  <IDENTIFIER> ( "[" "]" )*}void VariableInitializer() :{}{  "{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}"|  Expression()}void MethodDeclaration() :{}{  ( "public" | "protected" | "private" | "static" | "abstract" | "final" | "native" | "synchronized" )*  ResultType() MethodDeclarator() [ "throws" NameList() ]  ( Block() | ";" )}void MethodDeclarator() :{}{  <IDENTIFIER> FormalParameters() ( "[" "]" )*}void FormalParameters() :{}{  "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"}void FormalParameter() :{}{  Type() VariableDeclaratorId()}void ConstructorDeclaration() :{}{  [ "public" | "protected" | "private" ]  <IDENTIFIER> FormalParameters() [ "throws" NameList() ]  "{" [ LOOKAHEAD(2) ExplicitConstructorInvocation() ] ( BlockStatement() )* "}"}void ExplicitConstructorInvocation() :{}{  "this" Arguments() ";"|  "super" Arguments() ";"}void StaticInitializer() :{}{  "static" Block()}/* * Type, name and expression syntax follows. */void Type() :{}{  ( PrimitiveType() | Name() ) ( "[" "]" )*}

⌨️ 快捷键说明

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