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