/// decl_list ::= identifier | identifier, decl_list
std::unique_ptr<PrototypeAST> parsePrototype() {
auto loc = lexer.getLastLocation();
+
+ if (lexer.getCurToken() != tok_def)
+ return parseError<PrototypeAST>("def", "in prototype");
lexer.consume(tok_def);
+
if (lexer.getCurToken() != tok_identifier)
return parseError<PrototypeAST>("function name", "in prototype");
/// decl_list ::= identifier | identifier, decl_list
std::unique_ptr<PrototypeAST> parsePrototype() {
auto loc = lexer.getLastLocation();
+
+ if (lexer.getCurToken() != tok_def)
+ return parseError<PrototypeAST>("def", "in prototype");
lexer.consume(tok_def);
+
if (lexer.getCurToken() != tok_identifier)
return parseError<PrototypeAST>("function name", "in prototype");
/// decl_list ::= identifier | identifier, decl_list
std::unique_ptr<PrototypeAST> parsePrototype() {
auto loc = lexer.getLastLocation();
+
+ if (lexer.getCurToken() != tok_def)
+ return parseError<PrototypeAST>("def", "in prototype");
lexer.consume(tok_def);
+
if (lexer.getCurToken() != tok_identifier)
return parseError<PrototypeAST>("function name", "in prototype");
/// decl_list ::= identifier | identifier, decl_list
std::unique_ptr<PrototypeAST> parsePrototype() {
auto loc = lexer.getLastLocation();
+
+ if (lexer.getCurToken() != tok_def)
+ return parseError<PrototypeAST>("def", "in prototype");
lexer.consume(tok_def);
+
if (lexer.getCurToken() != tok_identifier)
return parseError<PrototypeAST>("function name", "in prototype");
/// decl_list ::= identifier | identifier, decl_list
std::unique_ptr<PrototypeAST> parsePrototype() {
auto loc = lexer.getLastLocation();
+
+ if (lexer.getCurToken() != tok_def)
+ return parseError<PrototypeAST>("def", "in prototype");
lexer.consume(tok_def);
+
if (lexer.getCurToken() != tok_identifier)
return parseError<PrototypeAST>("function name", "in prototype");
/// decl_list ::= identifier | identifier, decl_list
std::unique_ptr<PrototypeAST> parsePrototype() {
auto loc = lexer.getLastLocation();
+
+ if (lexer.getCurToken() != tok_def)
+ return parseError<PrototypeAST>("def", "in prototype");
lexer.consume(tok_def);
+
if (lexer.getCurToken() != tok_identifier)
return parseError<PrototypeAST>("function name", "in prototype");
/// decl_list ::= identifier | identifier, decl_list
std::unique_ptr<PrototypeAST> parsePrototype() {
auto loc = lexer.getLastLocation();
+
+ if (lexer.getCurToken() != tok_def)
+ return parseError<PrototypeAST>("def", "in prototype");
lexer.consume(tok_def);
+
if (lexer.getCurToken() != tok_identifier)
return parseError<PrototypeAST>("function name", "in prototype");
--- /dev/null
+# RUN: toyc-ch1 %s -emit=ast 2>&1 | FileCheck %s
+# CHECK-NOT: Assert
+# CHECK: Parse error
--- /dev/null
+# RUN: toyc-ch2 %s -emit=ast 2>&1 | FileCheck %s
+# CHECK-NOT: Assert
+# CHECK: Parse error
--- /dev/null
+# RUN: toyc-ch3 %s -emit=ast 2>&1 | FileCheck %s
+# CHECK-NOT: Assert
+# CHECK: Parse error
--- /dev/null
+# RUN: toyc-ch4 %s -emit=ast 2>&1 | FileCheck %s
+# CHECK-NOT: Assert
+# CHECK: Parse error
--- /dev/null
+# RUN: toyc-ch5 %s -emit=ast 2>&1 | FileCheck %s
+# CHECK-NOT: Assert
+# CHECK: Parse error
--- /dev/null
+# RUN: toyc-ch6 %s -emit=ast 2>&1 | FileCheck %s
+# CHECK-NOT: Assert
+# CHECK: Parse error
--- /dev/null
+# RUN: toyc-ch7 %s -emit=ast 2>&1 | FileCheck %s
+# CHECK-NOT: Assert
+# CHECK-NOT: Parse error
+# CHECK: Module