Commit 7ca0b717 authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

SCH_LIB_TABLE::Parse()

parents 7798e51d 5b5db555
Loading
Loading
Loading
Loading
+8 −12
Original line number Diff line number Diff line
@@ -144,9 +144,6 @@ set( sourceFileHeader
 * your DSN lexer.
 */

//#include \"fctsys.h\"
//#include \"macros.h\"

#include \"${result}_lexer.h\"

namespace DSN {
@@ -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 )
    {
    }

@@ -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 )
    {
    }

+10 −8
Original line number Diff line number Diff line
@@ -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.

@@ -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 )
{
@@ -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();
}
@@ -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;
}
@@ -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
+9 −7
Original line number Diff line number Diff line
@@ -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>
@@ -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()
    {
@@ -418,4 +420,4 @@ public:
    }
};

#endif  // _DSNLEXER_H
#endif  // DSNLEXER_H_
+1 −1
Original line number Diff line number Diff line
@@ -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 ),
+12 −4
Original line number Diff line number Diff line
@@ -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