Commit 63b60006 authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

++CMakeModules:

    Revise TokenList2DsnLexer.cmake to make an entire derived lexer class that
    returns the proper enum type for superior debugging.
++eeschema
  * netform.cpp now outputs the allowed footprint filters for a given library
    component.
  * There is an auto-generated class called NETLIST_LEXER which is defined in
    from netlist.keywords by TokenList2DsnLexer.cmake into netlist_lexer.h, that
    may be the basis of loading a S-expression form of the generic netlist format
    which is written from netform.cpp.
parents ac2fd246 fb0bb79a
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -4,6 +4,20 @@ KiCad ChangeLog 2010
Please add newer entries at the top, list the date and your name with
email address.

2010-Aug-8 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++CMakeModules:
    Revise TokenList2DsnLexer.cmake to make an entire derived lexer class that
    returns the proper enum type for superior debugging.
++eeschema
  * netform.cpp now outputs the allowed footprint filters for a given library
    component.
  * There is an auto-generated class called NETLIST_LEXER which is defined in
    from netlist.keywords by TokenList2DsnLexer.cmake into netlist_lexer.h, that
    may be the basis of loading a S-expression form of the generic netlist format
    which is written from netform.cpp.


2010-Aug-7 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++common
+115 −15
Original line number Diff line number Diff line
@@ -82,18 +82,17 @@ get_filename_component( result "${inputFile}" NAME_WE )
message( STATUS "Extracted file name ${result} from path ${inputFile}" )

# Create include and source file name from the list file name.
set( includeFileName "${outputPath}/${result}_keywords.h" )
set( includeFileName "${outputPath}/${result}_lexer.h" )
set( sourceFileName "${outputPath}/${result}_keywords.cpp" )

# Create tag for generating header file.
string( TOUPPER "${result}" fileNameTag )
set( headerTag "_${fileNameTag}_H_" )
string( TOUPPER "${result}" RESULT )
set( headerTag "_${RESULT}_H_" )

