Permalink
Browse files

Merge branch 'descriptors' of https://github.com/ceylon/ceylon-spec i…

…nto descriptors
  • Loading branch information...
2 parents 3050ded + 9c568cf commit a355fdb8839785d0b60f79191a7d8c096fa34f7e @gavinking gavinking committed Jul 31, 2012
Showing with 824 additions and 1,634 deletions.
  1. +104 −28 Ceylon.g
  2. +20 −0 Ceylon.nodes
  3. +387 −212 en/modules/declarations.xml
  4. +11 −317 en/modules/expressions.xml
  5. +7 −4 en/modules/introduction.xml
  6. +1 −1 en/modules/lexical.xml
  7. +40 −124 en/modules/modules.xml
  8. +12 −143 en/modules/statementblocks.xml
  9. +0 −390 en/modules/transformations.xml
  10. +0 −78 en/modules/typesystem.xml
  11. +1 −0 src/com/redhat/ceylon/compiler/typechecker/analyzer/DeclarationVisitor.java
  12. +79 −114 src/com/redhat/ceylon/compiler/typechecker/analyzer/ModuleVisitor.java
  13. +1 −15 src/com/redhat/ceylon/compiler/typechecker/analyzer/TypeVisitor.java
  14. +60 −0 src/com/redhat/ceylon/compiler/typechecker/analyzer/Util.java
  15. +6 −24 src/com/redhat/ceylon/compiler/typechecker/model/Module.java
  16. +8 −0 src/com/redhat/ceylon/compiler/typechecker/model/ModuleImport.java
  17. +5 −14 src/com/redhat/ceylon/compiler/typechecker/model/Package.java
  18. +4 −9 test/main/com/redhat/sample/circularity/c1/module.ceylon
  19. +5 −10 test/main/com/redhat/sample/circularity/c2/module.ceylon
  20. +6 −16 test/main/com/redhat/sample/multisource/module.ceylon
  21. +3 −6 test/main/com/redhat/sample/nestedmodules/module.ceylon
  22. +3 −6 test/main/com/redhat/sample/nestedmodules/sub/module.ceylon
  23. 0 test/main/imports/{package → pack}/Alias.ceylon
  24. 0 test/main/imports/{package → pack}/Class.ceylon
  25. 0 test/main/imports/{package → pack}/Dupe.ceylon
  26. 0 test/main/imports/{package → pack}/Interface.ceylon
  27. 0 test/main/imports/{package → pack}/attribute.ceylon
  28. 0 test/main/imports/{package → pack}/method.ceylon
  29. 0 test/main/imports/{package → pack}/op.ceylon
  30. 0 test/main/imports/{package → pack}/singleton.ceylon
  31. +1 −1 test/main/imports/test/Test.ceylon
  32. +1 −1 test/main/imports/test/TestAliases.ceylon
  33. +1 −1 test/main/imports/test/TestWildcard.ceylon
  34. +4 −6 test/main/module.ceylon
  35. +1 −1 test/main/visibility/Unit1.ceylon
  36. 0 test/main/visibility/{package → pack}/Unit3.ceylon
  37. 0 test/main/visibility/{package → pack}/Unit4.ceylon
  38. 0 test/main/visibility/{package → pack}/Unit5.ceylon
  39. 0 test/main/visibility/{package → pack}/Unit6.ceylon
  40. +0 −10 test/moduledep1/com/redhat/ceylon/compiler/typechecker/test/module/a/module.ceylon
  41. +0 −6 test/moduledep1/com/redhat/ceylon/compiler/typechecker/test/module/b/module.ceylon
  42. +0 −11 test/moduledep1/com/redhat/ceylon/compiler/typechecker/test/module/c/module.ceylon
  43. +0 −6 test/moduledep1/com/redhat/ceylon/compiler/typechecker/test/module/d/module.ceylon
  44. +5 −0 test/moduledep1/com/redhat/ceylon/compiler/typechecker/test/modulea/module.ceylon
  45. +3 −0 test/moduledep1/com/redhat/ceylon/compiler/typechecker/test/moduleb/module.ceylon
  46. +5 −0 test/moduledep1/com/redhat/ceylon/compiler/typechecker/test/modulec/module.ceylon
  47. +3 −0 test/moduledep1/com/redhat/ceylon/compiler/typechecker/test/moduled/module.ceylon
  48. +0 −10 test/moduledep2/com/redhat/ceylon/compiler/typechecker/test/module/b/module.ceylon
  49. +0 −6 test/moduledep2/com/redhat/ceylon/compiler/typechecker/test/module/c/module.ceylon
  50. +0 −6 test/moduledep2/com/redhat/ceylon/compiler/typechecker/test/module/d/module.ceylon
  51. +5 −0 test/moduledep2/com/redhat/ceylon/compiler/typechecker/test/moduleb/module.ceylon
  52. +3 −0 test/moduledep2/com/redhat/ceylon/compiler/typechecker/test/modulec/module.ceylon
  53. +3 −0 test/moduledep2/com/redhat/ceylon/compiler/typechecker/test/moduled/module.ceylon
  54. +0 −15 test/moduletest/com/redhat/ceylon/compiler/typechecker/test/module/testdiffversion/module.ceylon
  55. +0 −15 ...moduletest/com/redhat/ceylon/compiler/typechecker/test/module/testdiffversionexport/module.ceylon
  56. +0 −14 test/moduletest/com/redhat/ceylon/compiler/typechecker/test/module/testexportisolation/module.ceylon
  57. +0 −14 test/moduletest/com/redhat/ceylon/compiler/typechecker/test/module/testsameversionwork/module.ceylon
  58. +7 −0 test/moduletest/com/redhat/ceylon/compiler/typechecker/test/moduletestdiffversion/module.ceylon
  59. +7 −0 .../moduletest/com/redhat/ceylon/compiler/typechecker/test/moduletestdiffversionexport/module.ceylon
  60. +6 −0 test/moduletest/com/redhat/ceylon/compiler/typechecker/test/moduletestexportisolation/module.ceylon
  61. +6 −0 test/moduletest/com/redhat/ceylon/compiler/typechecker/test/moduletestsameversionwork/module.ceylon
