comparison src/luan/interp/LuaParser.java @ 46:a443637829c1

remove LuaNumber git-svn-id: https://luan-java.googlecode.com/svn/trunk@47 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Thu, 27 Dec 2012 01:48:36 +0000
parents 57054fa43189
children
comparison
equal deleted inserted replaced
45:b1b14d09fc98 46:a443637829c1
15 import org.parboiled.support.StringVar; 15 import org.parboiled.support.StringVar;
16 import org.parboiled.support.StringBuilderVar; 16 import org.parboiled.support.StringBuilderVar;
17 import org.parboiled.support.ValueStack; 17 import org.parboiled.support.ValueStack;
18 import org.parboiled.errors.ErrorUtils; 18 import org.parboiled.errors.ErrorUtils;
19 import luan.Lua; 19 import luan.Lua;
20 import luan.LuaNumber;
21 import luan.LuaState; 20 import luan.LuaState;
22 import luan.LuaSource; 21 import luan.LuaSource;
23 22
24 23
25 class LuaParser extends BaseParser<Object> { 24 class LuaParser extends BaseParser<Object> {
302 Rule NumericForStmt() { 301 Rule NumericForStmt() {
303 Var<Integer> start = new Var<Integer>(); 302 Var<Integer> start = new Var<Integer>();
304 return Sequence( 303 return Sequence(
305 start.set(currentIndex()), 304 start.set(currentIndex()),
306 Keyword("for"), Name(), '=', Spaces(), Expr(), Keyword("to"), Expr(), 305 Keyword("for"), Name(), '=', Spaces(), Expr(), Keyword("to"), Expr(),
307 push( new ConstExpr(LuaNumber.of(1)) ), // default step 306 push( new ConstExpr(1) ), // default step
308 Optional( 307 Optional(
309 Keyword("step"), 308 Keyword("step"),
310 drop(), 309 drop(),
311 Expr() 310 Expr()
312 ), 311 ),
890 Sequence( "false", push(false) ) 889 Sequence( "false", push(false) )
891 ); 890 );
892 } 891 }
893 892
894 Rule NumberLiteral() { 893 Rule NumberLiteral() {
895 return Sequence(
896 Number(),
897 push(LuaNumber.of((Double)pop()))
898 );
899 }
900
901 Rule Number() {
902 return FirstOf( 894 return FirstOf(
903 Sequence( 895 Sequence(
904 IgnoreCase("0x"), 896 IgnoreCase("0x"),
905 HexNumber() 897 HexNumber()
906 ), 898 ),
907 Sequence( 899 Sequence(
908 DecNumber(), 900 DecNumber(),
909 push(Double.parseDouble(match())) 901 push(Double.valueOf(match()))
910 ) 902 )
911 ); 903 );
912 } 904 }
913 905
914 Rule DecNumber() { 906 Rule DecNumber() {