2011-01-19 20:46:07 +00:00
|
|
|
|
2010-04-06 14:09:52 +00:00
|
|
|
# This program source code file is part of KICAD, a free EDA CAD application.
|
|
|
|
#
|
|
|
|
# Copyright (C) 2010 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
# Copyright (C) 2010 Kicad Developers, see AUTHORS.txt for contributors.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, you may find one here:
|
|
|
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
# or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
# or you may write to the Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# This script converts a plain text file with a line feed separated list
|
|
|
|
# of token names into the appropriate source and header files required by
|
|
|
|
# the DSN lexer. See files "<base_source_path>/common/dsnlexer.cpp" and
|
|
|
|
# "<base_source_path>/include/dsnlexer.h" for more information about how
|
|
|
|
# the DSN lexer works. The token list file format requires a single token
|
|
|
|
# per line. Tokens can only contain lower case letters, numbers, and
|
|
|
|
# underscores. The first letter of each token must be a lower case letter.
|
|
|
|
# Tokens must be unique. If any of the above criteria are not met, the
|
|
|
|
# source and header files will not be generated and a build error will
|
|
|
|
# occur.
|
|
|
|
#
|
|
|
|
# Valid tokens: a a1 foo_1 foo_bar2
|
|
|
|
# Invalid tokens: 1 A _foo bar_ foO
|
|
|
|
#
|
2010-08-09 16:56:00 +00:00
|
|
|
# Invocation Parameters are: enum, inputFile, outCppFile, outHeaderFile
|
2010-04-06 14:09:52 +00:00
|
|
|
#
|
2011-01-17 17:26:19 +00:00
|
|
|
# enum - Required, namespace in which the enum T will be placed.
|
|
|
|
# Keep it short because from outside the class you want a short enum name
|
|
|
|
# like enum::T. Enums are contained in their own namespace to avoid
|
|
|
|
# collisions on enum value names, a problem with C++ unless the enum
|
|
|
|
# itself is in a separate namespace.
|
2010-04-06 14:09:52 +00:00
|
|
|
#
|
2010-08-09 16:56:00 +00:00
|
|
|
# inputFile - Required, name of the token list file, or "*.keywords" file.
|
|
|
|
# Choose the basefilename carefully, it decides the class name
|
|
|
|
# used in the generated *_lexer.h file.
|
2010-04-06 14:09:52 +00:00
|
|
|
#
|
2010-08-09 16:56:00 +00:00
|
|
|
# outCppFile - Optional, full path and file name of where to save the generated
|
|
|
|
# cpp keywords file. If not defined, the output path is the same
|
|
|
|
# path as the token list file path, with a file name of *_keywords.cpp
|
|
|
|
#
|
|
|
|
# outHeaderFile - Optional, full path and file name of where to save the generated
|
|
|
|
# *.h lexfer file. If not defined, the output path is the same
|
|
|
|
# path as the token list file path, with a file name of *_lexer.h
|
|
|
|
#
|
2011-01-17 17:26:19 +00:00
|
|
|
# Use the max_lexer() CMake function from functions.cmake for invocation convenience.
|
|
|
|
|
2010-08-09 16:56:00 +00:00
|
|
|
|
|
|
|
#message( STATUS "TokenList2DsnLexer.cmake" ) # indicate we are running
|
2010-04-06 14:09:52 +00:00
|
|
|
|
|
|
|
set( tokens "" )
|
|
|
|
set( lineCount 0 )
|
2010-08-09 16:56:00 +00:00
|
|
|
set( dsnErrorMsg "TokenList2DsnLexer.cmake failure:" )
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2010-04-06 14:09:52 +00:00
|
|
|
if( NOT EXISTS ${inputFile} )
|
|
|
|
message( FATAL_ERROR "${dsnErrorMsg} file ${inputFile} cannot be found." )
|
2010-08-09 16:56:00 +00:00
|
|
|
endif()
|
2010-04-06 14:09:52 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
if( NOT DEFINED enum )
|
2010-08-09 16:56:00 +00:00
|
|
|
message( FATAL_ERROR "${dsnErrorMsg} missing \"enum\" processing ${inputFile}." )
|
2010-06-17 16:30:10 +00:00
|
|
|
endif()
|
|
|
|
|
2010-08-09 16:56:00 +00:00
|
|
|
get_filename_component( outputPath "${inputFile}" PATH )
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2010-08-09 16:56:00 +00:00
|
|
|
# the keywords filename without extension is important, it sets the classname into RESULT
|
2010-04-06 14:09:52 +00:00
|
|
|
get_filename_component( result "${inputFile}" NAME_WE )
|
2010-08-09 16:56:00 +00:00
|
|
|
string( TOUPPER "${result}" RESULT )
|
|
|
|
|
2011-01-17 17:26:19 +00:00
|
|
|
set( LEXERCLASS "${RESULT}_LEXER" )
|
|
|
|
set( PARSERCLASS "${RESULT}_PARSER" )
|
|
|
|
|
2010-08-09 16:56:00 +00:00
|
|
|
#message( "enum:'${enum}' result:'${result}' outputPath:'${outputPath}' inputFile:'${inputFile}'" )
|
2010-04-06 14:09:52 +00:00
|
|
|
|
2010-08-09 16:56:00 +00:00
|
|
|
if( NOT DEFINED outCppFile )
|
|
|
|
set( outCppFile "${outputPath}/${result}_keywords.cpp" )
|
|
|
|
endif()
|
2010-04-06 14:09:52 +00:00
|
|
|
|
2010-08-09 16:56:00 +00:00
|
|
|
if( NOT DEFINED outHeaderFile )
|
|
|
|
set( outHeaderFile "${outputPath}/${result}_lexer.h" )
|
|
|
|
endif()
|
2010-04-06 14:09:52 +00:00
|
|
|
|
|
|
|
# Create tag for generating header file.
|
2011-01-17 17:26:19 +00:00
|
|
|
set( headerTag "${LEXERCLASS}_H_" )
|
2010-04-06 14:09:52 +00:00
|
|
|
|
|
|
|
set( includeFileHeader
|
|
|
|
"
|
2010-08-09 02:03:16 +00:00
|
|
|
/* Do not modify this file it was automatically generated by the
|
|
|
|
* TokenList2DsnLexer CMake script.
|
2010-04-06 14:09:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ${headerTag}
|
|
|
|
#define ${headerTag}
|
|
|
|
|
|
|
|
#include \"dsnlexer.h\"
|
|
|
|
|
2011-01-17 17:26:19 +00:00
|
|
|
/**
|
|
|
|
* C++ does not put enum _values_ in separate namespaces unless the enum itself
|
|
|
|
* is in a separate namespace. All the token enums must be in separate namespaces
|
|
|
|
* otherwise the C++ compiler will eventually complain if it sees more than one
|
|
|
|
* DSNLEXER in the same compilation unit, say by mutliple header file inclusion.
|
|
|
|
* Plus this also enables re-use of the same enum name T. A typedef can always be used
|
|
|
|
* to clarify which enum T is in play should that ever be a problem. This is
|
|
|
|
* unlikely since Parse() functions will usually only be exposed to one header
|
|
|
|
* file like this one. But if there is a problem, then use:
|
|
|
|
* typedef ${enum}::T T;
|
|
|
|
* within that problem area.
|
|
|
|
*/
|
|
|
|
namespace ${enum}
|
|
|
|
{
|
|
|
|
/// enum T contains all this lexer's tokens.
|
|
|
|
enum T
|
|
|
|
{
|
|
|
|
// these first few are negative special ones for syntax, and are
|
|
|
|
// inherited from DSNLEXER.
|
|
|
|
T_NONE = DSN_NONE,
|
|
|
|
T_COMMENT = DSN_COMMENT,
|
|
|
|
T_STRING_QUOTE = DSN_STRING_QUOTE,
|
|
|
|
T_QUOTE_DEF = DSN_QUOTE_DEF,
|
|
|
|
T_DASH = DSN_DASH,
|
|
|
|
T_SYMBOL = DSN_SYMBOL,
|
|
|
|
T_NUMBER = DSN_NUMBER,
|
|
|
|
T_RIGHT = DSN_RIGHT, // right bracket: ')'
|
|
|
|
T_LEFT = DSN_LEFT, // left bracket: '('
|
|
|
|
T_STRING = DSN_STRING, // a quoted string, stripped of the quotes
|
|
|
|
T_EOF = DSN_EOF, // special case for end of file
|
2010-04-06 14:09:52 +00:00
|
|
|
|
|
|
|
"
|
|
|
|
)
|
|
|
|
|
2011-01-17 17:26:19 +00:00
|
|
|
|
2010-04-06 14:09:52 +00:00
|
|
|
set( sourceFileHeader
|
|
|
|
"
|
2010-08-09 02:03:16 +00:00
|
|
|
/* Do not modify this file it was automatically generated by the
|
|
|
|
* TokenList2DsnLexer CMake script.
|
2010-04-06 14:09:52 +00:00
|
|
|
*
|
2010-08-09 02:03:16 +00:00
|
|
|
* Include this file in your lexer class to provide the keywords for
|
|
|
|
* your DSN lexer.
|
2010-04-06 14:09:52 +00:00
|
|
|
*/
|
|
|
|
|
2010-08-09 02:03:16 +00:00
|
|
|
#include \"${result}_lexer.h\"
|
2010-04-06 14:09:52 +00:00
|
|
|
|
2011-01-17 17:26:19 +00:00
|
|
|
using namespace ${enum};
|
2010-04-06 14:09:52 +00:00
|
|
|
|
|
|
|
#define TOKDEF(x) { #x, T_##x }
|
|
|
|
|
2011-01-17 17:26:19 +00:00
|
|
|
const KEYWORD ${LEXERCLASS}::keywords[] = {
|
2010-04-06 14:09:52 +00:00
|
|
|
"
|
|
|
|
)
|
|
|
|
|
2011-01-19 20:46:07 +00:00
|
|
|
file( STRINGS ${inputFile} lines NO_HEX_CONVERSION )
|
2010-04-06 14:09:52 +00:00
|
|
|
|
2011-01-19 20:46:07 +00:00
|
|
|
foreach( line ${lines} )
|
2010-04-06 14:09:52 +00:00
|
|
|
math( EXPR lineCount "${lineCount} + 1" )
|
|
|
|
|
2011-01-19 20:46:07 +00:00
|
|
|
# strip any comment from # to end of line
|
|
|
|
string( REGEX REPLACE "#.*$" "" tmpToken "${line}" )
|
|
|
|
string( STRIP "${tmpToken}" token )
|
2010-04-06 14:09:52 +00:00
|
|
|
|
|
|
|
# Ignore empty lines.
|
2011-01-19 20:46:07 +00:00
|
|
|
if( NOT token STREQUAL "" ) # if token is "off" simple if( token) does not work
|
2010-04-06 14:09:52 +00:00
|
|
|
# Make sure token is valid.
|
2011-01-19 20:46:07 +00:00
|
|
|
|
|
|
|
#message( "token=${token}" )
|
|
|
|
|
|
|
|
string( REGEX MATCH "[a-z][_0-9a-z]*" validToken "${token}" )
|
|
|
|
#message( "validToken=${validToken}" )
|
|
|
|
|
|
|
|
if( validToken STREQUAL token )
|
2010-04-06 14:09:52 +00:00
|
|
|
list( APPEND tokens "${validToken}" )
|
2011-01-19 20:46:07 +00:00
|
|
|
else()
|
2010-04-06 14:09:52 +00:00
|
|
|
message( FATAL_ERROR
|
|
|
|
"Invalid token string \"${tmpToken}\" at line ${lineCount} in file "
|
|
|
|
"<${inputFile}>." )
|
2011-01-19 20:46:07 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2010-04-06 14:09:52 +00:00
|
|
|
|
|
|
|
list( SORT tokens )
|
|
|
|
|
|
|
|
# Check for duplicates.
|
|
|
|
list( LENGTH tokens tokensBefore )
|
|
|
|
list( REMOVE_DUPLICATES tokens )
|
|
|
|
list( LENGTH tokens tokensAfter )
|
|
|
|
|
|
|
|
if( NOT ( tokensBefore EQUAL tokensAfter ) )
|
|
|
|
message( FATAL_ERROR "Duplicate tokens found in file <${inputFile}>." )
|
2011-01-19 20:46:07 +00:00
|
|
|
endif()
|
2010-04-06 14:09:52 +00:00
|
|
|
|
2010-08-09 16:56:00 +00:00
|
|
|
file( WRITE "${outHeaderFile}" "${includeFileHeader}" )
|
|
|
|
file( WRITE "${outCppFile}" "${sourceFileHeader}" )
|
2010-04-06 14:09:52 +00:00
|
|
|
|
|
|
|
set( lineCount 1 )
|
|
|
|
|
|
|
|
foreach( token ${tokens} )
|
|
|
|
if( lineCount EQUAL 1 )
|
2011-01-17 17:26:19 +00:00
|
|
|
file( APPEND "${outHeaderFile}" " T_${token} = 0" )
|
2010-04-06 14:09:52 +00:00
|
|
|
else( lineCount EQUAL 1 )
|
2011-01-17 17:26:19 +00:00
|
|
|
file( APPEND "${outHeaderFile}" " T_${token}" )
|
2010-04-06 14:09:52 +00:00
|
|
|
endif( lineCount EQUAL 1 )
|
|
|
|
|
2010-08-09 16:56:00 +00:00
|
|
|
file(APPEND "${outCppFile}" " TOKDEF( ${token} )" )
|
2010-04-06 14:09:52 +00:00
|
|
|
|
|
|
|
if( lineCount EQUAL tokensAfter )
|
2010-08-09 16:56:00 +00:00
|
|
|
file( APPEND "${outHeaderFile}" "\n" )
|
|
|
|
file( APPEND "${outCppFile}" "\n" )
|
2010-04-06 14:09:52 +00:00
|
|
|
else( lineCount EQUAL tokensAfter )
|
2010-08-09 16:56:00 +00:00
|
|
|
file( APPEND "${outHeaderFile}" ",\n" )
|
|
|
|
file( APPEND "${outCppFile}" ",\n" )
|
2010-04-06 14:09:52 +00:00
|
|
|
endif( lineCount EQUAL tokensAfter )
|
|
|
|
math( EXPR lineCount "${lineCount} + 1" )
|
2011-01-19 20:46:07 +00:00
|
|
|
endforeach()
|
2010-04-06 14:09:52 +00:00
|
|
|
|
2010-08-09 16:56:00 +00:00
|
|
|
file( APPEND "${outHeaderFile}"
|
2011-01-17 17:26:19 +00:00
|
|
|
" };
|
|
|
|
} // namespace ${enum}
|
2010-08-09 02:03:16 +00:00
|
|
|
|
2010-12-28 21:06:08 +00:00
|
|
|
|
|
|
|
/**
|
2011-01-17 17:26:19 +00:00
|
|
|
* Class ${LEXERCLASS}
|
2010-12-28 21:06:08 +00:00
|
|
|
* is an automatically generated class using the TokenList2DnsLexer.cmake
|
|
|
|
* technology, based on keywords provided by file:
|
|
|
|
* ${inputFile}
|
|
|
|
*/
|
2011-01-17 17:26:19 +00:00
|
|
|
class ${LEXERCLASS} : public DSNLEXER
|
2010-08-09 02:03:16 +00:00
|
|
|
{
|
2011-01-17 17:26:19 +00:00
|
|
|
/// Auto generated lexer keywords table and length:
|
|
|
|
static const KEYWORD keywords[];
|
|
|
|
static const unsigned keyword_count;
|
2010-12-28 16:45:05 +00:00
|
|
|
|
2011-01-17 17:26:19 +00:00
|
|
|
public:
|
2010-08-09 02:03:16 +00:00
|
|
|
/**
|
2010-12-28 16:45:05 +00:00
|
|
|
* Constructor ( const std::string&, const wxString& )
|
2010-12-27 21:22:12 +00:00
|
|
|
* @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.
|
2010-08-09 02:03:16 +00:00
|
|
|
*/
|
2011-01-17 17:26:19 +00:00
|
|
|
${LEXERCLASS}( const std::string& aSExpression, const wxString& aSource = wxEmptyString ) :
|
|
|
|
DSNLEXER( keywords, keyword_count, aSExpression, aSource )
|
2010-08-09 02:03:16 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-12-28 16:45:05 +00:00
|
|
|
* Constructor ( FILE* )
|
2010-08-09 02:03:16 +00:00
|
|
|
* takes @a aFile already opened for reading and @a aFilename as parameters.
|
2010-12-27 16:49:39 +00:00
|
|
|
* The opened file is assumed to be positioned at the beginning of the file
|
|
|
|
* for purposes of accurate line number reporting in error messages. The
|
|
|
|
* FILE is closed by this instance when its destructor is called.
|
2010-08-09 02:03:16 +00:00
|
|
|
* @param aFile is a FILE already opened for reading.
|
|
|
|
* @param aFilename is the name of the opened file, needed for error reporting.
|
|
|
|
*/
|
2011-01-17 17:26:19 +00:00
|
|
|
${LEXERCLASS}( FILE* aFile, const wxString& aFilename ) :
|
|
|
|
DSNLEXER( keywords, keyword_count, aFile, aFilename )
|
2010-08-09 02:03:16 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-28 16:45:05 +00:00
|
|
|
/**
|
|
|
|
* Constructor ( LINE_READER* )
|
|
|
|
* intializes a lexer and prepares to read from @a aLineReader which
|
|
|
|
* is assumed ready, and may be in use by other DSNLEXERs also. No ownership
|
|
|
|
* is taken of @a aLineReader. This enables it to be used by other lexers also.
|
|
|
|
* The transition between grammars in such a case, must happen on a text
|
|
|
|
* line boundary, not within the same line of text.
|
|
|
|
*
|
|
|
|
* @param aLineReader is any subclassed instance of LINE_READER, such as
|
|
|
|
* STRING_LINE_READER or FILE_LINE_READER. No ownership is taken of aLineReader.
|
|
|
|
*/
|
2011-01-17 17:26:19 +00:00
|
|
|
${LEXERCLASS}( LINE_READER* aLineReader ) :
|
|
|
|
DSNLEXER( keywords, keyword_count, aLineReader )
|
2010-12-28 16:45:05 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-01-19 20:46:07 +00:00
|
|
|
/**
|
|
|
|
* Function TokenName
|
|
|
|
* returns the name of the token in ASCII form.
|
|
|
|
*/
|
|
|
|
static const char* TokenName( ${enum}::T aTok );
|
|
|
|
|
2010-08-09 02:03:16 +00:00
|
|
|
/**
|
|
|
|
* 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).
|
2011-01-17 17:26:19 +00:00
|
|
|
* @return ${enum}::T - the type of token found next.
|
2010-11-09 21:01:20 +00:00
|
|
|
* @throw IO_ERROR - only if the LINE_READER throws it.
|
2010-08-09 02:03:16 +00:00
|
|
|
*/
|
2011-01-17 17:26:19 +00:00
|
|
|
${enum}::T NextTok() throw( IO_ERROR )
|
2010-08-09 02:03:16 +00:00
|
|
|
{
|
2011-01-17 17:26:19 +00:00
|
|
|
return (${enum}::T) DSNLEXER::NextTok();
|
2010-08-09 02:03:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function NeedSYMBOL
|
|
|
|
* calls NextTok() and then verifies that the token read in
|
|
|
|
* satisfies bool IsSymbol().
|
2010-11-09 21:01:20 +00:00
|
|
|
* If not, an IO_ERROR is thrown.
|
2010-08-09 02:03:16 +00:00
|
|
|
* @return int - the actual token read in.
|
2010-11-09 21:01:20 +00:00
|
|
|
* @throw IO_ERROR, if the next token does not satisfy IsSymbol()
|
2010-08-09 02:03:16 +00:00
|
|
|
*/
|
2011-01-17 17:26:19 +00:00
|
|
|
${enum}::T NeedSYMBOL() throw( IO_ERROR )
|
2010-08-09 02:03:16 +00:00
|
|
|
{
|
2011-01-17 17:26:19 +00:00
|
|
|
return (${enum}::T) DSNLEXER::NeedSYMBOL();
|
2010-08-09 02:03:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function NeedSYMBOLorNUMBER
|
|
|
|
* calls NextTok() and then verifies that the token read in
|
|
|
|
* satisfies bool IsSymbol() or tok==T_NUMBER.
|
2010-11-09 21:01:20 +00:00
|
|
|
* If not, an IO_ERROR is thrown.
|
2010-08-09 02:03:16 +00:00
|
|
|
* @return int - the actual token read in.
|
2010-11-09 21:01:20 +00:00
|
|
|
* @throw IO_ERROR, if the next token does not satisfy the above test
|
2010-08-09 02:03:16 +00:00
|
|
|
*/
|
2011-01-17 17:26:19 +00:00
|
|
|
${enum}::T NeedSYMBOLorNUMBER() throw( IO_ERROR )
|
2010-08-09 02:03:16 +00:00
|
|
|
{
|
2011-01-17 17:26:19 +00:00
|
|
|
return (${enum}::T) DSNLEXER::NeedSYMBOLorNUMBER();
|
2010-08-09 02:03:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function CurTok
|
|
|
|
* returns whatever NextTok() returned the last time it was called.
|
|
|
|
*/
|
2011-01-17 17:26:19 +00:00
|
|
|
${enum}::T CurTok()
|
2010-08-09 02:03:16 +00:00
|
|
|
{
|
2011-01-17 17:26:19 +00:00
|
|
|
return (${enum}::T) DSNLEXER::CurTok();
|
2010-08-09 02:03:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function PrevTok
|
|
|
|
* returns whatever NextTok() returned the 2nd to last time it was called.
|
|
|
|
*/
|
2011-01-17 17:26:19 +00:00
|
|
|
${enum}::T PrevTok()
|
2010-08-09 02:03:16 +00:00
|
|
|
{
|
2011-01-17 17:26:19 +00:00
|
|
|
return (${enum}::T) DSNLEXER::PrevTok();
|
2010-08-09 02:03:16 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// example usage
|
|
|
|
|
|
|
|
/**
|
2011-01-17 17:26:19 +00:00
|
|
|
* Class ${LEXCLASS}_PARSER
|
2010-08-09 02:03:16 +00:00
|
|
|
* holds data and functions pertinent to parsing a S-expression file .
|
|
|
|
*
|
2011-01-17 17:26:19 +00:00
|
|
|
class ${PARSERCLASS} : public ${LEXERCLASS}
|
2010-08-09 02:03:16 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
};
|
2011-01-17 17:26:19 +00:00
|
|
|
*/
|
2010-04-06 14:09:52 +00:00
|
|
|
|
2010-08-09 02:03:16 +00:00
|
|
|
#endif // ${headerTag}
|
2010-04-06 14:09:52 +00:00
|
|
|
"
|
|
|
|
)
|
|
|
|
|
2010-08-09 16:56:00 +00:00
|
|
|
file( APPEND "${outCppFile}"
|
2010-04-06 14:09:52 +00:00
|
|
|
"};
|
|
|
|
|
2011-01-17 17:26:19 +00:00
|
|
|
const unsigned ${LEXERCLASS}::keyword_count = unsigned( sizeof( ${LEXERCLASS}::keywords )/sizeof( ${LEXERCLASS}::keywords[0] ) );
|
2010-04-06 14:09:52 +00:00
|
|
|
|
2011-01-19 20:46:07 +00:00
|
|
|
|
|
|
|
const char* ${LEXERCLASS}::TokenName( T aTok )
|
|
|
|
{
|
|
|
|
const char* ret;
|
|
|
|
|
|
|
|
if( (unsigned) aTok < keyword_count )
|
|
|
|
{
|
|
|
|
ret = keywords[aTok].name;
|
|
|
|
}
|
|
|
|
else if( aTok < 0 )
|
|
|
|
{
|
2011-01-21 07:21:19 +00:00
|
|
|
ret = DSNLEXER::Syntax( aTok );
|
2011-01-19 20:46:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ret = \"token too big\";
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2010-04-06 14:09:52 +00:00
|
|
|
"
|
|
|
|
)
|