Skip to content

Commit 800b71a

Browse files
LazyLazy
authored andcommitted
fix for and static
1 parent 5e406a0 commit 800b71a

1 file changed

Lines changed: 0 additions & 15 deletions

File tree

frontend/antlr4/Antlr4CSTVisitor.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,6 @@ std::any MiniCCSTVisitor::visitConstDeclNoSemi(MiniCParser::ConstDeclNoSemiConte
309309
{
310310
auto * stmtNode = ast_node::New(ast_operator_type::AST_OP_DECL_STMT);
311311
stmtNode->isConst = true;
312-
if (!extendedGrammar && ctx->T_STATIC() != nullptr) {
313-
throw std::runtime_error("默认文法下不支持static声明;如需使用扩展语法,请指定-e");
314-
}
315312
stmtNode->isStatic = ctx->T_STATIC() != nullptr;
316313

317314
type_attr typeAttr = std::any_cast<type_attr>(visitBasicType(ctx->basicType()));
@@ -420,9 +417,6 @@ std::any MiniCCSTVisitor::visitWhileUnmatchedStatement(MiniCParser::WhileUnmatch
420417

421418
std::any MiniCCSTVisitor::visitForStatement(MiniCParser::ForStatementContext * ctx)
422419
{
423-
if (!extendedGrammar) {
424-
throw std::runtime_error("默认文法下不支持for语句;如需使用扩展语法,请指定-e");
425-
}
426420

427421
ast_node * initNode = nullptr;
428422
if (ctx->forInit()) {
@@ -451,9 +445,6 @@ std::any MiniCCSTVisitor::visitForStatement(MiniCParser::ForStatementContext * c
451445

452446
std::any MiniCCSTVisitor::visitForUnmatchedStatement(MiniCParser::ForUnmatchedStatementContext * ctx)
453447
{
454-
if (!extendedGrammar) {
455-
throw std::runtime_error("默认文法下不支持for语句;如需使用扩展语法,请指定-e");
456-
}
457448

458449
ast_node * initNode = nullptr;
459450
if (ctx->forInit()) {
@@ -800,9 +791,6 @@ std::any MiniCCSTVisitor::visitUnaryExp(MiniCParser::UnaryExpContext * ctx)
800791

801792
return ast_node::New(op, operand);
802793
} else if (auto * lvalCtx = ctx->getRuleContext<MiniCParser::LValContext>(0)) {
803-
if (!extendedGrammar) {
804-
throw std::runtime_error("默认文法下不支持自增自减表达式;如需使用扩展语法,请指定-e");
805-
}
806794
ast_node * operand = std::any_cast<ast_node *>(visitLVal(lvalCtx));
807795
const bool prefix = !ctx->children.empty() && (ctx->children.front()->getText() == "++" ||
808796
ctx->children.front()->getText() == "--");
@@ -887,9 +875,6 @@ std::any MiniCCSTVisitor::visitVarDecl(MiniCParser::VarDeclContext * ctx)
887875
std::any MiniCCSTVisitor::visitVarDeclNoSemi(MiniCParser::VarDeclNoSemiContext * ctx)
888876
{
889877
// varDeclNoSemi: T_STATIC? basicType varDef (T_COMMA varDef)*
890-
if (!extendedGrammar && ctx->T_STATIC() != nullptr) {
891-
throw std::runtime_error("默认文法下不支持static声明;如需使用扩展语法,请指定-e");
892-
}
893878

894879
// 声明语句节点
895880
ast_node * stmt_node = ast_node::New(ast_operator_type::AST_OP_DECL_STMT);

0 commit comments

Comments
 (0)