Loading CMakeModules/TokenList2DsnLexer.cmake +8 −12 Original line number Diff line number Diff line Loading @@ -144,9 +144,6 @@ set( sourceFileHeader * your DSN lexer. */ //#include \"fctsys.h\" //#include \"macros.h\" #include \"${result}_lexer.h\" namespace DSN { Loading Loading @@ -228,13 +225,13 @@ class ${RESULT}_LEXER : public DSNLEXER public: /** * Constructor ${RESULT}_LEXER * @param aClipboartTxt is std::string (8 bit) text possibly from the * clipboard that you want to parse. * @param aSExpression is (utf8) text possibly from the clipboard that you want to parse. * @param aSource is a description of the origin of @a aSExpression, such as a filename. * If left empty, then _("clipboard") is used. */ ${RESULT}_LEXER( const std::string& aClipboardTxt ) : DSNLEXER( aClipboardTxt, DSN::${result}_keywords, DSN::${result}_keyword_count ) ${RESULT}_LEXER( const std::string& aSExpression, const wxString& aSource = wxEmptyString ) : DSNLEXER( DSN::${result}_keywords, DSN::${result}_keyword_count, aSExpression, aSource ) { } Loading @@ -248,9 +245,8 @@ public: * @param aFilename is the name of the opened file, needed for error reporting. */ ${RESULT}_LEXER( FILE* aFile, const wxString& aFilename ) : DSNLEXER( aFile, aFilename, DSN::${result}_keywords, DSN::${result}_keyword_count ) DSNLEXER( DSN::${result}_keywords, DSN::${result}_keyword_count, aFile, aFilename ) { } Loading common/dsnlexer.cpp +10 −8 Original line number Diff line number Diff line Loading @@ -32,8 +32,8 @@ #include "dsnlexer.h" #include "fctsys.h" #include "pcbnew.h" //#include "fctsys.h" //#include "pcbnew.h" //#define STANDALONE 1 // enable this for stand alone testing. Loading @@ -60,8 +60,8 @@ void DSNLEXER::init() } DSNLEXER::DSNLEXER( FILE* aFile, const wxString& aFilename, const KEYWORD* aKeywordTable, unsigned aKeywordCount ) : DSNLEXER::DSNLEXER( const KEYWORD* aKeywordTable, unsigned aKeywordCount, FILE* aFile, const wxString& aFilename ) : keywords( aKeywordTable ), keywordCount( aKeywordCount ) { Loading @@ -71,12 +71,13 @@ DSNLEXER::DSNLEXER( FILE* aFile, const wxString& aFilename, } DSNLEXER::DSNLEXER( const std::string& aClipboardTxt, const KEYWORD* aKeywordTable, unsigned aKeywordCount ) : DSNLEXER::DSNLEXER( const KEYWORD* aKeywordTable, unsigned aKeywordCount, const std::string& aClipboardTxt, const wxString& aSource ) : keywords( aKeywordTable ), keywordCount( aKeywordCount ) { STRING_LINE_READER* stringReader = new STRING_LINE_READER( aClipboardTxt, _( "clipboard" ) ); STRING_LINE_READER* stringReader = new STRING_LINE_READER( aClipboardTxt, aSource.IsEmpty() ? wxString( _( "clipboard" ) ) : aSource ); PushReader( stringReader ); init(); } Loading Loading @@ -206,7 +207,7 @@ wxString DSNLEXER::GetTokenString( int aTok ) { wxString ret; ret << wxT("'") << CONV_FROM_UTF8( GetTokenText(aTok) ) << wxT("'"); ret << wxT("'") << wxConvertMB2WX( GetTokenText(aTok) ) << wxT("'"); return ret; } Loading Loading @@ -300,6 +301,7 @@ int DSNLEXER::NeedSYMBOLorNUMBER() throw( IO_ERROR ) return tok; } /** * Function isspace * strips the upper bits of the int to ensure the value passed to ::isspace() is Loading include/dsnlexer.h +9 −7 Original line number Diff line number Diff line Loading @@ -22,8 +22,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #ifndef _DSNLEXER_H #define _DSNLEXER_H #ifndef DSNLEXER_H_ #define DSNLEXER_H_ #include <cstdio> #include <string> Loading Loading @@ -162,12 +162,14 @@ public: * @param aKeywordTable is an array of KEYWORDS holding \a aKeywordCount. This * token table need not contain the lexer separators such as '(' ')', etc. * @param aKeywordTable is the count of tokens in aKeywordTable. * @param aFile is an open file, which will be closed when this is destructed. * @param aFileName is the name of the file */ DSNLEXER( FILE* aFile, const wxString& aFilename, const KEYWORD* aKeywordTable, unsigned aKeywordCount ); DSNLEXER( const KEYWORD* aKeywordTable, unsigned aKeywordCount, FILE* aFile, const wxString& aFileName ); DSNLEXER( const std::string& aClipboardTxt, const KEYWORD* aKeywordTable, unsigned aKeywordCount ); DSNLEXER( const KEYWORD* aKeywordTable, unsigned aKeywordCount, const std::string& aClipboardTxt, const wxString& aSource = wxEmptyString ); ~DSNLEXER() { Loading Loading @@ -418,4 +420,4 @@ public: } }; #endif // _DSNLEXER_H #endif // DSNLEXER_H_ include/richio.h +1 −1 Original line number Diff line number Diff line Loading @@ -196,7 +196,7 @@ public: * The last line does not necessarily need a trailing '\n'. * * @param aSource describes the source of aString for error reporting purposes * can be anything meaninful, such as wxT( "cliboard" ). * can be anything meaninful, such as wxT( "clipboard" ). */ STRING_LINE_READER( const std::string& aString, const wxString& aSource ) : LINE_READER( LINE_READER_LINE_DEFAULT_MAX ), Loading new/CMakeLists.txt +12 −4 Original line number Diff line number Diff line Loading @@ -60,14 +60,22 @@ endif() include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) add_executable( test_dir_lib_source sch_dir_lib_source.cpp ) add_executable( test_dir_lib_source sch_dir_lib_source.cpp ) target_link_libraries( test_dir_lib_source ${wxWidgets_LIBRARIES} ) add_executable( test_lib_table sch_lib_table.cpp sch_lib_table_keywords.cpp ) target_link_libraries( test_lib_table ${wxWidgets_LIBRARIES} ) add_executable( test_sch_lib_table sch_lib_table.cpp sch_lib_table_keywords.cpp sch_lib.cpp ${PROJECT_SOURCE_DIR}/common/richio.cpp ${PROJECT_SOURCE_DIR}/common/dsnlexer.cpp ) target_link_libraries( test_sch_lib_table ${wxWidgets_LIBRARIES} ) add_executable( test_sch_part sch_part.cpp ) target_link_libraries( test_lib_table ${wxWidgets_LIBRARIES} ) target_link_libraries( test_sch_part ${wxWidgets_LIBRARIES} ) make_lexer( Loading Loading
CMakeModules/TokenList2DsnLexer.cmake +8 −12 Original line number Diff line number Diff line Loading @@ -144,9 +144,6 @@ set( sourceFileHeader * your DSN lexer. */ //#include \"fctsys.h\" //#include \"macros.h\" #include \"${result}_lexer.h\" namespace DSN { Loading Loading @@ -228,13 +225,13 @@ class ${RESULT}_LEXER : public DSNLEXER public: /** * Constructor ${RESULT}_LEXER * @param aClipboartTxt is std::string (8 bit) text possibly from the * clipboard that you want to parse. * @param aSExpression is (utf8) text possibly from the clipboard that you want to parse. * @param aSource is a description of the origin of @a aSExpression, such as a filename. * If left empty, then _("clipboard") is used. */ ${RESULT}_LEXER( const std::string& aClipboardTxt ) : DSNLEXER( aClipboardTxt, DSN::${result}_keywords, DSN::${result}_keyword_count ) ${RESULT}_LEXER( const std::string& aSExpression, const wxString& aSource = wxEmptyString ) : DSNLEXER( DSN::${result}_keywords, DSN::${result}_keyword_count, aSExpression, aSource ) { } Loading @@ -248,9 +245,8 @@ public: * @param aFilename is the name of the opened file, needed for error reporting. */ ${RESULT}_LEXER( FILE* aFile, const wxString& aFilename ) : DSNLEXER( aFile, aFilename, DSN::${result}_keywords, DSN::${result}_keyword_count ) DSNLEXER( DSN::${result}_keywords, DSN::${result}_keyword_count, aFile, aFilename ) { } Loading
common/dsnlexer.cpp +10 −8 Original line number Diff line number Diff line Loading @@ -32,8 +32,8 @@ #include "dsnlexer.h" #include "fctsys.h" #include "pcbnew.h" //#include "fctsys.h" //#include "pcbnew.h" //#define STANDALONE 1 // enable this for stand alone testing. Loading @@ -60,8 +60,8 @@ void DSNLEXER::init() } DSNLEXER::DSNLEXER( FILE* aFile, const wxString& aFilename, const KEYWORD* aKeywordTable, unsigned aKeywordCount ) : DSNLEXER::DSNLEXER( const KEYWORD* aKeywordTable, unsigned aKeywordCount, FILE* aFile, const wxString& aFilename ) : keywords( aKeywordTable ), keywordCount( aKeywordCount ) { Loading @@ -71,12 +71,13 @@ DSNLEXER::DSNLEXER( FILE* aFile, const wxString& aFilename, } DSNLEXER::DSNLEXER( const std::string& aClipboardTxt, const KEYWORD* aKeywordTable, unsigned aKeywordCount ) : DSNLEXER::DSNLEXER( const KEYWORD* aKeywordTable, unsigned aKeywordCount, const std::string& aClipboardTxt, const wxString& aSource ) : keywords( aKeywordTable ), keywordCount( aKeywordCount ) { STRING_LINE_READER* stringReader = new STRING_LINE_READER( aClipboardTxt, _( "clipboard" ) ); STRING_LINE_READER* stringReader = new STRING_LINE_READER( aClipboardTxt, aSource.IsEmpty() ? wxString( _( "clipboard" ) ) : aSource ); PushReader( stringReader ); init(); } Loading Loading @@ -206,7 +207,7 @@ wxString DSNLEXER::GetTokenString( int aTok ) { wxString ret; ret << wxT("'") << CONV_FROM_UTF8( GetTokenText(aTok) ) << wxT("'"); ret << wxT("'") << wxConvertMB2WX( GetTokenText(aTok) ) << wxT("'"); return ret; } Loading Loading @@ -300,6 +301,7 @@ int DSNLEXER::NeedSYMBOLorNUMBER() throw( IO_ERROR ) return tok; } /** * Function isspace * strips the upper bits of the int to ensure the value passed to ::isspace() is Loading
include/dsnlexer.h +9 −7 Original line number Diff line number Diff line Loading @@ -22,8 +22,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #ifndef _DSNLEXER_H #define _DSNLEXER_H #ifndef DSNLEXER_H_ #define DSNLEXER_H_ #include <cstdio> #include <string> Loading Loading @@ -162,12 +162,14 @@ public: * @param aKeywordTable is an array of KEYWORDS holding \a aKeywordCount. This * token table need not contain the lexer separators such as '(' ')', etc. * @param aKeywordTable is the count of tokens in aKeywordTable. * @param aFile is an open file, which will be closed when this is destructed. * @param aFileName is the name of the file */ DSNLEXER( FILE* aFile, const wxString& aFilename, const KEYWORD* aKeywordTable, unsigned aKeywordCount ); DSNLEXER( const KEYWORD* aKeywordTable, unsigned aKeywordCount, FILE* aFile, const wxString& aFileName ); DSNLEXER( const std::string& aClipboardTxt, const KEYWORD* aKeywordTable, unsigned aKeywordCount ); DSNLEXER( const KEYWORD* aKeywordTable, unsigned aKeywordCount, const std::string& aClipboardTxt, const wxString& aSource = wxEmptyString ); ~DSNLEXER() { Loading Loading @@ -418,4 +420,4 @@ public: } }; #endif // _DSNLEXER_H #endif // DSNLEXER_H_
include/richio.h +1 −1 Original line number Diff line number Diff line Loading @@ -196,7 +196,7 @@ public: * The last line does not necessarily need a trailing '\n'. * * @param aSource describes the source of aString for error reporting purposes * can be anything meaninful, such as wxT( "cliboard" ). * can be anything meaninful, such as wxT( "clipboard" ). */ STRING_LINE_READER( const std::string& aString, const wxString& aSource ) : LINE_READER( LINE_READER_LINE_DEFAULT_MAX ), Loading
new/CMakeLists.txt +12 −4 Original line number Diff line number Diff line Loading @@ -60,14 +60,22 @@ endif() include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) add_executable( test_dir_lib_source sch_dir_lib_source.cpp ) add_executable( test_dir_lib_source sch_dir_lib_source.cpp ) target_link_libraries( test_dir_lib_source ${wxWidgets_LIBRARIES} ) add_executable( test_lib_table sch_lib_table.cpp sch_lib_table_keywords.cpp ) target_link_libraries( test_lib_table ${wxWidgets_LIBRARIES} ) add_executable( test_sch_lib_table sch_lib_table.cpp sch_lib_table_keywords.cpp sch_lib.cpp ${PROJECT_SOURCE_DIR}/common/richio.cpp ${PROJECT_SOURCE_DIR}/common/dsnlexer.cpp ) target_link_libraries( test_sch_lib_table ${wxWidgets_LIBRARIES} ) add_executable( test_sch_part sch_part.cpp ) target_link_libraries( test_lib_table ${wxWidgets_LIBRARIES} ) target_link_libraries( test_sch_part ${wxWidgets_LIBRARIES} ) make_lexer( Loading