[Bprocessor-commit] bscript/src/etc bscript.g,1.11,1.12
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-10-11 11:23:36
|
Update of /cvsroot/bprocessor/bscript/src/etc In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv26191/src/etc Modified Files: bscript.g Log Message: Improved errorhandling in scripting Index: bscript.g =================================================================== RCS file: /cvsroot/bprocessor/bscript/src/etc/bscript.g,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** bscript.g 10 Oct 2006 14:41:36 -0000 1.11 --- bscript.g 11 Oct 2006 11:23:27 -0000 1.12 *************** *** 5,8 **** --- 5,9 ---- import java.util.List; import java.util.LinkedList; + import antlr.CharScanner; } *************** *** 14,38 **** } ! StartTerm: '(' ; ! EndTerm: ')' ; ! Plus : '+' ; ! Minus : '-' ; ! Multiply : '*' ; ! Divide : '/' ; ! Period : '.' ; ! End : ';' ; ! Comma : ',' ; ! Bar : '|' ; ! Lt : '<' ; ! Gt : '>' ; ! LB : '[' ; ! RB : ']' ; ! LC : '{' ; ! RC : '}' ; ! Equal: '=' ; ! LtEq: "<=" ; ! GtEq: ">=" ; ! Assign: ":=" ; protected Letter --- 15,41 ---- } ! StartTerm options { paraphrase = "'('"; } : '(' ; ! EndTerm options { paraphrase = "')'"; } : ')' ; ! Plus options { paraphrase = "'+'"; } : '+' ; ! Minus options { paraphrase = "'-'"; } : '-' ; ! Multiply options { paraphrase = "'*'"; } : '*' ; ! Divide options { paraphrase = "'/'"; } : '/' ; ! Period options { paraphrase = "'.'"; } : '.' ; ! Semicolon options { paraphrase = "';'"; } : ';' ; ! Comma options { paraphrase = "','"; } : ',' ; ! Bar options { paraphrase = "'|'"; } : '|' ; ! Lt options { paraphrase = "'<'"; } : '<' ; ! Gt options { paraphrase = "'>'"; } : '>' ; ! LB options { paraphrase = "'['"; } : '[' ; ! RB options { paraphrase = "']'"; } : ']' ; ! LC options { paraphrase = "'{'"; } : '{' ; ! RC options { paraphrase = "'}'"; } : '}' ; ! ! Equal options { paraphrase = "'='"; } : '=' ; ! LtEq options { paraphrase = "'<='"; } : "<=" ; ! GtEq options { paraphrase = "'>='"; } : ">=" ; ! Assign options { paraphrase = "':='"; } : ":=" ; ! Elipsis : "..."; protected Letter *************** *** 55,74 **** Identifier : (Letter | '_' ) ( Letter | Digit | '_' )* ; String : ( '"' ( ~'"' )* '"' ) ; WhiteSpace ! : ( ' ' ! | '\r' '\n' ! | '\n' ! | '\t' ! ) ! {$setType(Token.SKIP);} ! ; class ScriptParser extends Parser; --- 58,79 ---- Identifier + options { paraphrase = "an identifier"; } : (Letter | '_' ) ( Letter | Digit | '_' )* ; String + options { paraphrase = "a string"; } : ( '"' ( ~'"' )* '"' ) ; + protected Space : ' ' ; + protected Tab : '\t' ; + protected Form : '\f' ; + WhiteSpace ! : ( Space | Tab | Form ) { $setType(Token.SKIP); } ! | ( '\r' | '\n' | '\r''\n' ) { newline(); $setType(Token.SKIP); } ! ; class ScriptParser extends Parser; *************** *** 76,84 **** options { k=3; } program[Function env] ! : statement[env] End ; --- 81,98 ---- options { k=3; + defaultErrorHandler=false; } + { private CharScanner scanner; + public void setScanner(CharScanner scanner) { + this.scanner = scanner; + } + public int getLine() { + return scanner.getLine(); + } + } program[Function env] ! : statement[env] Semicolon ; *************** *** 92,97 **** ( formal:Identifier { formals.add(formal.getText()); } ) * { function = new Function(name.getText(), formals); } "begin" ! ( statement[function] End ) * "end" { map.put(name.getText(), function); } --- 106,112 ---- ( formal:Identifier { formals.add(formal.getText()); } ) * { function = new Function(name.getText(), formals); } + ( Elipsis ) ? "begin" ! ( statement[function] Semicolon) * "end" { map.put(name.getText(), function); } *************** *** 122,126 **** "while" expression[env] { int beforebranch = env.length(); env.append(branchend); } ! "do" ( statement[env] End ) * "end" { int after = env.length(); Branch branch = new Branch(before - after); --- 137,141 ---- "while" expression[env] { int beforebranch = env.length(); env.append(branchend); } ! "do" ( statement[env] Semicolon ) * "end" { int after = env.length(); Branch branch = new Branch(before - after); *************** *** 137,141 **** env.append(branchelse); } ! ( statement[env] End) * ( "end" --- 152,156 ---- env.append(branchelse); } ! ( statement[env] Semicolon) * ( "end" *************** *** 149,153 **** } "else" ! ( statement[env] End) * "end" { --- 164,168 ---- } "else" ! ( statement[env] Semicolon) * "end" { |