Mercurial Hosting > luan
comparison src/luan/impl/LuanParser.java @ 1560:33a53c43e2f7
handle unreachable statement
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 22 Oct 2020 00:33:04 -0600 |
parents | d4407e8de707 |
children | e1a13e707bf3 |
comparison
equal
deleted
inserted
replaced
1559:153ea3b7afaf | 1560:33a53c43e2f7 |
---|---|
1132 Spaces(); | 1132 Spaces(); |
1133 Stmts block = RequiredBlock(); | 1133 Stmts block = RequiredBlock(); |
1134 stmt.addAll( block ); | 1134 stmt.addAll( block ); |
1135 stmt.hasReturn = block.hasReturn; | 1135 stmt.hasReturn = block.hasReturn; |
1136 Expr fnDef = newFnExp(stmt,name); | 1136 Expr fnDef = newFnExp(stmt,name); |
1137 RequiredEnd("end_function"); | 1137 // RequiredEnd("end_function"); |
1138 if( !Keyword("end") && !Keyword("end_function") ) { | |
1139 if( stmt.hasReturn && !parser.endOfInput() ) { | |
1140 throw parser.exception("unreachable statement"); | |
1141 } else { | |
1142 throw parser.exception("'end_function' or 'end' expected"); | |
1143 } | |
1144 } | |
1138 frame = frame.parent; | 1145 frame = frame.parent; |
1139 return parser.success(fnDef); | 1146 return parser.success(fnDef); |
1140 } | 1147 } |
1141 | 1148 |
1142 private Expr VarArgs() throws ParseException { | 1149 private Expr VarArgs() throws ParseException { |