set( includeFileHeader
"
/*
 * Do not modify this file it was automatically generated by the TokenList2DsnLexer CMake
 * script.
/* Do not modify this file it was automatically generated by the
 * TokenList2DsnLexer CMake script.
 */

#ifndef ${headerTag}
@@ -124,18 +123,17 @@ enum ${enum} {

set( sourceFileHeader
"
/*
 * Do not modify this file it was automatically generated by the TokenList2DsnLexer CMake
 * script.
/* Do not modify this file it was automatically generated by the
 * TokenList2DsnLexer CMake script.
 *
 * Include this file in your lexer class to provide the keywords for you DSN lexer.
 * Include this file in your lexer class to provide the keywords for
 * your DSN lexer.
 */

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

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

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

namespace DSN {

@@ -209,18 +207,120 @@ extern const unsigned ${result}_keyword_count;

}   // End namespace DSN

using namespace DSN;    // enum ${enum} is in this namespace

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.
     */
    ${RESULT}_LEXER( const std::string& aClipboardTxt ) :
        DSNLEXER( aClipboardTxt,
                  DSN::${result}_keywords,
                  DSN::${result}_keyword_count )
    {
    }

    /**
     * Constructor ${RESULT}_LEXER
     * takes @a aFile already opened for reading and @a aFilename as parameters.
     * The opened file is not closed by this class, and is assumed to be positioned
     * at the beginning of the file for purposes of accurate line number reporting
     * in error messages.
     * @param aFile is a FILE already opened for reading.
     * @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 )
    {
    }

    /**
     * Function NextTok
     * returns the next token found in the input file or T_EOF when reaching
     * the end of file.  Users should wrap this function to return an enum
     * to aid in grammar debugging while running under a debugger, but leave
     * this lower level function returning an int (so the enum does not collide
     * with another usage).
     * @return ${enum} - the type of token found next.
     * @throw IOError - only if the LINE_READER throws it.
     */
    ${enum} NextTok() throw (IOError)
    {
        return (${enum}) DSNLEXER::NextTok();
    }

    /**
     * Function NeedSYMBOL
     * calls NextTok() and then verifies that the token read in
     * satisfies bool IsSymbol().
     * If not, an IOError is thrown.
     * @return int - the actual token read in.
     * @throw IOError, if the next token does not satisfy IsSymbol()
     */
    ${enum} NeedSYMBOL() throw( IOError )
    {
        return (${enum}) DSNLEXER::NeedSYMBOL();
    }

    /**
     * Function NeedSYMBOLorNUMBER
     * calls NextTok() and then verifies that the token read in
     * satisfies bool IsSymbol() or tok==T_NUMBER.
     * If not, an IOError is thrown.
     * @return int - the actual token read in.
     * @throw IOError, if the next token does not satisfy the above test
     */
    ${enum} NeedSYMBOLorNUMBER() throw( IOError )
    {
        return (${enum}) DSNLEXER::NeedSYMBOLorNUMBER();
    }

    /**
     * Function CurTok
     * returns whatever NextTok() returned the last time it was called.
     */
    ${enum} CurTok()
    {
        return (${enum}) DSNLEXER::CurTok();
    }

    /**
     * Function PrevTok
     * returns whatever NextTok() returned the 2nd to last time it was called.
     */
    ${enum} PrevTok()
    {
        return (${enum}) DSNLEXER::PrevTok();
    }
};

// example usage

/**
 * Class ${RESULT}_PARSER
 * holds data and functions pertinent to parsing a S-expression file .
 *
class ${RESULT}_PARSER : public ${RESULT}_LEXER
{

};
 */

#endif   // End ${headerTag}
#endif   // ${headerTag}
"
)

file( APPEND "${sourceFileName}"
"};


const unsigned ${result}_keyword_count = DIM( ${result}_keywords );


}   // End namespace DSN
"
)
+14 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ set(COMMON_SRCS
    gr_basic.cpp
    hotkeys_basic.cpp
    msgpanel.cpp
    netlist_keywords.cpp
    newstroke_font.cpp
    ../pcbnew/class_drc_item.cpp
    projet_config.cpp
@@ -91,6 +92,19 @@ set(PCB_COMMON_SRCS

add_library(pcbcommon ${PCB_COMMON_SRCS})

# auto-generate netlist_lexer.h and netlist_keywords.cpp
add_custom_command(
    OUTPUT  ${CMAKE_CURRENT_SOURCE_DIR}/netlist_lexer.h
            ${CMAKE_CURRENT_SOURCE_DIR}/netlist_keywords.cpp
    COMMAND ${CMAKE_COMMAND}
        -Denum=NL_T
        -DinputFile=${CMAKE_CURRENT_SOURCE_DIR}/netlist.keywords
        -P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake
    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/netlist.keywords
    COMMENT "creating ${CMAKE_CURRENT_SOURCE_DIR}/netlist_{lexer.h,keywords.cpp}
       from ${CMAKE_CURRENT_SOURCE_DIR}/netlist.keywords"
    )

# The dsntest may not build properly using MS Visual Studio.
if(NOT MSVC)
    # This one gets made only when testing.
+2 −0
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@ export
field
fields
footprint
footprints
fp
lib
libpart
libraries
+3 −3
Original line number Diff line number Diff line
@@ -204,14 +204,14 @@ int OUTPUTFORMATTER::Print( int nestLevel, const char* fmt, ... ) throw( IOError
}


//-----<STRINGFORMATTER>----------------------------------------------------
//-----<STRING_FORMATTER>----------------------------------------------------

void STRINGFORMATTER::write( const char* aOutBuf, int aCount ) throw( IOError )
void STRING_FORMATTER::write( const char* aOutBuf, int aCount ) throw( IOError )
{
    mystring.append( aOutBuf, aCount );
}

void STRINGFORMATTER::StripUseless()
void STRING_FORMATTER::StripUseless()
{
    std::string  copy = mystring;

Loading