Update of /cvsroot/bprocessor/bscript/src/etc
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv5814/src/etc
Modified Files:
bscript.g
Log Message:
Added a script to project that can contain userdefined functions
Index: bscript.g
===================================================================
RCS file: /cvsroot/bprocessor/bscript/src/etc/bscript.g,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** bscript.g 12 Sep 2006 12:59:36 -0000 1.5
--- bscript.g 13 Sep 2006 13:36:32 -0000 1.6
***************
*** 2,5 ****
--- 2,8 ----
package net.sourceforge.bprocessor.parser;
import net.sourceforge.bprocessor.model.evaluator.*;
+ import java.util.Map;
+ import java.util.List;
+ import java.util.LinkedList;
}
***************
*** 65,69 ****
--- 68,87 ----
: statement[env] End
;
+
+ script[Map map]
+ : ( definition[map] ) *
+ ;
+ definition[Map map]
+ { Function function; List formals = new LinkedList(); }
+ : "to" name:Identifier
+ ( formal:Identifier { formals.add(formal.getText()); } ) *
+ { function = new Function(name.getText(), formals); }
+ "begin"
+ ( statement[function] End ) *
+ "end"
+ { map.put(name.getText(), function); }
+ ;
+
statement[Function env]
: name:Identifier { env.append(new Mark()); }
|