- Revision
- 1073
- Author
- rfscholte
- Date
- 2011-02-23 14:01:37 -0600 (Wed, 23 Feb 2011)
Log Message
Using ImportDeclaration of JLS
Modified Paths
Diff
Modified: trunk/qdox/src/grammar/parser.y (1072 => 1073)
--- trunk/qdox/src/grammar/parser.y 2011-02-22 15:44:38 UTC (rev 1072) +++ trunk/qdox/src/grammar/parser.y 2011-02-23 20:01:37 UTC (rev 1073) @@ -69,24 +69,40 @@ %type <type> type arrayidentifier classtype typearg %% +// Source: Java Language Specification - Third Edition - // ----- TOP LEVEL // A file consists of 0-n fileparts... file: | file { line = lexer.getLine(); } filepart; // And a filepart is a package/import statement, javadoc comment, or class declaration. -filepart: annotation | package | import | javadoc | class | enum | SEMI; +filepart: annotation | package | ImportDeclaration | javadoc | class | enum | SEMI; // Package statement package: PACKAGE fullidentifier SEMI { builder.addPackage(new PackageDef($2, line)); }; -// Import statement -import: IMPORT fullidentifier SEMI { builder.addImport($2); } | - IMPORT STATIC fullidentifier SEMI { builder.addImport("static " + $3); }; +////ImportDeclarations: ImportDeclaration +//// | ImportDeclarations ImportDeclaration; +// 7.5 Import Declarations +ImportDeclaration: SingleTypeImportDeclaration + | TypeImportOnDemandDeclaration + | SingleStaticImportDeclaration + | StaticImportOnDemandDeclaration; +// 7.5.1 Single-Type-Import Declaration +SingleTypeImportDeclaration: IMPORT fullidentifier SEMI { builder.addImport( $2 ); }; + +// 7.5.2 Type-Import-on-Demand Declaration +TypeImportOnDemandDeclaration: IMPORT fullidentifier DOT STAR SEMI { builder.addImport( $2 + ".*" ); }; + +// 7.5.3 Single Static Import Declaration +SingleStaticImportDeclaration: IMPORT STATIC fullidentifier SEMI { builder.addImport( "static " + $3); }; + +// 7.5.4 Static-Import-on-Demand Declaration +StaticImportOnDemandDeclaration: IMPORT STATIC fullidentifier DOT STAR SEMI { builder.addImport( "static " + $3 + ".*" ); }; + // ----- JAVADOC javadoclist: @@ -118,11 +134,10 @@ // ----- COMMON TOKENS -// A fullidentifier is "a", "a.b", "a.b.c", "a.b.*", etc... +// A fullidentifier is "a", "a.b", "a.b.c", etc... fullidentifier: IDENTIFIER { $$ = $1; } | - fullidentifier DOT IDENTIFIER { $$ = $1 + '.' + $3; } | - fullidentifier DOT STAR { $$ = $1 + ".*"; }; + fullidentifier DOT IDENTIFIER { $$ = $1 + '.' + $3; }; arrayidentifier: IDENTIFIER dimensions {
To unsubscribe from this list please visit:
