The Language Java BNF Converter % File generated by the BNF Converter. This document was automatically generated by the //BNF-Converter//. ==The lexical structure of Java== ===Literals=== Double-precision float literals //Double// have the structure indicated by the regular expression ``digit+ '.' digit+ ('e' ('-')? digit+)?`` i.e. two sequences of digits separated by a decimal point, optionally followed by an unsigned or negative exponent. Integer literals //Integer// are nonempty sequences of digits. Double-precision float literals //Double// have the structure indicated by the regular expression ``digit+ '.' digit+ ('e' ('-')? digit+)?`` i.e. two sequences of digits separated by a decimal point, optionally followed by an unsigned or negative exponent. HexLong literals are recognized by the regular expression `````('0') ('x' | 'X') (digit | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F')+ ('l' | 'L')````` HexUnsLong literals are recognized by the regular expression `````('0') ('x' | 'X') (digit | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F')+ (('u') ('l') | ('U') ('L'))````` HexUnsigned literals are recognized by the regular expression `````('0') ('x' | 'X') (digit | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F')+ ('u' | 'U')````` Hexadecimal literals are recognized by the regular expression `````('0') ('x' | 'X') (digit | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F')+````` Ident literals are recognized by the regular expression `````(lower | upper) (upper | lower | digit | '_' | ''')*````` JChar literals are recognized by the regular expression `````(''') (char - ''' | '\' | ('\') (''' | '\' | 'n' | 't' | 'r')) (''')````` JDouble literals are recognized by the regular expression `````((digit)+ ('.') | ('.') (digit)+) (('e' | 'E') ('-')? (digit)+)? | (digit)+ ('e' | 'E') ('-')? (digit)+ | (digit)+ ('.') (digit)+ ('E') ('-')? (digit)+````` JFloat literals are recognized by the regular expression `````((digit)+ ('.') (digit)+ | (digit)+ ('.') | ('.') (digit)+) (('e' | 'E') ('-')? (digit)+)? ('f' | 'F') | (digit)+ ('e' | 'E') ('-')? (digit)+ ('f' | 'F')````` JLongDouble literals are recognized by the regular expression `````((digit)+ ('.') (digit)+ | (digit)+ ('.') | ('.') (digit)+) (('e' | 'E') ('-')? (digit)+)? ('l' | 'L') | (digit)+ ('e' | 'E') ('-')? (digit)+ ('l' | 'L')````` Long literals are recognized by the regular expression `````('1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9') (digit)* ('l' | 'L')````` Octal literals are recognized by the regular expression `````('0') ('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7')*````` OctalLong literals are recognized by the regular expression `````('0') ('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7')* ('l' | 'L')````` OctalUnsLong literals are recognized by the regular expression `````('0') ('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7')* (('u') ('l') | ('U') ('L'))````` OctalUnsigned literals are recognized by the regular expression `````('0') ('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7')* ('u' | 'U')````` UnicodeChar literals are recognized by the regular expression `````(''') ('\') ('u') (digit | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F') (digit | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F') (digit | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F') (digit | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F') (''')````` Unsigned literals are recognized by the regular expression `````('1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9') (digit)* ('u' | 'U')````` UnsignedLong literals are recognized by the regular expression `````('1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9') (digit)* (('u') ('l') | ('U') ('L'))````` ===Reserved words and symbols=== The set of reserved words is the set of terminals appearing in the grammar. Those reserved words that consist of non-letter characters are called symbols, and they are treated in a different way from those that are similar to identifiers. The lexer follows rules familiar from languages like Haskell, C, and Java, including longest match and spacing conventions. The reserved words used in Java are the following: | ``abstract`` | ``boolean`` | ``break`` | ``byte`` | ``case`` | ``catch`` | ``char`` | ``class`` | ``continue`` | ``default`` | ``do`` | ``double`` | ``else`` | ``extends`` | ``false`` | ``final`` | ``finally`` | ``float`` | ``for`` | ``if`` | ``implements`` | ``import`` | ``instanceof`` | ``int`` | ``interface`` | ``long`` | ``native`` | ``new`` | ``null`` | ``package`` | ``private`` | ``protected`` | ``public`` | ``return`` | ``short`` | ``static`` | ``super`` | ``switch`` | ``synchronized`` | ``this`` | ``throw`` | ``throws`` | ``transient`` | ``true`` | ``try`` | ``volatile`` | ``while`` | The symbols used in Java the following: | ! | != | % | %= | & | && | &= | ( | ) | * | *= | + | ++ | += | , | - | -- | -= | . | .* | .class | .this | / | /= | : | ; | < | << | <<= | <= | = | == | > | >= | >> | >>= | >>> | >>>= | ? | [ | [] | ] | ^ | ^= | else if | { | | | |= | || | } | ~ | ===Comments=== Single-line comments begin with //. Multiple-line comments are enclosed with /* and */. ==The syntactic structure of Java == Non-terminals are enclosed between < and >. The symbols **->** (production), **|** (union) and **eps** (empty rule) belong to the BNF notation. All other symbols are terminals. | //Args// | -> | ``(`` //[Exp]// ``)`` | //ArrAcc// | -> | //[Ident]// ``[`` //Exp// ``]`` | | **|** | //SpecExp// ``[`` //Exp// ``]`` | //ArrayInits// | -> | //ArrayInits// ``,`` //VariableInits// | | **|** | //VariableInits// | | **|** | //ArrayInits// ``,`` | //Assignment_op// | -> | ``=`` | | **|** | ``+=`` | | **|** | ``&=`` | | **|** | ``/=`` | | **|** | ``<<=`` | | **|** | ``%=`` | | **|** | ``*=`` | | **|** | ``|=`` | | **|** | ``>>=`` | | **|** | ``-=`` | | **|** | ``>>>=`` | | **|** | ``^=`` | //BasicType// | -> | ``boolean`` | | **|** | ``byte`` | | **|** | ``char`` | | **|** | ``double`` | | **|** | ``float`` | | **|** | ``int`` | | **|** | ``long`` | | **|** | ``short`` | //Body// | -> | ``{`` //[LVarStatement]// ``}`` | //BracketsOpt// | -> | ``[]`` | //Catch// | -> | ``catch`` ``(`` //TypeSpec// //Ident// ``)`` //Body// | | **|** | ``catch`` ``(`` //TypeSpec// ``)`` //Body// | //ClassHeader// | -> | //[Modifier]// ``class`` //Ident// | | **|** | //[Modifier]// ``class`` //Ident// ``extends`` //[TypeName]// | | **|** | //[Modifier]// ``class`` //Ident// ``extends`` //[TypeName]// ``implements`` //[TypeName]// | | **|** | //[Modifier]// ``class`` //Ident// ``implements`` //[TypeName]// | | **|** | //[Modifier]// ``interface`` //Ident// | | **|** | //[Modifier]// ``interface`` //Ident// ``extends`` //[TypeName]// | | **|** | //[Modifier]// ``interface`` //Ident// ``extends`` //[TypeName]// ``implements`` //[TypeName]// | | **|** | //[Modifier]// ``interface`` //Ident// ``implements`` //[TypeName]// | //Constant// | -> | //JDouble// | | **|** | //JFloat// | | **|** | //JChar// | | **|** | //JLongDouble// | | **|** | //Double// | | **|** | ``false`` | | **|** | //Double// | | **|** | //Hexadecimal// | | **|** | //HexLong// | | **|** | //HexUnsigned// | | **|** | //HexUnsLong// | | **|** | //Integer// | | **|** | //Long// | | **|** | //Integer// | | **|** | //Octal// | | **|** | //OctalLong// | | **|** | //OctalUnsigned// | | **|** | //OctalUnsLong// | | **|** | ``true`` | | **|** | //UnicodeChar// | | **|** | //Unsigned// | | **|** | //UnsignedLong// | //DeclaratorName// | -> | //Ident// //[BracketsOpt]// | | **|** | //Ident// | //DimExpr// | -> | ``[`` //Exp// ``]`` | //ElseIfStm// | -> | ``else if`` ``(`` //Exp// ``)`` //Stm// | //Exp// | -> | //Exp14// //Assignment_op// //Exp// | | **|** | //Exp14// ``instanceof`` //TypeName// | | **|** | //Exp1// | //FieldAcc// | -> | //[Ident]// ``.class`` | | **|** | //BasicType// ``.class`` | | **|** | //[Ident]// ``.this`` | | **|** | //SpecExp// ``.`` //Ident// | | **|** | //NewAlloc// ``.`` //Ident// | //FieldDeclaration// | -> | //Body// | | **|** | //[Modifier]// //Ident// ``(`` //[Parameter]// ``)`` //Body// | | **|** | //[Modifier]// //Ident// ``(`` //[Parameter]// ``)`` ``throws`` //[TypeName]// //Body// | | **|** | //TypeDeclaration// | | **|** | //[Modifier]// //TypeSpec// //MethodDecl// //MethodBody// | | **|** | //[Modifier]// //TypeSpec// //MethodDecl// ``throws`` //[TypeName]// //MethodBody// | | **|** | //[Modifier]// //TypeSpec// //[VarDecl]// ``;`` | //ForInit// | -> | //TypeSpec// //[VarDecl]// ``;`` | | **|** | ``final`` //TypeSpec// //[VarDecl]// ``;`` | | **|** | //[Exp]// ``;`` | //GuardStm// | -> | ``synchronized`` ``(`` //Exp// ``)`` //Body// | | **|** | ``try`` //Body// //[Catch]// | | **|** | ``try`` //Body// //[Catch]// ``finally`` //Body// | //Import// | -> | ``import`` //[Ident]// ``.*`` //[Semi]// | | **|** | ``import`` //[Ident]// //[Semi]// | //IterStm// | -> | ``do`` //Stm// ``while`` ``(`` //Exp// ``)`` | | **|** | ``for`` ``(`` //ForInit// //[Exp]// ``;`` //[Exp]// ``)`` //Stm// | | **|** | ``while`` ``(`` //Exp// ``)`` //Stm// | //JumpStm// | -> | ``break`` ``;`` | | **|** | ``break`` //Ident// ``;`` | | **|** | ``continue`` ``;`` | | **|** | ``continue`` //Ident// ``;`` | | **|** | ``return`` ``;`` | | **|** | ``return`` //Exp// ``;`` | | **|** | ``throw`` //Exp// ``;`` | //LVarStatement// | -> | //TypeSpec// //[VarDecl]// ``;`` | | **|** | ``final`` //TypeSpec// //[VarDecl]// ``;`` | | **|** | //Stm// | //MethodBody// | -> | ``;`` | | **|** | //Body// | //MethodDecl// | -> | //DeclaratorName// ``(`` //[Parameter]// ``)`` | | **|** | //MethodDecl// //BracketsOpt// | //Modifier// | -> | ``abstract`` | | **|** | ``final`` | | **|** | ``native`` | | **|** | ``private`` | | **|** | ``protected`` | | **|** | ``public`` | | **|** | ``static`` | | **|** | ``synchronized`` | | **|** | ``transient`` | | **|** | ``volatile`` | //MthCall// | -> | //[Ident]// //Args// | | **|** | //SpecExpNP// //Args// | | **|** | //SpecName// //Args// | //NewAlloc// | -> | ``new`` //TypeName// //[DimExpr]// | | **|** | ``new`` //TypeName// //[DimExpr]// ``{`` ``}`` | | **|** | ``new`` //TypeName// //[DimExpr]// ``{`` //ArrayInits// ``}`` | | **|** | ``new`` //TypeName// //Args// | | **|** | ``new`` //TypeName// //Args// ``{`` //[FieldDeclaration]// ``}`` | //Parameter// | -> | //TypeSpec// //DeclaratorName// | | **|** | ``final`` //TypeSpec// //DeclaratorName// | //ProgramFile// | -> | //[Import]// //[TypeDeclaration]// | | **|** | ``package`` //[Ident]// //[Semi]// //[Import]// //[TypeDeclaration]// | //SelectionStm// | -> | ``if`` ``(`` //Exp// ``)`` //Stm// //[ElseIfStm]// ``else`` //Stm// | | **|** | ``if`` ``(`` //Exp// ``)`` //Stm// //[ElseIfStm]// | | **|** | ``switch`` ``(`` //Exp// ``)`` //Body// | //Semi// | -> | ``;`` | //SpecExp// | -> | ``(`` //Exp// ``)`` | | **|** | //SpecExpNP// | | **|** | //SpecName// | //SpecExpNP// | -> | //Constant// | | **|** | //ArrAcc// | | **|** | //FieldAcc// | | **|** | //MthCall// | //SpecName// | -> | ``null`` | | **|** | ``super`` | | **|** | ``this`` | //Stm// | -> | ``case`` //Exp// ``:`` | | **|** | ``default`` ``:`` | | **|** | //Exp// ``;`` | | **|** | //GuardStm// | | **|** | //IterStm// | | **|** | //JumpStm// | | **|** | ``{`` //[LVarStatement]// ``}`` | | **|** | //Ident// ``:`` | | **|** | //SelectionStm// | | **|** | ``;`` | //TypeDeclaration// | -> | //ClassHeader// ``{`` //[FieldDeclaration]// ``}`` | //TypeName// | -> | //BasicType// | | **|** | //[Ident]// | //TypeSpec// | -> | //TypeName// //[BracketsOpt]// | | **|** | //TypeName// | //Unary_operator// | -> | ``~`` | | **|** | ``!`` | | **|** | ``-`` | | **|** | ``+`` | //VarDecl// | -> | //Ident// | | **|** | //DeclaratorName// ``=`` //VariableInits// | //VariableInits// | -> | ``{`` //ArrayInits// ``}`` | | **|** | ``{`` ``}`` | | **|** | //Exp// | //[Ident]// | -> | //Ident// | | **|** | //Ident// ``.`` //[Ident]// | //[BracketsOpt]// | -> | //BracketsOpt// | | **|** | //BracketsOpt// //[BracketsOpt]// | //[Catch]// | -> | **eps** | | **|** | //Catch// //[Catch]// | //[DimExpr]// | -> | //DimExpr// | | **|** | //DimExpr// //[DimExpr]// | //[ElseIfStm]// | -> | **eps** | | **|** | //ElseIfStm// //[ElseIfStm]// | //[Exp]// | -> | **eps** | | **|** | //Exp// | | **|** | //Exp// ``,`` //[Exp]// | //[FieldDeclaration]// | -> | **eps** | | **|** | //FieldDeclaration// //[FieldDeclaration]// | //[Import]// | -> | **eps** | | **|** | //Import// //[Import]// | //[LVarStatement]// | -> | **eps** | | **|** | //LVarStatement// //[LVarStatement]// | //[Modifier]// | -> | **eps** | | **|** | //Modifier// //[Modifier]// | //[Parameter]// | -> | **eps** | | **|** | //Parameter// | | **|** | //Parameter// ``,`` //[Parameter]// | //[Semi]// | -> | **eps** | | **|** | //Semi// //[Semi]// | //[TypeDeclaration]// | -> | **eps** | | **|** | //TypeDeclaration// //[TypeDeclaration]// | //[TypeName]// | -> | //TypeName// | | **|** | //TypeName// ``,`` //[TypeName]// | //[VarDecl]// | -> | //VarDecl// | | **|** | //VarDecl// ``,`` //[VarDecl]// | //Exp1// | -> | //Exp2// | //Exp2// | -> | //Exp3// ``?`` //Exp// ``:`` //Exp2// | | **|** | //Exp3// | //Exp3// | -> | //Exp3// ``||`` //Exp4// | | **|** | //Exp4// | //Exp4// | -> | //Exp4// ``&&`` //Exp5// | | **|** | //Exp5// | //Exp5// | -> | //Exp5// ``|`` //Exp6// | | **|** | //Exp6// | //Exp6// | -> | //Exp6// ``^`` //Exp7// | | **|** | //Exp7// | //Exp7// | -> | //Exp7// ``&`` //Exp8// | | **|** | //Exp8// | //Exp8// | -> | //Exp8// ``==`` //Exp9// | | **|** | //Exp8// ``!=`` //Exp9// | | **|** | //Exp9// | //Exp9// | -> | //Exp9// ``>=`` //Exp10// | | **|** | //Exp9// ``>`` //Exp10// | | **|** | //Exp9// ``<=`` //Exp10// | | **|** | //Exp9// ``<`` //Exp10// | | **|** | //Exp10// | //Exp10// | -> | //Exp10// ``<<`` //Exp11// | | **|** | //Exp10// ``>>`` //Exp11// | | **|** | //Exp10// ``>>>`` //Exp11// | | **|** | //Exp11// | //Exp11// | -> | //Exp11// ``-`` //Exp12// | | **|** | //Exp11// ``+`` //Exp12// | | **|** | //Exp12// | //Exp12// | -> | //Exp12// ``/`` //Exp13// | | **|** | //Exp12// ``%`` //Exp13// | | **|** | //Exp12// ``*`` //Exp13// | | **|** | //Exp13// | //Exp13// | -> | ``(`` //[Ident]// //[BracketsOpt]// ``)`` //Exp13// | | **|** | ``(`` //BasicType// ``)`` //Exp13// | | **|** | ``(`` //Exp// ``)`` //Exp15// | | **|** | //Exp14// | //Exp14// | -> | ``--`` //Exp14// | | **|** | ``++`` //Exp14// | | **|** | //Unary_operator// //Exp13// | | **|** | //Exp15// | //Exp15// | -> | //Exp15// ``--`` | | **|** | //Exp15// ``++`` | | **|** | //Exp16// | //Exp16// | -> | //ArrAcc// | | **|** | //Constant// | | **|** | //FieldAcc// | | **|** | //MthCall// | | **|** | //SpecName// | | **|** | //String// | | **|** | //Exp17// | //Exp17// | -> | //NewAlloc// | | **|** | //Exp18// | //Exp18// | -> | //[Ident]// | | **|** | ``(`` //Exp// ``)``