diff --git a/common/libeval_compiler/libeval_compiler.cpp b/common/libeval_compiler/libeval_compiler.cpp index f4f66f3960..35aa1d79d2 100644 --- a/common/libeval_compiler/libeval_compiler.cpp +++ b/common/libeval_compiler/libeval_compiler.cpp @@ -759,8 +759,7 @@ bool COMPILER::generateUCode( UCODE* aCode, CONTEXT* aPreflightContext ) msg.Printf( _( "Unrecognized item '%s'" ), itemName ); reportError( CST_CODEGEN, msg, node->leaf[0]->srcPos - (int) itemName.length() ); } - - if( vref->GetType() == VT_PARSE_ERROR ) + else if( vref->GetType() == VT_PARSE_ERROR ) { msg.Printf( _( "Unrecognized property '%s'" ), propName ); reportError( CST_CODEGEN, msg, node->leaf[1]->srcPos - (int) propName.length() ); diff --git a/pcbnew/drc/drc_rule_parser.cpp b/pcbnew/drc/drc_rule_parser.cpp index bf7a599d36..af718678ab 100644 --- a/pcbnew/drc/drc_rule_parser.cpp +++ b/pcbnew/drc/drc_rule_parser.cpp @@ -37,7 +37,6 @@ using namespace DRCRULE_T; DRC_RULES_PARSER::DRC_RULES_PARSER( BOARD* aBoard, const wxString& aSource, const wxString& aSourceDescr ) : DRC_RULES_LEXER( aSource.ToStdString(), aSourceDescr ), - m_board( aBoard ), m_requiredVersion( 0 ), m_tooRecent( false ), m_reporter( nullptr ) @@ -47,7 +46,6 @@ DRC_RULES_PARSER::DRC_RULES_PARSER( BOARD* aBoard, const wxString& aSource, DRC_RULES_PARSER::DRC_RULES_PARSER( BOARD* aBoard, FILE* aFile, const wxString& aFilename ) : DRC_RULES_LEXER( aFile, aFilename ), - m_board( aBoard ), m_requiredVersion( 0 ), m_tooRecent( false ), m_reporter( nullptr ) @@ -144,6 +142,10 @@ void DRC_RULES_PARSER::Parse( std::vector& aRules, REPORTER* aReporte aRules.push_back( parseDRC_RULE() ); break; + case T_EOF: + reportError( _( "Incomplete statement." ) ); + break; + default: msg.Printf( _( "Unrecognized item '%s'.| Expected %s." ), FromUTF8(), "'rule', 'version'" ); @@ -170,7 +172,7 @@ DRC_RULE* DRC_RULES_PARSER::parseDRC_RULE() rule->m_Name = FromUTF8(); - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT && token != T_EOF; token = NextTok() ) { if( token != T_LEFT ) reportError( _( "Missing '('." ) ); @@ -216,6 +218,10 @@ DRC_RULE* DRC_RULES_PARSER::parseDRC_RULE() rule->m_LayerCondition = parseLayer(); break; + case T_EOF: + reportError( _( "Incomplete statement." ) ); + return rule; + default: msg.Printf( _( "Unrecognized item '%s'.| Expected %s." ), FromUTF8(), @@ -225,6 +231,9 @@ DRC_RULE* DRC_RULES_PARSER::parseDRC_RULE() } } + if( (int) CurTok() != DSN_RIGHT ) + reportError( _( "Missing ')'." ) ); + return rule; } @@ -239,7 +248,7 @@ void DRC_RULES_PARSER::parseConstraint( DRC_RULE* aRule ) T token = NextTok(); - if( (int) token == DSN_RIGHT ) + if( (int) token == DSN_RIGHT || token == T_EOF ) { msg.Printf( _( "Missing constraint type.| Expected %s." ), "'clearance', 'track_width', 'annulus_width', 'hole', 'disallow'" ); @@ -281,6 +290,11 @@ void DRC_RULES_PARSER::parseConstraint( DRC_RULE* aRule ) case T_graphic: constraint.m_DisallowFlags |= DISALLOW_GRAPHICS; break; case T_hole: constraint.m_DisallowFlags |= DISALLOW_HOLES; break; case T_footprint: constraint.m_DisallowFlags |= DISALLOW_FOOTPRINTS; break; + + case T_EOF: + reportError( _( "Missing ')'." ) ); + return; + default: msg.Printf( _( "Unrecognized item '%s'.| Expected %s." ), FromUTF8(), @@ -288,14 +302,17 @@ void DRC_RULES_PARSER::parseConstraint( DRC_RULE* aRule ) "'blind_via', 'pad', 'zone', 'text', 'graphic', 'hole'." ); reportError( msg ); - parseUnknown(); + break; } } + if( (int) CurTok() != DSN_RIGHT ) + reportError( _( "Missing ')'." ) ); + return; } - for( token = NextTok(); token != T_RIGHT; token = NextTok() ) + for( token = NextTok(); token != T_RIGHT && token != T_EOF; token = NextTok() ) { if( token != T_LEFT ) reportError( _( "Missing '('." ) ); @@ -364,6 +381,10 @@ void DRC_RULES_PARSER::parseConstraint( DRC_RULE* aRule ) break; + case T_EOF: + reportError( _( "Incomplete statement." ) ); + return; + default: msg.Printf( _( "Unrecognized item '%s'.| Expected %s." ), FromUTF8(), "'min', 'max', 'opt'" ); @@ -371,6 +392,9 @@ void DRC_RULES_PARSER::parseConstraint( DRC_RULE* aRule ) parseUnknown(); } } + + if( (int) CurTok() != DSN_RIGHT ) + reportError( _( "Missing ')'." ) ); } diff --git a/pcbnew/drc/drc_rule_parser.h b/pcbnew/drc/drc_rule_parser.h index 5e7dac54f7..c4557dffde 100644 --- a/pcbnew/drc/drc_rule_parser.h +++ b/pcbnew/drc/drc_rule_parser.h @@ -56,7 +56,6 @@ private: void reportError( const wxString& aMessage ); private: - BOARD* m_board; int m_requiredVersion; bool m_tooRecent; REPORTER* m_reporter;