Commits

Jesse McGrew committed 2a87071

Added parsing for Constant directive

  • Participants
  • Parent commits 422fb3e

Comments (0)

Files changed (1)

File Rellor.Core/Inform6.g3

 options { k=1; }
 @init { bool omit = false; }
 @after { if (omit) $tree = (CommonTree)adaptor.Nil(); }
-    :	include_directive
+    :	include_directive | BEGIN_INCLUDE | END_INCLUDE
     |	version_directive
     |	release_directive
     |	serial_directive
     |	global_directive
 		{DefineSymbol($Symbols::scope, SymbolType.GlobalVar, $global_directive.identifier, $global_directive.tree);}
     |	verb_directive
-	|	BEGIN_INCLUDE
-	|	END_INCLUDE
+	|	constant_directive
     ;
 
 include_directive
     |	SQ_STRING (SLASH^ SQ_STRING)*
     ;
 
+constant_directive
+	:	kCONSTANTci constant_def (COMMA constant_def)* ';'
+		-> ^(CONSTANT constant_def+)
+	;
+
+constant_def
+	:	id
+		(	EQ? arg_expr
+			{DefineSymbol($Symbols::scope, SymbolType.Constant, $id.start, $arg_expr.tree);}
+			-> ^(id arg_expr)
+		|	/* nada */
+			{DefineSymbol($Symbols::scope, SymbolType.Constant, $id.start, new NumberTree(INT, 1));}
+			-> id
+		)
+	;
+
 /**************************** STATEMENTS ****************************/
 
 statement