View
132 Ceylon.g
@@ -41,50 +41,99 @@ compilationUnit returns [CompilationUnit compilationUnit]
SEMICOLON
{ $compilationUnit.getCompilerAnnotations().addAll($ca1.annotations); }
)?
- importList
- { $compilationUnit.setImportList($importList.importList); }
- (
- ca2=compilerAnnotations declaration
- { if ($declaration.declaration!=null)
- $compilationUnit.addDeclaration($declaration.declaration);
- if ($declaration.declaration!=null)
- $declaration.declaration.getCompilerAnnotations().addAll($ca2.annotations); }
- )*
+ (
+ (compilerAnnotations annotations MODULE)=>
+ moduleDescriptor
+ { $compilationUnit.setModuleDescriptor($moduleDescriptor.moduleDescriptor); }
+ |
+ (compilerAnnotations annotations PACKAGE)=>
+ packageDescriptor
+ { $compilationUnit.setPackageDescriptor($packageDescriptor.packageDescriptor); }
+ |
+ importList
+ { $compilationUnit.setImportList($importList.importList); }
+ (
+ ca2=compilerAnnotations declaration
+ { if ($declaration.declaration!=null)
+ $compilationUnit.addDeclaration($declaration.declaration);
+ if ($declaration.declaration!=null)
+ $declaration.declaration.getCompilerAnnotations().addAll($ca2.annotations); }
+ )*
+ )
EOF
;
+moduleDescriptor returns [ModuleDescriptor moduleDescriptor]
+ : compilerAnnotations annotations
+ MODULE
+ { $moduleDescriptor = new ModuleDescriptor($MODULE);
+ $moduleDescriptor.setAnnotationList($annotations.annotationList);
+ $moduleDescriptor.getCompilerAnnotations().addAll($compilerAnnotations.annotations); }
+ packagePath
+ { $moduleDescriptor.setImportPath($packagePath.importPath); }
+ QUOTED_LITERAL
+ { $moduleDescriptor.setVersion(new QuotedLiteral($QUOTED_LITERAL)); }
+ importModuleList
+ { $moduleDescriptor.setImportModuleList($importModuleList.importModuleList); }
+ ;
+
+importModuleList returns [ImportModuleList importModuleList]
+ : LBRACE
+ { $importModuleList = new ImportModuleList($LBRACE); }
+ (
+ compilerAnnotations annotations
+ importModule
+ { if ($importModule.importModule!=null)
+ $importModuleList.addImportModule($importModule.importModule);
+ if ($importModule.importModule!=null)
+ $importModule.importModule.setAnnotationList($annotations.annotationList);
+ if ($importModule.importModule!=null)
+ $importModule.importModule.getCompilerAnnotations().addAll($compilerAnnotations.annotations); }
+ )*
+ RBRACE
+ { $importModuleList.setEndToken($RBRACE); }
+ ;
+
+packageDescriptor returns [PackageDescriptor packageDescriptor]
+ : compilerAnnotations annotations
+ PACKAGE
+ { $packageDescriptor = new PackageDescriptor($PACKAGE);
+ $packageDescriptor.setAnnotationList($annotations.annotationList);
+ $packageDescriptor.getCompilerAnnotations().addAll($compilerAnnotations.annotations); }
+ packagePath
+ { $packageDescriptor.setImportPath($packagePath.importPath); }
+ SEMICOLON
+ { $packageDescriptor.setEndToken($SEMICOLON); }
+ ;
+
+importModule returns [ImportModule importModule]
+ : IMPORT
+ { $importModule = new ImportModule($IMPORT); }
+ packagePath
+ { $importModule.setImportPath($packagePath.importPath); }
+ QUOTED_LITERAL
+ { $importModule.setVersion(new QuotedLiteral($QUOTED_LITERAL)); }
+ SEMICOLON
+ { $importModule.setEndToken($SEMICOLON); }
+ ;
+
importList returns [ImportList importList]
: { $importList = new ImportList(null); }
( importDeclaration { $importList.addImport($importDeclaration.importDeclaration); } )*
;
importDeclaration returns [Import importDeclaration]
- @init { ImportPath importPath=null; }
: IMPORT
{ $importDeclaration = new Import($IMPORT); }
- (
- pn1=packageName
- { importPath = new ImportPath(null);
- if ($pn1.identifier!=null)
- importPath.addIdentifier($pn1.identifier);
- $importDeclaration.setImportPath(importPath); }
- (
- m=MEMBER_OP
- { importPath.setEndToken($m); }
- (
- pn2=packageName
- { importPath.addIdentifier($pn2.identifier);
- importPath.setEndToken(null); }
- | { displayRecognitionError(getTokenNames(),
- new MismatchedTokenException(LIDENTIFIER, input)); }
- )
- )*
+ (
+ packagePath
+ { $importDeclaration.setImportPath($packagePath.importPath); }
| { displayRecognitionError(getTokenNames(),
new MismatchedTokenException(LIDENTIFIER, input)); }
)
importElementList
{ $importDeclaration.setImportMemberOrTypeList($importElementList.importMemberOrTypeList); }
- ;
+ ;
importElementList returns [ImportMemberOrTypeList importMemberOrTypeList]
@init { ImportMemberOrTypeList il=null;
@@ -162,6 +211,25 @@ importName returns [Identifier identifier]
| typeName { $identifier=$typeName.identifier; }
;
+packagePath returns [ImportPath importPath]
+ @init { $importPath = new ImportPath(null); }
+ : pn1=packageName
+ { if ($pn1.identifier!=null)
+ $importPath.addIdentifier($pn1.identifier); }
+ (
+ m=MEMBER_OP
+ { $importPath.setEndToken($m); }
+ (
+ pn2=packageName
+ { $importPath.addIdentifier($pn2.identifier);
+ $importPath.setEndToken(null); }
+ | { displayRecognitionError(getTokenNames(),
+ new MismatchedTokenException(LIDENTIFIER, input)); }
+ )
+ )*
+ ;
+
+
packageName returns [Identifier identifier]
: LIDENTIFIER
{ $identifier = new Identifier($LIDENTIFIER);
@@ -2980,6 +3048,14 @@ FUNCTION_MODIFIER
: 'function'
;
+MODULE
+ : 'module'
+ ;
+
+PACKAGE
+ : 'package'
+ ;
+
NONEMPTY
: 'nonempty'
;
View
@@ -1,9 +1,29 @@
"A file containing Ceylon source."
^(COMPILATION_UNIT
+ MODULE_DESCRIPTOR?
+ PACKAGE_DESCRIPTOR?
COMPILER_ANNOTATION*
IMPORT_LIST?
DECLARATION*)
+^(MODULE_DESCRIPTOR:STATEMENT_OR_ARGUMENT
+ ANNOTATION_LIST?
+ IMPORT_PATH
+ QUOTED_LITERAL version
+ IMPORT_MODULE_LIST)
+
+^(PACKAGE_DESCRIPTOR:STATEMENT_OR_ARGUMENT
+ ANNOTATION_LIST?
+ IMPORT_PATH)
+
+^(IMPORT_MODULE_LIST
+ IMPORT_MODULE*)
+
+^(IMPORT_MODULE:STATEMENT_OR_ARGUMENT
+ ANNOTATION_LIST?
+ IMPORT_PATH
+ QUOTED_LITERAL version)
+
^(IMPORT_LIST
IMPORT*)
Oops, something went wrong.

0 comments on commit a355fdb

Please sign in to comment.