pax_global_header00006660000000000000000000000064146104264430014516gustar00rootroot0000000000000052 comment=14901c5f4aead1cdd28d2d05007f130b055f5ab6 java-1.1.2/000077500000000000000000000000001461042644300124405ustar00rootroot00000000000000java-1.1.2/.gitignore000066400000000000000000000000531461042644300144260ustar00rootroot00000000000000/node_modules/ /src/parser.* .tern-* /dist java-1.1.2/.npmignore000066400000000000000000000000161461042644300144340ustar00rootroot00000000000000/node_modules java-1.1.2/CHANGELOG.md000066400000000000000000000033561461042644300142600ustar00rootroot00000000000000## 1.1.2 (2024-04-19) ### Bug fixes Fix incorrect precedences for binary operators. ## 1.1.1 (2023-12-28) ### Bug fixes Tag comments and strings as isolating for the purpose of bidirectional text. ## 1.1.0 (2023-11-17) ### New features The new `"ClassContent"` top rule allows you to parse only class body declarations. ## 1.0.4 (2023-07-03) ### Bug fixes Make the package work with new TS resolution styles. ## 1.0.3 (2023-02-11) ### Bug fixes Allow multiple adjacent underscores in number literals. ## 1.0.2 (2023-02-06) ### Bug fixes Add missing highlighting tag for the `var` keyword. ## 1.0.1 (2023-02-02) ### Bug fixes Fix highlighting information for float literals. ## 1.0.0 (2022-06-06) ### New features First stable version. ## 0.16.0 (2022-04-20) ### Breaking changes Move to 0.16 serialized parser format. ### Bug fixes Support triple-quoted textblock literals. ### New features The parser now includes syntax highlighting information in its node types. ## 0.15.0 (2021-08-11) ### Breaking changes The module's name changed from `lezer-java` to `@lezer/java`. Upgrade to the 0.15.0 lezer interfaces. ## 0.13.2 (2020-12-09) ### New features The method name in MethodInvocation nodes is now wrapped in a MethodName node. ## 0.13.1 (2020-12-04) ### Bug fixes Fix versions of lezer packages depended on. ## 0.13.0 (2020-12-04) ## 0.12.0 (2020-10-23) ### Breaking changes Adjust to changed serialized parser format. ## 0.11.1 (2020-09-26) ### Bug fixes Fix lezer depencency versions ## 0.11.0 (2020-09-26) ### Breaking changes Follow change in serialized parser format. ### Bug fixes Fix a conflict previously hidden by a bug in the generator. ## 0.10.0 (2020-09-10) ### Breaking changes First numbered release. java-1.1.2/LICENSE000066400000000000000000000021311461042644300134420ustar00rootroot00000000000000MIT License Copyright (C) 2020 by Marijn Haverbeke and others Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. java-1.1.2/README.md000066400000000000000000000004301461042644300137140ustar00rootroot00000000000000# @lezer/java This is a Java grammar for the [Lezer](https://lezer.codemirror.net/) parser system. The grammar used is based in a large part on the corresponding [tree-sitter grammar](https://github.com/tree-sitter/tree-sitter-java). The code is licensed under an MIT license. java-1.1.2/dist/000077500000000000000000000000001461042644300134035ustar00rootroot00000000000000java-1.1.2/dist/index.d.cts000066400000000000000000000001021461042644300154400ustar00rootroot00000000000000import {LRParser} from "@lezer/lr" export const parser: LRParser java-1.1.2/dist/index.d.ts000066400000000000000000000001021461042644300152750ustar00rootroot00000000000000import {LRParser} from "@lezer/lr" export const parser: LRParser java-1.1.2/package.json000066400000000000000000000017351461042644300147340ustar00rootroot00000000000000{ "name": "@lezer/java", "version": "1.1.2", "description": "lezer-based Java grammar", "main": "dist/index.cjs", "type": "module", "exports": { "import": "./dist/index.js", "require": "./dist/index.cjs" }, "module": "dist/index.js", "types": "dist/index.d.ts", "author": "Marijn Haverbeke ", "license": "MIT", "devDependencies": { "@lezer/generator": "^1.0.0", "mocha": "^10.2.0", "rollup": "^2.52.2", "@rollup/plugin-node-resolve": "^9.0.0" }, "dependencies": { "@lezer/common": "^1.2.0", "@lezer/lr": "^1.0.0", "@lezer/highlight": "^1.0.0" }, "repository": { "type" : "git", "url" : "https://github.com/lezer-parser/java.git" }, "scripts": { "build": "lezer-generator src/java.grammar -o src/parser && rollup -c", "build-debug": "lezer-generator src/java.grammar --names -o src/parser && rollup -c", "prepare": "npm run build", "test": "mocha test/test-*.js" } } java-1.1.2/rollup.config.js000066400000000000000000000004621461042644300155610ustar00rootroot00000000000000import {nodeResolve} from "@rollup/plugin-node-resolve" export default { input: "./src/parser.js", output: [{ format: "cjs", file: "./dist/index.cjs" }, { format: "es", file: "./dist/index.js" }], external(id) { return !/^[\.\/]/.test(id) }, plugins: [ nodeResolve() ] } java-1.1.2/src/000077500000000000000000000000001461042644300132275ustar00rootroot00000000000000java-1.1.2/src/highlight.js000066400000000000000000000025421461042644300155370ustar00rootroot00000000000000import {styleTags, tags as t} from "@lezer/highlight" export const javaHighlighting = styleTags({ null: t.null, instanceof: t.operatorKeyword, this: t.self, "new super assert open to with void": t.keyword, "class interface extends implements enum var": t.definitionKeyword, "module package import": t.moduleKeyword, "switch while for if else case default do break continue return try catch finally throw": t.controlKeyword, ["requires exports opens uses provides public private protected static transitive abstract final " + "strictfp synchronized native transient volatile throws"]: t.modifier, IntegerLiteral: t.integer, FloatingPointLiteral: t.float, "StringLiteral TextBlock": t.string, CharacterLiteral: t.character, LineComment: t.lineComment, BlockComment: t.blockComment, BooleanLiteral: t.bool, PrimitiveType: t.standard(t.typeName), TypeName: t.typeName, Identifier: t.variableName, "MethodName/Identifier": t.function(t.variableName), Definition: t.definition(t.variableName), ArithOp: t.arithmeticOperator, LogicOp: t.logicOperator, BitOp: t.bitwiseOperator, CompareOp: t.compareOperator, AssignOp: t.definitionOperator, UpdateOp: t.updateOperator, Asterisk: t.punctuation, Label: t.labelName, "( )": t.paren, "[ ]": t.squareBracket, "{ }": t.brace, ".": t.derefOperator, ", ;": t.separator }) java-1.1.2/src/java.grammar000066400000000000000000000331341461042644300155240ustar00rootroot00000000000000@precedence { cast update @left unaryPlus @left negate @left instanceof times @left plus @left shift @left compare @left bitAnd @left bitOr @left bitXor @left and @left or @left ternary @right valuePair assign @right array @right new @right else @right scope @left typeArgs } @top Program { statement* } @top ClassContent { classBodyDeclaration* } literal { IntegerLiteral | FloatingPointLiteral | @specialize[@name=BooleanLiteral] | CharacterLiteral | StringLiteral | TextBlock | kw<"null"> } @skip {} { TextBlock { textBlockStart textBlockContent* textBlockEnd } } expression[@isGroup=Expression] { AssignmentExpression | BinaryExpression | InstanceofExpression | LambdaExpression | TernaryExpression | UpdateExpression | baseExpression | UnaryExpression | CastExpression } CastExpression { "(" type ("&" type)* ")" !cast expression } AssignmentExpression { (Identifier | FieldAccess | ArrayAccess) !assign (AssignOp | "=") expression } BinaryExpression { expression !compare (op=" | "<=" | "!="> | CompareOp { "<" | ">" }) expression | expression !and op expression | expression !or op expression | expression !bitAnd BitOp { "&" } expression | expression !bitOr op expression | expression !bitXor op expression | expression !plus op expression | expression !times times expression | expression !shift (op | op>" ">"?>) expression } InstanceofExpression { expression !instanceof kw<"instanceof"> type } LambdaExpression { (Definition | FormalParameters | InferredParameters) "->" (expression | Block) } InferredParameters { "(" commaSep1 ")" } TernaryExpression { expression !ternary op expression ":" expression } UnaryExpression { op !unaryPlus expression | (op | op) !negate expression } UpdateExpression { expression !update op | op !update expression } baseExpression { literal | ClassLiteral | kw<"this"> | Identifier ~identifier | ParenthesizedExpression | ObjectCreationExpression | FieldAccess | ArrayAccess | MethodInvocation | MethodReference | ArrayCreationExpression } ArrayCreationExpression { kw<"new"> simpleType Dimension { annotation* !array "[" expression? "]" }+ ArrayInitializer? } ParenthesizedExpression { "(" expression ")" } ClassLiteral { unannotatedType "." kw<"class"> } ObjectCreationExpression { unqualifiedObjectCreationExpression | baseExpression "." unqualifiedObjectCreationExpression } unqualifiedObjectCreationExpression { kw<"new"> TypeArguments? simpleType !new ArgumentList ClassBody? } FieldAccess { (baseExpression | kw<"super">) ("." kw<"super">)? "." (Identifier | kw<"this">) } ArrayAccess { baseExpression "[" expression "]" } MethodName { Identifier } MethodInvocation { (MethodName | (baseExpression | kw<"super">) "." (kw<"super"> ".")? TypeArguments? MethodName) ArgumentList } ArgumentList { "(" commaSep ")" } MethodReference { (type | baseExpression | kw<"super">) "::" TypeArguments? (kw<"new"> | Identifier) } TypeArguments { "<" commaSep ">" } Wildcard { annotation* "?" wildcardBounds? } wildcardBounds { kw<"extends"> type | kw<"super"> type } Dimension { annotation* !array "[" "]" } statement[@isGroup=Statement] { declaration | ExpressionStatement | LabeledStatement | IfStatement | WhileStatement | ForStatement | EnhancedForStatement | Block | ";" | AssertStatement | SwitchStatement | DoStatement | BreakStatement | ContinueStatement | ReturnStatement | SynchronizedStatement | LocalVariableDeclaration | ThrowStatement | TryStatement | TryWithResourcesStatement } Block { "{" statement* "}" } ExpressionStatement { expression ";" } LabeledStatement { Label ":" statement } Label { identifier | capitalIdentifier } AssertStatement { kw<"assert"> expression ";" | kw<"assert"> expression ":" expression ";" } SwitchStatement { kw<"switch"> ParenthesizedExpression SwitchBlock } SwitchBlock { "{" (SwitchLabel | statement)* "}" } SwitchLabel { kw<"case"> expression ":" | kw<"default"> ":" } DoStatement { kw<"do"> statement kw<"while"> ParenthesizedExpression ";" } BreakStatement { kw<"break"> Label? ";" } ContinueStatement { kw<"continue"> Label? ";" } ReturnStatement { kw<"return"> expression? ";" } SynchronizedStatement { kw<"synchronized"> ParenthesizedExpression Block } ThrowStatement { kw<"throw"> expression ";" } TryStatement { kw<"try"> Block CatchClause* FinallyClause? } CatchClause { !else kw<"catch"> CatchFormalParameter Block } CatchFormalParameter { "(" Modifiers? CatchType variableDeclaratorId ")" } CatchType { unannotatedType ("|" unannotatedType)* } FinallyClause { kw<"finally"> Block } TryWithResourcesStatement { kw<"try"> ResourceSpecification Block CatchClause* FinallyClause? } ResourceSpecification { "(" Resource (";" Resource)* ";"? ")" } Resource { Modifiers? unannotatedType variableDeclaratorId "=" expression | Identifier | FieldAccess } IfStatement { kw<"if"> ParenthesizedExpression statement (!else kw<"else"> statement)? } WhileStatement { kw<"while"> ParenthesizedExpression statement } ForStatement { kw<"for"> ForSpec { "(" (LocalVariableDeclaration | commaSep ";") expression? ";" commaSep ")" } statement } EnhancedForStatement { kw<"for"> ForSpec { "(" Modifiers? unannotatedType variableDeclaratorId ":" expression ")" } statement } annotation { MarkerAnnotation | Annotation } MarkerAnnotation { "@" name } Annotation { "@" name AnnotationArgumentList } AnnotationArgumentList { "(" (elementValue | commaSep) ")" } ElementValuePair { Identifier !valuePair "=" elementValue } elementValue { (expression | ElementValueArrayInitializer | annotation) !valuePair } ElementValueArrayInitializer { "{" commaSepTrailing "}" } declaration { ModuleDeclaration | PackageDeclaration | ImportDeclaration | ClassDeclaration | InterfaceDeclaration | AnnotationTypeDeclaration | EnumDeclaration } ModuleDeclaration { annotation* ckw<"open">? ckw<"module"> name ModuleBody } ModuleBody { "{" ModuleDirective* "}" } ModuleDirective { (kw<"requires"> requiresModifier* name | kw<"exports"> name kw<"to">? commaSep | kw<"opens"> name kw<"to">? commaSep | kw<"uses"> name | kw<"provides"> name kw<"with"> commaSep1) ";" } requiresModifier { kw<"transitive"> | kw<"static"> } PackageDeclaration { annotation* kw<"package"> name ";" } ImportDeclaration { kw<"import"> kw<"static">? name ("." Asterisk)? ";" } EnumDeclaration { Modifiers? kw<"enum"> Definition SuperInterfaces? EnumBody } EnumBody { "{" commaSepTrailing EnumBodyDeclarations? "}" } EnumBodyDeclarations { ";" classBodyDeclaration* } EnumConstant { Modifiers? Definition ArgumentList? ClassBody? } ClassDeclaration { Modifiers? kw<"class"> Definition TypeParameters? Superclass? SuperInterfaces? ClassBody } Modifiers { annotation+ (modifier annotation*)* ~annotations | (modifier annotation*)+ ~annotations } modifier { kw<"public"> | kw<"protected"> | kw<"private"> | kw<"abstract"> | kw<"static"> | kw<"final"> | kw<"strictfp"> | kw<"default"> kw<"synchronized"> | kw<"native"> | kw<"transient"> | kw<"volatile"> } TypeParameters { "<" commaSep1 ">" } TypeParameter { annotation* Definition TypeBound? } TypeBound { kw<"extends"> type ("&" type)* } Superclass { kw<"extends"> type } SuperInterfaces { kw<"implements"> InterfaceTypeList } InterfaceTypeList { commaSep1 } ClassBody { "{" classBodyDeclaration* "}" } classBodyDeclaration { FieldDeclaration | MethodDeclaration | ClassDeclaration | InterfaceDeclaration | AnnotationTypeDeclaration | EnumDeclaration | Block | StaticInitializer | ConstructorDeclaration | ";" } StaticInitializer { kw<"static"> Block } ConstructorDeclaration { Modifiers? constructorDeclarator Throws? ConstructorBody } constructorDeclarator { TypeParameters? Definition FormalParameters } ConstructorBody { "{" ExplicitConstructorInvocation? statement* "}" } ExplicitConstructorInvocation { (TypeArguments? (kw<"this"> | kw<"super">) | (baseExpression) "." TypeArguments? kw<"super">) ArgumentList ";" } name { Identifier | ScopedIdentifier } ScopedIdentifier { name "." Identifier } FieldDeclaration { Modifiers? unannotatedType commaSep1 ";" } AnnotationTypeDeclaration { Modifiers? "@interface" Identifier AnnotationTypeBody } AnnotationTypeBody { "{" ( AnnotationTypeElementDeclaration | ConstantDeclaration | ClassDeclaration | InterfaceDeclaration | AnnotationTypeDeclaration )* "}" } AnnotationTypeElementDeclaration { Modifiers? unannotatedType Identifier "(" ")" Dimension* defaultValue? ";" } defaultValue { kw<"default"> elementValue } InterfaceDeclaration { Modifiers? kw<"interface"> Definition TypeParameters? ExtendsInterfaces? InterfaceBody } ExtendsInterfaces { kw<"extends"> InterfaceTypeList } InterfaceBody { "{" ( ConstantDeclaration | EnumDeclaration | MethodDeclaration | ClassDeclaration | InterfaceDeclaration | AnnotationTypeDeclaration | ";" )* "}" } ConstantDeclaration { Modifiers? unannotatedType commaSep1 ";" } VariableDeclarator { variableDeclaratorId ("=" variableInitializer)? } variableDeclaratorId { Definition Dimension* } variableInitializer { expression | ArrayInitializer } ArrayInitializer { "{" commaSepTrailing "}" } type[@isGroup=Type] { unannotatedType | AnnotatedType { annotation+ unannotatedType } } unannotatedType { ~annotations simpleType | ArrayType } simpleType { kw<"void"> | @specialize[@name=PrimitiveType] | TypeName | ScopedTypeName | GenericType } TypeName { ~annotations ( capitalIdentifier ~identifier | [@dynamicPrecedence=-1] { identifier ~identifier } ) } Identifier { identifier ~identifier | [@dynamicPrecedence=-1] { capitalIdentifier ~identifier } } Definition { identifier ~identifier | capitalIdentifier ~identifier } ScopedTypeName { (TypeName | ScopedTypeName | GenericType) !scope "." annotation* TypeName } GenericType[@dynamicPrecedence=1] { (TypeName | ScopedTypeName) !typeArgs TypeArguments } ArrayType { unannotatedType !array Dimension+ } methodHeader { (TypeParameters annotation*)? unannotatedType methodDeclarator Throws? } methodDeclarator { Definition FormalParameters Dimension* } FormalParameters { "(" ReceiverParameter? commaSep ")" } FormalParameter { Modifiers? unannotatedType variableDeclaratorId } ReceiverParameter { annotation* unannotatedType (Identifier ".")? kw<"this"> } SpreadParameter { Modifiers? unannotatedType "..." VariableDeclarator } Throws { kw<"throws"> commaSep1 } LocalVariableDeclaration { Modifiers? (ckw<"var"> | unannotatedType) commaSep1 ";" } MethodDeclaration { Modifiers? methodHeader (Block | ";") } kw { @specialize[@name={term}] } ckw { @extend[@name={term}] } commaSep { (expr ("," expr)*)? } commaSep1 { expr ("," expr)* } commaSepTrailing { (expr ("," expr?)*)? } @skip { LineComment | BlockComment | whitespace } @tokens { whitespace { @whitespace+ } digits { $[0-9]+ ("_"+ $[0-9]+)* } hexDigits { $[A-Fa-f0-9]+ ("_" $[A-Fa-f0-9]+)* } IntegerLiteral { (digits | ("0x" | "0X") hexDigits | ("0o" | "0O") $[0-7]+ ("_" $[0-7]+)* | ("0b" | "0B") $[01]+ ("_" $[01]+)*) ("l" | "L")? } exponent { $[eE] ("-" | "+")? digits } hexExponent { $[pP] ("-" | "+")? digits } floatSuffix { $[fFdD] } FloatingPointLiteral { digits ("." digits? exponent? floatSuffix? | exponent floatSuffix? | floatSuffix) | "." digits exponent? floatSuffix? | ("0x" | "0X") (hexDigits ("." hexDigits?)? | "." hexDigits) hexExponent floatSuffix? } @precedence { FloatingPointLiteral, IntegerLiteral } CharacterLiteral[isolate] { "'" (![\\'\n] | "\\" ("'" | "\\" | ![\n\\']+)) "'" } StringLiteral[isolate] { "\"" (![\\"\n] | "\\" (![\n] | "\n"))* "\"" } textBlockStart { '"""' $[ \t]* "\n" } @precedence { textBlockStart, StringLiteral } textBlockContent { "\n" | !["\n] textBlockContent? | '"' textBlockQuote } textBlockQuote { !["\n] textBlockContent | "\n" | '"' textBlockQuote2 } textBlockQuote2 { !["\n] textBlockContent | "\n" } textBlockEnd { '"""' } Asterisk { "*" } identifier { $[a-z_$] $[a-zA-Z0-9_$]* } capitalIdentifier { $[A-Z] $[a-zA-Z0-9_$]* } AssignOp { ("+" | "-" | "*" | "/" | "&" | "|" | "^" | "%" | "<<" | ">>" ">"?) "=" } op[@name={name} "Op"] { body } times[@name=ArithOp] { "*" | "/" } LineComment[isolate] { "//" ![\n]* } BlockComment[isolate] { "/*" blockCommentRest } blockCommentRest { ![*] blockCommentRest | "*" blockCommentAfterStar } blockCommentAfterStar { "/" | "*" blockCommentAfterStar | ![/*] blockCommentRest } @precedence { LineComment, times } @precedence { BlockComment, times } "="[@name=AssignOp] "{" "}" "(" ")" "[" "]" "." "," ";" ":" } @external propSource javaHighlighting from "./highlight" @detectDelim java-1.1.2/test/000077500000000000000000000000001461042644300134175ustar00rootroot00000000000000java-1.1.2/test/comments.txt000066400000000000000000000004151461042644300160050ustar00rootroot00000000000000# comment // This is a comment /* This is also a comment */ /* this comment /* // /** ends here: */ ==> Program(LineComment, BlockComment, BlockComment) # comments and literals 123; // comment ==> Program( ExpressionStatement(IntegerLiteral), LineComment) java-1.1.2/test/declarations.txt000066400000000000000000000267321461042644300166420ustar00rootroot00000000000000# local variable class A { public int b() { int c = 5; } } ==> Program( ClassDeclaration(class, Definition, ClassBody( MethodDeclaration( Modifiers(public), PrimitiveType, Definition, FormalParameters, Block( LocalVariableDeclaration( PrimitiveType, VariableDeclarator( Definition, AssignOp, IntegerLiteral))))))) # local array variable String[] nodeNames = internalCluster().getNodeNames(); Integer[][] inputArrays = new Integer[0x100][]; ==> Program( LocalVariableDeclaration( ArrayType( TypeName, Dimension), VariableDeclarator( Definition, AssignOp, MethodInvocation( MethodInvocation( MethodName(Identifier), ArgumentList), MethodName(Identifier), ArgumentList))), LocalVariableDeclaration( ArrayType( TypeName, Dimension, Dimension), VariableDeclarator( Definition, AssignOp, ArrayCreationExpression(new, TypeName, Dimension(IntegerLiteral), Dimension)))) # module module com.foo { } open module com.foo { } ==> Program( ModuleDeclaration(module, ScopedIdentifier( Identifier, Identifier), ModuleBody), ModuleDeclaration(open, module, ScopedIdentifier( Identifier, Identifier), ModuleBody)) # module with normal annotation @RequestForEnhancement( id = 2868724, synopsis = "Provide time-travel functionality", engineer = "Mr. Peabody", date = "4/1/2004" ) module com.foo { } ==> Program( ModuleDeclaration( Annotation( Identifier, AnnotationArgumentList( ElementValuePair(Identifier, AssignOp, IntegerLiteral), ElementValuePair(Identifier, AssignOp, StringLiteral), ElementValuePair(Identifier, AssignOp, StringLiteral), ElementValuePair(Identifier, AssignOp, StringLiteral))), module, ScopedIdentifier(Identifier, Identifier), ModuleBody)) # module with marker annotation @Preliminary module com.foo { } @Preliminary open module com.foo { } ==> Program( ModuleDeclaration( MarkerAnnotation(Identifier), module, ScopedIdentifier(Identifier, Identifier), ModuleBody), ModuleDeclaration( MarkerAnnotation(Identifier), open, module, ScopedIdentifier(Identifier, Identifier), ModuleBody)) # module with single element annotation @Copyright("a") module com.foo {} ==> Program( ModuleDeclaration( Annotation( Identifier, AnnotationArgumentList(StringLiteral)), module, ScopedIdentifier( Identifier, Identifier), ModuleBody)) # package_declaration package myVector; ==> Program(PackageDeclaration(package,Identifier)) # module directive module com.example.foo { requires com.example.foo.http; } ==> Program( ModuleDeclaration(module, ScopedIdentifier( ScopedIdentifier( Identifier, Identifier), Identifier), ModuleBody( ModuleDirective(requires, ScopedIdentifier( ScopedIdentifier( ScopedIdentifier( Identifier, Identifier), Identifier), Identifier))))) # module directive with requires, exports, opens, uses and provides module com.example.foo { requires com.example.http; requires java.logging; requires transitive com.example.network; exports com.example.bar; exports com.example.internal to com.example.probe; opens com.example.quux; opens com.example.internal to com.example.network, com.example.probe; uses com.example.Intf; provides com.example.Intf with com.example.Impl; } ==> Program( ModuleDeclaration(module, ScopedIdentifier(ScopedIdentifier(Identifier, Identifier), Identifier), ModuleBody( ModuleDirective(requires, ScopedIdentifier(ScopedIdentifier(Identifier, Identifier), Identifier)), ModuleDirective(requires, ScopedIdentifier(Identifier, Identifier)), ModuleDirective(requires, transitive, ScopedIdentifier(ScopedIdentifier(Identifier, Identifier), Identifier)), ModuleDirective(exports, ScopedIdentifier(ScopedIdentifier(Identifier, Identifier), Identifier)), ModuleDirective(exports, ScopedIdentifier(ScopedIdentifier(Identifier, Identifier), Identifier), to, ScopedIdentifier(ScopedIdentifier(Identifier, Identifier), Identifier)), ModuleDirective(opens, ScopedIdentifier(ScopedIdentifier(Identifier, Identifier), Identifier)), ModuleDirective(opens, ScopedIdentifier(ScopedIdentifier(Identifier, Identifier), Identifier), to, ScopedIdentifier(ScopedIdentifier(Identifier, Identifier), Identifier), ScopedIdentifier(ScopedIdentifier(Identifier, Identifier), Identifier)), ModuleDirective(uses, ScopedIdentifier(ScopedIdentifier(Identifier, Identifier), Identifier)), ModuleDirective(provides, ScopedIdentifier(ScopedIdentifier(Identifier, Identifier), Identifier), with, ScopedIdentifier(ScopedIdentifier(Identifier, Identifier), Identifier))))) # single type import declaration import java.util.Vector; ==> Program(ImportDeclaration(import, ScopedIdentifier(ScopedIdentifier(Identifier, Identifier), Identifier))) # type_import_on_declaraction import java.util.*; ==> Program(ImportDeclaration(import, ScopedIdentifier(Identifier, Identifier), Asterisk)) # single static import declaration import static java.util.Vector; ==> Program(ImportDeclaration(import, static, ScopedIdentifier( ScopedIdentifier(Identifier, Identifier), Identifier))) # static import on demand declaration import static java.util.*; ==> Program(ImportDeclaration(import, static, ScopedIdentifier(Identifier, Identifier), Asterisk)) # class declaration class Point { } ==> Program( ClassDeclaration(class, Definition, ClassBody)) # class declaration involving public, private, abstract and superclass public class Point { } private class Point { } abstract class ColoredPoint extends Point { } ==> Program( ClassDeclaration(Modifiers(public), class, Definition, ClassBody), ClassDeclaration(Modifiers(private), class, Definition, ClassBody), ClassDeclaration(Modifiers(abstract), class, Definition, Superclass(extends, TypeName), ClassBody)) # class declaration with implements public class Dog implements ISpeak { } ==> Program( ClassDeclaration( Modifiers(public), class, Definition, SuperInterfaces(implements,InterfaceTypeList(TypeName)), ClassBody)) # class declaration with body class Point { int x; void bar() { x = 2; } } ==> Program( ClassDeclaration(class, Definition, ClassBody( FieldDeclaration( PrimitiveType, VariableDeclarator(Definition)), MethodDeclaration( void, Definition, FormalParameters, Block( ExpressionStatement( AssignmentExpression(Identifier, AssignOp, IntegerLiteral))))))) # interface declaration interface Top { } ==> Program( InterfaceDeclaration( interface, Definition, InterfaceBody)) # interface declaration with extends interface Left extends Top { } interface Bottom extends Left, Right {} ==> Program( InterfaceDeclaration( interface, Definition, ExtendsInterfaces(extends,InterfaceTypeList(TypeName)), InterfaceBody), InterfaceDeclaration( interface, Definition, ExtendsInterfaces(extends,InterfaceTypeList(TypeName, TypeName)), InterfaceBody)) # interface with annotation type declaration @interface SelfRef {} ==> Program( AnnotationTypeDeclaration(Identifier, AnnotationTypeBody)) # method declaration class Beyonce { void calculateAnswer(double wingSpan, int numberOfEngines, double length, double grossTons) { //do the calculation here } } ==> Program( ClassDeclaration(class, Definition, ClassBody( MethodDeclaration( void, Definition, FormalParameters( FormalParameter(PrimitiveType, Definition), FormalParameter(PrimitiveType, Definition), FormalParameter(PrimitiveType, Definition), FormalParameter(PrimitiveType, Definition)), Block(LineComment))))) # constructor declaration class Point { int x, y; Point(int x, int y) { this.x = x; this.y = y; } Point() { this(0, 0); } } ==> Program( ClassDeclaration(class, Definition, ClassBody( FieldDeclaration( PrimitiveType, VariableDeclarator(Definition), VariableDeclarator(Definition)), ConstructorDeclaration( Definition, FormalParameters( FormalParameter( PrimitiveType, Definition), FormalParameter( PrimitiveType, Definition)), ConstructorBody( ExpressionStatement(AssignmentExpression( FieldAccess( this, Identifier), AssignOp, Identifier)), ExpressionStatement(AssignmentExpression( FieldAccess( this, Identifier), AssignOp, Identifier)))), ConstructorDeclaration( Definition, FormalParameters, ConstructorBody( ExplicitConstructorInvocation( this, ArgumentList( IntegerLiteral, IntegerLiteral))))))) # throws class Beyonce { BufferedReader newReader() throws FileNotFoundException { new BufferedReader(new InputStreamReader(new FileInputStream(file), charset)); } } ==> Program( ClassDeclaration(class, Definition, ClassBody( MethodDeclaration( TypeName, Definition, FormalParameters, Throws(throws,TypeName), Block( ExpressionStatement( ObjectCreationExpression(new, TypeName, ArgumentList( ObjectCreationExpression(new, TypeName, ArgumentList( ObjectCreationExpression(new, TypeName, ArgumentList(Identifier)), Identifier)))))))))) # object instantiation class Point { public double Foo() { new BufferedWriter(); Foo.new BufferedWriter(); } } ==> Program( ClassDeclaration(class, Definition, ClassBody( MethodDeclaration( Modifiers(public), PrimitiveType, Definition, FormalParameters, Block( ExpressionStatement( ObjectCreationExpression(new, TypeName, ArgumentList)), ExpressionStatement( ObjectCreationExpression( Identifier, new, TypeName, ArgumentList))))))) # variable declaration class JayZ { public void Beyonce() { int blue_ivy_carter; }; } ==> Program( ClassDeclaration(class, Definition, ClassBody( MethodDeclaration( Modifiers(public), void, Definition, FormalParameters, Block( LocalVariableDeclaration( PrimitiveType, VariableDeclarator(Definition))))))) # enum declaration enum HandSign { SCISSOR, PAPER, STONE } ==> Program( EnumDeclaration(enum, Definition, EnumBody( EnumConstant(Definition), EnumConstant(Definition), EnumConstant(Definition)))) java-1.1.2/test/expressions.txt000066400000000000000000000403501461042644300165440ustar00rootroot00000000000000# standalone assignment expression x = 3; ==> Program( ExpressionStatement(AssignmentExpression( Identifier, AssignOp, IntegerLiteral))) # standalone binary expression a > b; a < b; a == b; a >= b; a <= b; a != b; a && b; a || b; a & b; a | b; a ^ b; a % b; a << b; a >> b; a >>> b; 3 + 2; 3 - 2; 3 * 2; 9 / 3; ==> Program( ExpressionStatement(BinaryExpression(Identifier, CompareOp, Identifier)), ExpressionStatement(BinaryExpression(Identifier, CompareOp, Identifier)), ExpressionStatement(BinaryExpression(Identifier, CompareOp, Identifier)), ExpressionStatement(BinaryExpression(Identifier, CompareOp, Identifier)), ExpressionStatement(BinaryExpression(Identifier, CompareOp, Identifier)), ExpressionStatement(BinaryExpression(Identifier, CompareOp, Identifier)), ExpressionStatement(BinaryExpression(Identifier, LogicOp, Identifier)), ExpressionStatement(BinaryExpression(Identifier, LogicOp, Identifier)), ExpressionStatement(BinaryExpression(Identifier, BitOp, Identifier)), ExpressionStatement(BinaryExpression(Identifier, BitOp, Identifier)), ExpressionStatement(BinaryExpression(Identifier, BitOp, Identifier)), ExpressionStatement(BinaryExpression(Identifier, ArithOp, Identifier)), ExpressionStatement(BinaryExpression(Identifier, BitOp, Identifier)), ExpressionStatement(BinaryExpression(Identifier, BitOp, Identifier)), ExpressionStatement(BinaryExpression(Identifier, BitOp, Identifier)), ExpressionStatement(BinaryExpression(IntegerLiteral, ArithOp, IntegerLiteral)), ExpressionStatement(BinaryExpression(IntegerLiteral, ArithOp, IntegerLiteral)), ExpressionStatement(BinaryExpression(IntegerLiteral, ArithOp, IntegerLiteral)), ExpressionStatement(BinaryExpression(IntegerLiteral, ArithOp, IntegerLiteral))) # instanceof expressions a instanceof C.D; a instanceof List; c instanceof C[]; ==> Program( ExpressionStatement(InstanceofExpression( Identifier, instanceof, ScopedTypeName(TypeName, TypeName))), ExpressionStatement(InstanceofExpression( Identifier, instanceof, GenericType(TypeName, TypeArguments(TypeName)))), ExpressionStatement(InstanceofExpression( Identifier, instanceof, ArrayType(TypeName, Dimension)))) # if statements if (x) y; ==> Program( IfStatement(if, ParenthesizedExpression(Identifier), ExpressionStatement(Identifier))) # if statements with braces if (x) { y; } ==> Program( IfStatement(if, ParenthesizedExpression(Identifier), Block(ExpressionStatement(Identifier)))) # if statements with assignment without braces if (x = 3) y = 2; ==> Program( IfStatement(if, ParenthesizedExpression( AssignmentExpression( Identifier, AssignOp, IntegerLiteral)), ExpressionStatement( AssignmentExpression( Identifier, AssignOp, IntegerLiteral)))) # if then else statement if (x = 3) { y = 9; } else { y = 0; } ==> Program( IfStatement(if, ParenthesizedExpression( AssignmentExpression( Identifier, AssignOp, IntegerLiteral)), Block( ExpressionStatement(AssignmentExpression( Identifier, AssignOp, IntegerLiteral))), else, Block( ExpressionStatement(AssignmentExpression( Identifier, AssignOp, IntegerLiteral))))) # nested if then else statements if (a) if (b) c(); else d(); ==> Program( IfStatement(if, ParenthesizedExpression(Identifier), IfStatement(if, ParenthesizedExpression(Identifier), ExpressionStatement(MethodInvocation(MethodName(Identifier), ArgumentList)), else, ExpressionStatement(MethodInvocation(MethodName(Identifier), ArgumentList))))) # ternary expressions max = (a > b) ? a : b; ==> Program( ExpressionStatement(AssignmentExpression( Identifier, AssignOp, TernaryExpression( ParenthesizedExpression(BinaryExpression( Identifier, CompareOp, Identifier)), LogicOp, Identifier, Identifier)))) # for statement for(int i = 1; i < 11; i++) { System.out.println("Count is: " + i); } for (j.init(i); j.check(); j.update()) { System.out.println(j); } ==> Program( ForStatement(for, ForSpec( LocalVariableDeclaration( PrimitiveType, VariableDeclarator( Definition, AssignOp, IntegerLiteral)), BinaryExpression( Identifier, CompareOp, IntegerLiteral), UpdateExpression(Identifier, UpdateOp,)), Block( ExpressionStatement(MethodInvocation( FieldAccess( Identifier, Identifier), MethodName(Identifier), ArgumentList(BinaryExpression( StringLiteral, ArithOp, Identifier)))))), ForStatement(for, ForSpec( MethodInvocation( Identifier, MethodName(Identifier), ArgumentList(Identifier)), MethodInvocation( Identifier, MethodName(Identifier), ArgumentList), MethodInvocation( Identifier, MethodName(Identifier), ArgumentList)), Block( ExpressionStatement(MethodInvocation( FieldAccess( Identifier, Identifier), MethodName(Identifier), ArgumentList(Identifier)))))) # Enhanced for statements for (A b : c) { d(b); } ==> Program( EnhancedForStatement(for, ForSpec( TypeName, Definition, Identifier), Block( ExpressionStatement(MethodInvocation( MethodName(Identifier), ArgumentList(Identifier)))))) # while statement class WhileDemo { public static void main(String[] args){ int count = 1; while (count < 11) { System.out.println("Count is: " + count); count++; } } } ==> Program( ClassDeclaration(class, Definition, ClassBody( MethodDeclaration( Modifiers(public, static), void, Definition, FormalParameters( FormalParameter( ArrayType( TypeName, Dimension), Definition)), Block( LocalVariableDeclaration( PrimitiveType, VariableDeclarator( Definition, AssignOp, IntegerLiteral)), WhileStatement(while, ParenthesizedExpression( BinaryExpression( Identifier, CompareOp, IntegerLiteral)), Block( ExpressionStatement(MethodInvocation( FieldAccess( Identifier, Identifier), MethodName(Identifier), ArgumentList( BinaryExpression(StringLiteral, ArithOp, Identifier)))), ExpressionStatement(UpdateExpression(Identifier, UpdateOp))))))))) # try-with-resources statements try (FileInputStream input = new FileInputStream("file.txt")) { int data = input.read(); } ==> Program( TryWithResourcesStatement(try, ResourceSpecification( Resource( TypeName, Definition, AssignOp, ObjectCreationExpression(new, TypeName, ArgumentList(StringLiteral)))), Block( LocalVariableDeclaration( PrimitiveType, VariableDeclarator( Definition, AssignOp, MethodInvocation( Identifier, MethodName(Identifier), ArgumentList)))))) # return statement return x; return x * y; return x + 2; return fire(x); ==> Program( ReturnStatement(return,Identifier), ReturnStatement(return,BinaryExpression(Identifier, ArithOp, Identifier)), ReturnStatement(return,BinaryExpression(Identifier, ArithOp, IntegerLiteral)), ReturnStatement(return,MethodInvocation(MethodName(Identifier), ArgumentList(Identifier)))) # annotation @SuppressWarnings(value = "unchecked") @GwtCompatible(emulated = true) class Duck { } ==> Program( ClassDeclaration( Modifiers( Annotation( Identifier, AnnotationArgumentList( ElementValuePair( Identifier, AssignOp, StringLiteral))), Annotation( Identifier, AnnotationArgumentList( ElementValuePair( Identifier, AssignOp, BooleanLiteral)))), class, Definition, ClassBody)) # marker annotation @Override class Quack { @bar public void foo() { } } ==> Program( ClassDeclaration( Modifiers(MarkerAnnotation(Identifier)), class, Definition, ClassBody( MethodDeclaration( Modifiers(MarkerAnnotation(Identifier), public), void, Definition, FormalParameters, Block)))) # single element annotation @Duck(waddle.swim) @SuppressWarnings("unchecked") class Quack { } ==> Program( ClassDeclaration( Modifiers( Annotation(Identifier, AnnotationArgumentList(FieldAccess(Identifier, Identifier))), Annotation(Identifier, AnnotationArgumentList(StringLiteral))), class, Definition, ClassBody)) # lambda expression class LambdaTest { void singleton() { version -> create; (a, b) -> a + b; } } ==> Program( ClassDeclaration(class, Definition, ClassBody( MethodDeclaration( void, Definition, FormalParameters, Block( ExpressionStatement(LambdaExpression( Definition, Identifier)), ExpressionStatement(LambdaExpression( InferredParameters(Definition, Definition), BinaryExpression(Identifier, ArithOp, Identifier)))))))) # switch statement public class SwitchDemo { public static void main(String[] args) { int destinysChild = 2; String destinysChildString; switch (destinysChild) { case 1: destinysChildString = "Beyonce"; break; case 2: destinysChildString = "Kelly"; break; case 3: destinysChildString = "Michelle"; break; default: destinysChildString = "Invalid"; break; } System.out.println(destinysChildString); } } ==> Program( ClassDeclaration( Modifiers(public), class, Definition, ClassBody( MethodDeclaration( Modifiers(public, static), void, Definition, FormalParameters( FormalParameter( ArrayType( TypeName, Dimension), Definition)), Block( LocalVariableDeclaration( PrimitiveType, VariableDeclarator( Definition, AssignOp, IntegerLiteral)), LocalVariableDeclaration( TypeName, VariableDeclarator(Definition)), SwitchStatement(switch, ParenthesizedExpression(Identifier), SwitchBlock( SwitchLabel(case,IntegerLiteral), ExpressionStatement(AssignmentExpression( Identifier, AssignOp, StringLiteral)), BreakStatement(break), SwitchLabel(case,IntegerLiteral), ExpressionStatement(AssignmentExpression( Identifier, AssignOp, StringLiteral)), BreakStatement(break), SwitchLabel(case,IntegerLiteral), ExpressionStatement(AssignmentExpression( Identifier, AssignOp, StringLiteral)), BreakStatement(break), SwitchLabel(default), ExpressionStatement(AssignmentExpression( Identifier, AssignOp, StringLiteral)), BreakStatement(break))), ExpressionStatement(MethodInvocation( FieldAccess( Identifier, Identifier), MethodName(Identifier), ArgumentList(Identifier)))))))) # type arguments class Box { private T theObject; public Box( T arg) { theObject = arg; } // more code } ==> Program( ClassDeclaration(class, Definition, TypeParameters( TypeParameter( Definition)), ClassBody( FieldDeclaration( Modifiers(private), TypeName, VariableDeclarator(Definition)), ConstructorDeclaration( Modifiers(public), Definition, FormalParameters( FormalParameter( TypeName, Definition)), ConstructorBody( ExpressionStatement(AssignmentExpression( Identifier, AssignOp, Identifier)))), LineComment))) # wildcard class WildcardDemo { List a; } ==> Program( ClassDeclaration(class, Definition, ClassBody( FieldDeclaration( GenericType( TypeName, TypeArguments( Wildcard(extends, TypeName))), VariableDeclarator(Definition))))) # type arguments with generic types class someClass { public List someMethod() { List< T > list = Collections.< T >emptyList(); return list; } public static void anotherMethod(S arg) { List< S > list = Collections.< S >emptyList(); } } ==> Program( ClassDeclaration(class, Definition, TypeParameters( TypeParameter( Definition)), ClassBody( MethodDeclaration( Modifiers(public), GenericType( TypeName, TypeArguments(TypeName)), Definition, FormalParameters, Block( LocalVariableDeclaration( GenericType( TypeName, TypeArguments(TypeName)), VariableDeclarator( Definition, AssignOp, MethodInvocation( Identifier, TypeArguments(TypeName), MethodName(Identifier), ArgumentList))), ReturnStatement(return,Identifier))), MethodDeclaration( Modifiers(public, static), TypeParameters( TypeParameter( Definition)), void, Definition, FormalParameters( FormalParameter( TypeName, Definition)), Block( LocalVariableDeclaration( GenericType( TypeName, TypeArguments(TypeName)), VariableDeclarator( Definition, AssignOp, MethodInvocation( Identifier, TypeArguments(TypeName), MethodName(Identifier), ArgumentList)))))))) # empty type arguments Box integerBox = new Box<>(); ==> Program( LocalVariableDeclaration( GenericType(TypeName, TypeArguments(TypeName)), VariableDeclarator( Definition, AssignOp, ObjectCreationExpression(new, GenericType(TypeName, TypeArguments), ArgumentList)))) # method references action = bar::method; foo.bar::method; String[]::new; Foo::apply; super::something; ==> Program( ExpressionStatement(AssignmentExpression(Identifier, AssignOp, MethodReference(Identifier, Identifier))), ExpressionStatement(MethodReference(FieldAccess(Identifier, Identifier), Identifier)), ExpressionStatement(MethodReference(ArrayType(TypeName, Dimension), new)), ExpressionStatement(MethodReference(GenericType(TypeName, TypeArguments(TypeName)), Identifier)), ExpressionStatement(MethodReference(super, Identifier))) # text block x = """ hello multi-""-line foo"""; ==> Program(ExpressionStatement(AssignmentExpression(Identifier,AssignOp,TextBlock))) # precedence x = 1 < 2 || a & b ^ c * 2 && 1 + d | e; ==> Program(ExpressionStatement(AssignmentExpression(Identifier,AssignOp, BinaryExpression( BinaryExpression(IntegerLiteral,CompareOp,IntegerLiteral), LogicOp, BinaryExpression( BinaryExpression( BinaryExpression(Identifier,BitOp,Identifier), BitOp, BinaryExpression(Identifier,ArithOp,IntegerLiteral)), LogicOp, BinaryExpression( BinaryExpression(IntegerLiteral,ArithOp,Identifier), BitOp, Identifier)))))) java-1.1.2/test/literals.txt000066400000000000000000000106101461042644300157750ustar00rootroot00000000000000# decimal integer literals 123; 4l; 50L; ==> Program( ExpressionStatement(IntegerLiteral), ExpressionStatement(IntegerLiteral), ExpressionStatement(IntegerLiteral)) # hex integer literals 0xa_bcd_ef0; 0Xa_bcd_ef0; 0X8000L; ==> Program( ExpressionStatement(IntegerLiteral), ExpressionStatement(IntegerLiteral), ExpressionStatement(IntegerLiteral)) # octal integer literals 0o123; 0O123; ==> Program( ExpressionStatement(IntegerLiteral), ExpressionStatement(IntegerLiteral)) # binary integer literal 0b001; 0B001; 0b10; 0B1000; ==> Program( ExpressionStatement(IntegerLiteral), ExpressionStatement(IntegerLiteral), ExpressionStatement(IntegerLiteral), ExpressionStatement(IntegerLiteral)) # floating point literals 4.23e9; 4.23e-9; 4.23e+9; 40.3e6; 40.3e-6; 1.234; 0.123456; .12345; 1e4; 0.2e-2; 0.0e-4; .2e-2; 0x5.4p-10; ==> Program( ExpressionStatement(FloatingPointLiteral), ExpressionStatement(FloatingPointLiteral), ExpressionStatement(FloatingPointLiteral), ExpressionStatement(FloatingPointLiteral), ExpressionStatement(FloatingPointLiteral), ExpressionStatement(FloatingPointLiteral), ExpressionStatement(FloatingPointLiteral), ExpressionStatement(FloatingPointLiteral), ExpressionStatement(FloatingPointLiteral), ExpressionStatement(FloatingPointLiteral), ExpressionStatement(FloatingPointLiteral), ExpressionStatement(FloatingPointLiteral), ExpressionStatement(FloatingPointLiteral)) # boolean literals true; false; ==> Program( ExpressionStatement(BooleanLiteral), ExpressionStatement(BooleanLiteral)) # character literals 'a'; '%'; '\t'; '\\'; '\''; '\u03a9'; '\uFFFF'; '\177'; '™'; ==> Program( ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral)) # string literals ""; "\""; "This is a string"; "'"; ==> Program( ExpressionStatement(StringLiteral), ExpressionStatement(StringLiteral), ExpressionStatement(StringLiteral), ExpressionStatement(StringLiteral)) # null literals null; ==> Program( ExpressionStatement(null)) # char escapes '\b'; '\t'; '\n'; '\f'; '\r'; '\"'; '\''; '\\' + 'a'; ==> Program( ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(BinaryExpression(CharacterLiteral, ArithOp, CharacterLiteral))) # octal escapes '\7'; ==> Program( ExpressionStatement(CharacterLiteral)) # ascii escapes '\NUL'; '\SOH'; '\STX'; '\ETX'; '\EOT'; '\ENQ'; '\ACK'; '\BEL'; '\BS'; '\TAB'; '\LF'; '\VT'; '\FF'; '\CR'; '\SO'; '\SI'; '\DLE'; '\DC1'; '\DC2'; '\DC3'; '\DC4'; '\NAK'; '\SYN'; '\ETB'; '\CAN'; '\EM'; '\SUB'; '\ESC'; '\FS'; '\GS'; '\RS'; '\US'; ==> Program( ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral), ExpressionStatement(CharacterLiteral)) java-1.1.2/test/test-java.js000066400000000000000000000010131461042644300156460ustar00rootroot00000000000000import {parser} from "../dist/index.js" import {fileTests} from "@lezer/generator/dist/test" import * as fs from "fs" import * as path from "path" import {fileURLToPath} from "url" let caseDir = path.dirname(fileURLToPath(import.meta.url)) for (let file of fs.readdirSync(caseDir)) { if (!/\.txt$/.test(file)) continue let name = /^[^\.]*/.exec(file)[0] describe(name, () => { for (let {name, run} of fileTests(fs.readFileSync(path.join(caseDir, file), "utf8"), file)) it(name, () => run(parser)) }) } java-1.1.2/test/types.txt000066400000000000000000000025101461042644300153220ustar00rootroot00000000000000# integral types class Beyonce { int formation() { int x; byte x; short x; long x; char x; } } ==> Program( ClassDeclaration(class, Definition, ClassBody( MethodDeclaration( PrimitiveType, Definition, FormalParameters, Block( LocalVariableDeclaration( PrimitiveType, VariableDeclarator(Definition)), LocalVariableDeclaration( PrimitiveType, VariableDeclarator(Definition)), LocalVariableDeclaration( PrimitiveType, VariableDeclarator(Definition)), LocalVariableDeclaration( PrimitiveType, VariableDeclarator(Definition)), LocalVariableDeclaration( PrimitiveType, VariableDeclarator(Definition))))))) # floating point types class Beyonce { int formation() { float x; double x; } } ==> Program( ClassDeclaration(class, Definition, ClassBody( MethodDeclaration( PrimitiveType, Definition, FormalParameters, Block( LocalVariableDeclaration( PrimitiveType, VariableDeclarator(Definition)), LocalVariableDeclaration( PrimitiveType, VariableDeclarator(Definition)))))))