Browse Source

Report lexer issues through error reporter.

6.0.7
Jeff Young 5 years ago
parent
commit
834c7bbe05
  1. 3
      common/dsnlexer.cpp
  2. 2
      common/exceptions.cpp
  3. 11
      include/ki_exception.h
  4. 22
      pcbnew/dialogs/panel_setup_rules.cpp

3
common/dsnlexer.cpp

@ -671,7 +671,8 @@ L_read:
// L_unterminated:
wxString errtxt( _( "Un-terminated delimited string" ) );
THROW_PARSE_ERROR( errtxt, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
THROW_PARSE_ERROR( errtxt, CurSource(), CurLine(), CurLineNumber(),
cur - start + curText.length() );
}
}

2
common/exceptions.cpp

@ -70,6 +70,8 @@ void PARSE_ERROR::init( const wxString& aProblem, const char* aThrowersFile,
const wxString& aSource, const char* aInputLine, int aLineNumber,
int aByteIndex )
{
parseProblem = aProblem;
problem.Printf( _( "%s in \"%s\", line %d, offset %d" ),
aProblem,
aSource,

11
include/ki_exception.h

@ -154,8 +154,17 @@ struct PARSE_ERROR : public IO_ERROR
~PARSE_ERROR() throw () {}
const wxString ParseProblem() { return parseProblem; }
protected:
PARSE_ERROR() :
IO_ERROR(),
lineNumber( 0 ),
byteIndex( 0 )
{}
protected:
PARSE_ERROR(): IO_ERROR(), lineNumber( 0 ), byteIndex( 0 ) {}
wxString parseProblem;
};

22
pcbnew/dialogs/panel_setup_rules.cpp

@ -336,7 +336,13 @@ void PANEL_SETUP_RULES::OnCompile( wxCommandEvent& event )
}
catch( PARSE_ERROR& pe )
{
m_Parent->SetError( pe.What(), this, m_textEditor, pe.lineNumber, pe.byteIndex );
wxString msg = wxString::Format( _( "ERROR: <a href='%d:%d'>%s</a>%s" ),
pe.lineNumber,
pe.byteIndex,
pe.ParseProblem(),
wxEmptyString );
m_errorsReport->Report( msg, RPT_SEVERITY_ERROR );
}
m_errorsReport->Flush();
@ -404,20 +410,6 @@ bool PANEL_SETUP_RULES::TransferDataFromWindow()
if( m_frame->Prj().IsNullProject() )
return true;
try
{
std::vector<DRC_RULE*> dummyRules;
DRC_RULES_PARSER parser( m_textEditor->GetText(), _( "DRC rules" ) );
parser.Parse( dummyRules, m_errorsReport );
}
catch( PARSE_ERROR& pe )
{
m_Parent->SetError( pe.What(), this, m_textEditor, pe.lineNumber, pe.byteIndex );
return false;
}
wxString rulesFilepath = m_frame->GetDesignRulesPath();
try

Loading…
Cancel
Save