Commit bdbd28a9 authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

complete initial version of LIB_TABLE::Parse()

parent 364132cb
Loading
Loading
Loading
Loading
+8 −12
Original line number Original line Diff line number Diff line
@@ -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 {
@@ -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 )
    {
    {
    }
    }


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


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


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


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