[noop] push by aeagle22206 - Add typealias to the grammar on 2009-11-25 23:56 GMT

1 view
Skip to first unread message

no...@googlecode.com

unread,
Nov 25, 2009, 6:57:40 PM11/25/09
to noop-c...@googlegroups.com
Revision: 9108cda75e
Author: Alex Eagle <alex...@google.com>
Date: Wed Nov 25 15:56:45 2009
Log: Add typealias to the grammar
http://code.google.com/p/noop/source/detail?r=9108cda75e

Added:
/examples/noop/injection/Injection.noop
/examples/noop/injection/start_injection.sh
Modified:
/core/src/main/antlr3/noop/grammar/antlr/Noop.g
/core/src/test/scala/noop/grammar/BindingSpec.scala

=======================================
--- /dev/null
+++ /examples/noop/injection/Injection.noop Wed Nov 25 15:56:45 2009
@@ -0,0 +1,7 @@
+import noop.system.CmdLineOption;
+
+binding Injection {
+ noop.Application -> injection.MyApp;
+ alias String ServerUrl;
+ ServerUrl -> CmdLineOption("server");
+}
=======================================
--- /dev/null
+++ /examples/noop/injection/start_injection.sh Wed Nov 25 15:56:45 2009
@@ -0,0 +1,1 @@
+noop injection.Injection --server http://google.com
=======================================
--- /core/src/main/antlr3/noop/grammar/antlr/Noop.g Wed Nov 25 15:40:07 2009
+++ /core/src/main/antlr3/noop/grammar/antlr/Noop.g Wed Nov 25 15:56:45 2009
@@ -212,9 +212,10 @@
-> ^(TRY block FINALLY block)
;

+//TODO(alex): The binding syntax seems a little scattered. Sometimes
semicolon, sometimes comma?
bindingDefinition
- : doc? 'binding' qualifiedType '{' (binding ';')* '}'
- -> ^(BINDING qualifiedType doc? binding*)
+ : doc? 'binding' qualifiedType '{' ((binding | typealias) ';')* '}'
+ -> ^(BINDING qualifiedType doc? binding* typealias*)
;

bindingDeclaration
@@ -235,6 +236,10 @@
: qualifiedType '->' expression
-> ^(BIND qualifiedType expression)
;
+
+typealias
+ : 'alias'^ qualifiedType TypeIdentifier
+ ;

shouldStatement
: expression 'should'^ expression
=======================================
--- /core/src/test/scala/noop/grammar/BindingSpec.scala Wed Nov 25 15:26:47
2009
+++ /core/src/test/scala/noop/grammar/BindingSpec.scala Wed Nov 25 15:56:45
2009
@@ -106,4 +106,12 @@
firstBinding.binding.asInstanceOf[StringLiteralExpression].value
should be ("foo");
}
}
-}
+
+ describe("the type alias") {
+ it("should parse") {
+ val source = "binding App { alias Int Port; }";
+ parser.parseFile(source).toStringTree() should be(
+ "(BINDING App (alias Int Port))");
+ }
+ }
+}
Reply all
Reply to author
Forward
0 new messages