Mercurial Hosting > luan
comparison core/src/luan/impl/LuanParser.java @ 326:db37d6aee4db
remove try-catch statement;
add Luan.try() and Luan.pcall();
git-svn-id: https://luan-java.googlecode.com/svn/trunk@327 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Thu, 19 Mar 2015 00:01:57 +0000 |
parents | b24a35612947 |
children | 5e34702423a0 |
comparison
equal
deleted
inserted
replaced
325:78a6a71afbfd | 326:db37d6aee4db |
---|---|
249 if( (stmt=ReturnStmt()) != null | 249 if( (stmt=ReturnStmt()) != null |
250 || (stmt=FunctionStmt()) != null | 250 || (stmt=FunctionStmt()) != null |
251 || (stmt=LocalFunctionStmt()) != null | 251 || (stmt=LocalFunctionStmt()) != null |
252 || (stmt=BreakStmt()) != null | 252 || (stmt=BreakStmt()) != null |
253 || (stmt=ForStmt()) != null | 253 || (stmt=ForStmt()) != null |
254 || (stmt=TryStmt()) != null | |
255 || (stmt=DoStmt()) != null | 254 || (stmt=DoStmt()) != null |
256 || (stmt=WhileStmt()) != null | 255 || (stmt=WhileStmt()) != null |
257 || (stmt=FunctionStmt()) != null | 256 || (stmt=FunctionStmt()) != null |
258 || (stmt=RepeatStmt()) != null | 257 || (stmt=RepeatStmt()) != null |
259 || (stmt=IfStmt()) != null | 258 || (stmt=IfStmt()) != null |
368 addSymbols(names); | 367 addSymbols(names); |
369 Stmt loop = RequiredLoopBlock(); | 368 Stmt loop = RequiredLoopBlock(); |
370 RequiredKeyword("end",In.NOTHING); | 369 RequiredKeyword("end",In.NOTHING); |
371 Stmt stmt = new ForStmt( se(start), stackStart, symbolsSize() - stackStart, expr, loop ); | 370 Stmt stmt = new ForStmt( se(start), stackStart, symbolsSize() - stackStart, expr, loop ); |
372 popSymbols( symbolsSize() - stackStart ); | 371 popSymbols( symbolsSize() - stackStart ); |
373 return parser.success(stmt); | |
374 } | |
375 | |
376 private Stmt TryStmt() throws ParseException { | |
377 parser.begin(); | |
378 if( !Keyword("try",In.NOTHING) ) | |
379 return parser.failure(null); | |
380 Stmt tryBlock = RequiredBlock(); | |
381 RequiredKeyword("catch",In.NOTHING); | |
382 String name = RequiredName(In.NOTHING); | |
383 addSymbol(name); | |
384 RequiredKeyword("do",In.NOTHING); | |
385 Stmt catchBlock = RequiredBlock(); | |
386 RequiredKeyword("end",In.NOTHING); | |
387 Stmt stmt = new TryStmt( tryBlock, symbolsSize()-1, catchBlock ); | |
388 popSymbols(1); | |
389 return parser.success(stmt); | 372 return parser.success(stmt); |
390 } | 373 } |
391 | 374 |
392 private Stmt DoStmt() throws ParseException { | 375 private Stmt DoStmt() throws ParseException { |
393 parser.begin(); | 376 parser.begin(); |
1093 } | 1076 } |
1094 | 1077 |
1095 private static final Set<String> keywords = new HashSet<String>(Arrays.asList( | 1078 private static final Set<String> keywords = new HashSet<String>(Arrays.asList( |
1096 "and", | 1079 "and", |
1097 "break", | 1080 "break", |
1098 "catch", | |
1099 "do", | 1081 "do", |
1100 "else", | 1082 "else", |
1101 "elseif", | 1083 "elseif", |
1102 "end", | 1084 "end", |
1103 "false", | 1085 "false", |
1112 "or", | 1094 "or", |
1113 "repeat", | 1095 "repeat", |
1114 "return", | 1096 "return", |
1115 "then", | 1097 "then", |
1116 "true", | 1098 "true", |
1117 "try", | |
1118 "until", | 1099 "until", |
1119 "while" | 1100 "while" |
1120 )); | 1101 )); |
1121 | 1102 |
1122 private Expr Literal(In in) throws ParseException { | 1103 private Expr Literal(In in) throws ParseException { |