KiCad PCB EDA Suite
Loading...
Searching...
No Matches
DSNLEXER Class Reference

Implement a lexical analyzer for the SPECCTRA DSN file format. More...

#include <dsnlexer.h>

Public Member Functions

 DSNLEXER (const KEYWORD *aKeywordTable, unsigned aKeywordCount, const KEYWORD_MAP *aKeywordMap, FILE *aFile, const wxString &aFileName)
 Initialize a DSN lexer and prepares to read from aFile which is already open and has aFilename. More...
 
 DSNLEXER (const KEYWORD *aKeywordTable, unsigned aKeywordCount, const KEYWORD_MAP *aKeywordMap, const std::string &aSExpression, const wxString &aSource=wxEmptyString)
 Initialize a DSN lexer and prepares to read from aSExpression. More...
 
 DSNLEXER (const std::string &aSExpression, const wxString &aSource=wxEmptyString)
 Initialize a DSN lexer and prepares to read from aSExpression. More...
 
 DSNLEXER (const KEYWORD *aKeywordTable, unsigned aKeywordCount, const KEYWORD_MAP *aKeywordMap, LINE_READER *aLineReader=nullptr)
 Initialize a DSN lexer and prepares to read from aLineReader which is already open, and may be in use by other DSNLEXERs also. More...
 
virtual ~DSNLEXER ()
 
void InitParserState ()
 Reinit variables used during parsing, to ensure od states are not used in a new parsing must be called before parsing a new file after parsing an old file to avoid starting with some variables in a non initial state. More...
 
bool SyncLineReaderWith (DSNLEXER &aLexer)
 Usable only for DSN lexers which share the same LINE_READER. More...
 
void SetSpecctraMode (bool aMode)
 Change the behavior of this lexer into or out of "specctra mode". More...
 
void PushReader (LINE_READER *aLineReader)
 Manage a stack of LINE_READERs in order to handle nested file inclusion. More...
 
LINE_READERPopReader ()
 Delete the top most LINE_READER from an internal stack of LINE_READERs and in the case of FILE_LINE_READER this means the associated FILE is closed. More...
 
int NextTok ()
 Return the next token found in the input file or DSN_EOF when reaching the end of file. More...
 
int NeedSYMBOL ()
 Call NextTok() and then verifies that the token read in satisfies IsSymbol(). More...
 
int NeedSYMBOLorNUMBER ()
 Call NextTok() and then verifies that the token read in satisfies bool IsSymbol() or the next token is DSN_NUMBER. More...
 
int NeedNUMBER (const char *aExpectation)
 Call NextTok() and then verifies that the token read is type DSN_NUMBER. More...
 
int CurTok () const
 Return whatever NextTok() returned the last time it was called. More...
 
int PrevTok () const
 Return whatever NextTok() returned the 2nd to last time it was called. More...
 
int GetCurStrAsToken () const
 Used to support "loose" matches (quoted tokens). More...
 
char SetStringDelimiter (char aStringDelimiter)
 Change the string delimiter from the default " to some other character and return the old value. More...
 
bool SetSpaceInQuotedTokens (bool val)
 Change the setting controlling whether a space in a quoted string isa terminator. More...
 
bool SetCommentsAreTokens (bool val)
 Change the handling of comments. More...
 
wxArrayString * ReadCommentLines ()
 Check the next sequence of tokens and reads them into a wxArrayString if they are comments. More...
 
void Expecting (int aTok) const
 Throw an IO_ERROR exception with an input file specific error message. More...
 
void Expecting (const char *aTokenList) const
 Throw an IO_ERROR exception with an input file specific error message. More...
 
void Unexpected (int aTok) const
 Throw an IO_ERROR exception with an input file specific error message. More...
 
void Unexpected (const char *aToken) const
 Throw an IO_ERROR exception with an input file specific error message. More...
 
void Duplicate (int aTok)
 Throw an IO_ERROR exception with a message saying specifically that aTok is a duplicate of one already seen in current context. More...
 
void NeedLEFT ()
 Call NextTok() and then verifies that the token read in is a DSN_LEFT. More...
 
void NeedRIGHT ()
 Call NextTok() and then verifies that the token read in is a DSN_RIGHT. More...
 
const char * GetTokenText (int aTok) const
 Return the C string representation of a DSN_T value. More...
 
wxString GetTokenString (int aTok) const
 Return a quote wrapped wxString representation of a token value. More...
 
const char * CurText () const
 Return a pointer to the current token's text. More...
 
const std::string & CurStr () const
 Return a reference to current token in std::string form. More...
 
wxString FromUTF8 () const
 Return the current token text as a wxString, assuming that the input byte stream is UTF8 encoded. More...
 
int CurLineNumber () const
 Return the current line number within my LINE_READER. More...
 
const char * CurLine () const
 Return the current line of text from which the CurText() would return its token. More...
 
const wxString & CurSource () const
 Return the current LINE_READER source. More...
 
int CurOffset () const
 Return the byte offset within the current line, using a 1 based index. More...
 

Static Public Member Functions

static bool IsSymbol (int aTok)
 Test a token to see if it is a symbol. More...
 
static const char * Syntax (int aTok)
 

Protected Types

typedef std::vector< LINE_READER * > READER_STACK
 

Protected Member Functions

void init ()
 
int readLine ()
 
int findToken (const std::string &aToken) const
 Take aToken string and looks up the string in the keywords table. More...
 
bool isStringTerminator (char cc) const
 
double parseDouble ()
 Parse the current token as an ASCII numeric string with possible leading whitespace into a double precision floating point number. More...
 
double parseDouble (const char *aExpected)
 
template<typename T >
double parseDouble (T aToken)
 

Protected Attributes

bool iOwnReaders
 on readerStack, should I delete them? More...
 
const char * start
 
const char * next
 
const char * limit
 
char dummy [1]
 when there is no reader. More...
 
READER_STACK readerStack
 all the LINE_READERs by pointer. More...
 
LINE_READERreader
 
bool specctraMode
 if true, then: 1) stringDelimiter can be changed 2) Kicad quoting protocol is not in effect 3) space_in_quoted_tokens is functional else not. More...
 
char stringDelimiter
 
bool space_in_quoted_tokens
 blank spaces within quoted strings More...
 
bool commentsAreTokens
 true if should return comments as tokens More...
 
int prevTok
 curTok from previous NextTok() call. More...
 
int curOffset
 offset within current line of the current token More...
 
int curTok
 the current token obtained on last NextTok() More...
 
std::string curText
 the text of the current token More...
 
const KEYWORDkeywords
 table sorted by CMake for bsearch() More...
 
unsigned keywordCount
 count of keywords table More...
 
const KEYWORD_MAPkeywordsLookup
 fast, specialized "C string" hashtable More...
 

Detailed Description

Implement a lexical analyzer for the SPECCTRA DSN file format.

It reads lexical tokens from the current LINE_READER through the NextTok() function.

Definition at line 79 of file dsnlexer.h.

Member Typedef Documentation

◆ READER_STACK

typedef std::vector<LINE_READER*> DSNLEXER::READER_STACK
protected

Definition at line 529 of file dsnlexer.h.

Constructor & Destructor Documentation

◆ DSNLEXER() [1/4]

DSNLEXER::DSNLEXER ( const KEYWORD aKeywordTable,
unsigned  aKeywordCount,
const KEYWORD_MAP aKeywordMap,
FILE *  aFile,
const wxString &  aFileName 
)

Initialize a DSN lexer and prepares to read from aFile which is already open and has aFilename.

Parameters
aKeywordTableis an array of KEYWORDS holding aKeywordCount. This token table need not contain the lexer separators such as '(' ')', etc.
aKeywordCountis the count of tokens in aKeywordTable.
aFileis an open file, which will be closed when this is destructed.
aFileNameis the name of the file

Definition at line 54 of file dsnlexer.cpp.

References init(), and PushReader().

◆ DSNLEXER() [2/4]

DSNLEXER::DSNLEXER ( const KEYWORD aKeywordTable,
unsigned  aKeywordCount,
const KEYWORD_MAP aKeywordMap,
const std::string &  aSExpression,
const wxString &  aSource = wxEmptyString 
)

Initialize a DSN lexer and prepares to read from aSExpression.

Parameters
aKeywordTableis an array of KEYWORDS holding aKeywordCount. This token table need not contain the lexer separators such as '(' ')', etc.
aKeywordCountis the count of tokens in aKeywordTable.
aSExpressionis text to feed through a STRING_LINE_READER
aSourceis a description of aSExpression, used for error reporting.

Definition at line 72 of file dsnlexer.cpp.

References FMT_CLIPBOARD, init(), and PushReader().

◆ DSNLEXER() [3/4]

DSNLEXER::DSNLEXER ( const std::string &  aSExpression,
const wxString &  aSource = wxEmptyString 
)

Initialize a DSN lexer and prepares to read from aSExpression.

Use this one without a keyword table with the DOM parser in ptree.h.

Parameters
aSExpressionis text to feed through a STRING_LINE_READER
aSourceis a description of aSExpression, used for error reporting.

Definition at line 111 of file dsnlexer.cpp.

References FMT_CLIPBOARD, init(), and PushReader().

◆ DSNLEXER() [4/4]

DSNLEXER::DSNLEXER ( const KEYWORD aKeywordTable,
unsigned  aKeywordCount,
const KEYWORD_MAP aKeywordMap,
LINE_READER aLineReader = nullptr 
)

Initialize a DSN lexer and prepares to read from aLineReader which is already open, and may be in use by other DSNLEXERs also.

No ownership is taken of aLineReader. This enables it to be used by other DSNLEXERs.

Parameters
aKeywordTableis an array of #KEYWORDS holding aKeywordCount. This token table need not contain the lexer separators such as '(' ')', etc.
aKeywordCountis the count of tokens in aKeywordTable.
aLineReaderis any subclassed instance of LINE_READER, such as STRING_LINE_READER or FILE_LINE_READER. No ownership is taken.

Definition at line 91 of file dsnlexer.cpp.

References init(), and PushReader().

◆ ~DSNLEXER()

DSNLEXER::~DSNLEXER ( )
virtual

Definition at line 128 of file dsnlexer.cpp.

References iOwnReaders, and readerStack.

Member Function Documentation

◆ CurLine()

const char * DSNLEXER::CurLine ( ) const
inline

Return the current line of text from which the CurText() would return its token.

Definition at line 432 of file dsnlexer.h.

Referenced by Duplicate(), Expecting(), NeedNUMBER(), NextTok(), parseDouble(), and Unexpected().

◆ CurLineNumber()

int DSNLEXER::CurLineNumber ( ) const
inline

Return the current line number within my LINE_READER.

Definition at line 424 of file dsnlexer.h.

Referenced by Duplicate(), Expecting(), NeedNUMBER(), NextTok(), parseDouble(), and Unexpected().

◆ CurOffset()

int DSNLEXER::CurOffset ( ) const
inline

Return the byte offset within the current line, using a 1 based index.

Returns
a one based index into the current line.

Definition at line 452 of file dsnlexer.h.

Referenced by Duplicate(), Expecting(), NeedNUMBER(), NextTok(), parseDouble(), and Unexpected().

◆ CurSource()

const wxString & DSNLEXER::CurSource ( ) const
inline

Return the current LINE_READER source.

Returns
source of the lines of text, e.g. a filename or "clipboard".

Definition at line 442 of file dsnlexer.h.

Referenced by Duplicate(), Expecting(), NeedNUMBER(), NextTok(), parseDouble(), and Unexpected().

◆ CurStr()

const std::string & DSNLEXER::CurStr ( ) const
inline

Return a reference to current token in std::string form.

Definition at line 407 of file dsnlexer.h.

Referenced by parseDouble().

◆ CurText()

const char * DSNLEXER::CurText ( ) const
inline

Return a pointer to the current token's text.

Definition at line 399 of file dsnlexer.h.

Referenced by CADSTAR_ARCHIVE_PARSER::LoadArchiveFile(), PCAD2KICAD::LoadInputFile(), parseDouble(), scanAtom(), and scanList().

◆ CurTok()

int DSNLEXER::CurTok ( ) const
inline

Return whatever NextTok() returned the last time it was called.

Definition at line 238 of file dsnlexer.h.

Referenced by Scan(), and scanList().

◆ Duplicate()

void DSNLEXER::Duplicate ( int  aTok)

Throw an IO_ERROR exception with a message saying specifically that aTok is a duplicate of one already seen in current context.

Parameters
aTokis the token/keyword type which was not expected at the current input location.
Exceptions
IO_ERRORwith the location within the input file of the problem.

Definition at line 349 of file dsnlexer.cpp.

References _, CurLine(), CurLineNumber(), CurOffset(), CurSource(), GetTokenString(), and THROW_PARSE_ERROR.

◆ Expecting() [1/2]

void DSNLEXER::Expecting ( const char *  aTokenList) const

Throw an IO_ERROR exception with an input file specific error message.

Parameters
aTokenListis the token/keyword type which was expected at the current input location, e.g. "pin|graphic|property".
Exceptions
IO_ERRORwith the location within the input file of the problem.

Definition at line 333 of file dsnlexer.cpp.

References _, CurLine(), CurLineNumber(), CurOffset(), CurSource(), text, and THROW_PARSE_ERROR.

◆ Expecting() [2/2]

void DSNLEXER::Expecting ( int  aTok) const

Throw an IO_ERROR exception with an input file specific error message.

Parameters
aTokis the token/keyword type which was expected at the current input location.
Exceptions
IO_ERRORwith the location within the input file of the problem.

Definition at line 325 of file dsnlexer.cpp.

References _, CurLine(), CurLineNumber(), CurOffset(), CurSource(), GetTokenString(), and THROW_PARSE_ERROR.

Referenced by NeedLEFT(), NeedRIGHT(), NeedSYMBOL(), and NeedSYMBOLorNUMBER().

◆ findToken()

int DSNLEXER::findToken ( const std::string &  aToken) const
protected

Take aToken string and looks up the string in the keywords table.

Parameters
aTokenis a string to lookup in the keywords table.
Returns
with a value from the enum DSN_T matching the keyword text, or DSN_SYMBOL if aToken is not in the keywords table.

Definition at line 229 of file dsnlexer.cpp.

References DSN_SYMBOL, and keywordsLookup.

Referenced by NextTok().

◆ FromUTF8()

wxString DSNLEXER::FromUTF8 ( ) const
inline

Return the current token text as a wxString, assuming that the input byte stream is UTF8 encoded.

Definition at line 416 of file dsnlexer.h.

Referenced by ReadCommentLines().

◆ GetCurStrAsToken()

int DSNLEXER::GetCurStrAsToken ( ) const
inline

Used to support "loose" matches (quoted tokens).

Definition at line 254 of file dsnlexer.h.

◆ GetTokenString()

wxString DSNLEXER::GetTokenString ( int  aTok) const

Return a quote wrapped wxString representation of a token value.

Definition at line 306 of file dsnlexer.cpp.

References GetTokenText().

Referenced by Duplicate(), Expecting(), and Unexpected().

◆ GetTokenText()

const char * DSNLEXER::GetTokenText ( int  aTok) const

Return the C string representation of a DSN_T value.

Definition at line 287 of file dsnlexer.cpp.

References keywordCount, keywords, KEYWORD::name, and Syntax().

Referenced by GetTokenString().

◆ init()

void DSNLEXER::init ( )
protected

◆ InitParserState()

void DSNLEXER::InitParserState ( )

Reinit variables used during parsing, to ensure od states are not used in a new parsing must be called before parsing a new file after parsing an old file to avoid starting with some variables in a non initial state.

Definition at line 155 of file dsnlexer.cpp.

References commentsAreTokens, curOffset, curTok, DSN_NONE, and prevTok.

◆ isStringTerminator()

bool DSNLEXER::isStringTerminator ( char  cc) const
inlineprotected

Definition at line 491 of file dsnlexer.h.

Referenced by NextTok().

◆ IsSymbol()

bool DSNLEXER::IsSymbol ( int  aTok)
static

Test a token to see if it is a symbol.

This means it cannot be a special delimiter character such as DSN_LEFT, DSN_RIGHT, #DSN_QUOTE, etc. It may however, coincidentally match a keyword and still be a symbol.

Definition at line 316 of file dsnlexer.cpp.

References DSN_STRING, and DSN_SYMBOL.

Referenced by NeedSYMBOL(), and NeedSYMBOLorNUMBER().

◆ NeedLEFT()

void DSNLEXER::NeedLEFT ( )

Call NextTok() and then verifies that the token read in is a DSN_LEFT.

Exceptions
IO_ERRORif the next token is not a DSN_LEFT

Definition at line 365 of file dsnlexer.cpp.

References DSN_LEFT, Expecting(), and NextTok().

◆ NeedNUMBER()

int DSNLEXER::NeedNUMBER ( const char *  aExpectation)

Call NextTok() and then verifies that the token read is type DSN_NUMBER.

Returns
the actual token read in.
Exceptions
IO_ERRORif the next token does not satisfy the above test.

Definition at line 404 of file dsnlexer.cpp.

References _, CurLine(), CurLineNumber(), CurOffset(), CurSource(), DSN_NUMBER, NextTok(), and THROW_PARSE_ERROR.

◆ NeedRIGHT()

void DSNLEXER::NeedRIGHT ( )

Call NextTok() and then verifies that the token read in is a DSN_RIGHT.

Exceptions
IO_ERRORif the next token is not a DSN_RIGHT

Definition at line 373 of file dsnlexer.cpp.

References DSN_RIGHT, Expecting(), and NextTok().

◆ NeedSYMBOL()

int DSNLEXER::NeedSYMBOL ( )

Call NextTok() and then verifies that the token read in satisfies IsSymbol().

Returns
the actual token read in.
Exceptions
IO_ERRORif the next token does not satisfy IsSymbol().

Definition at line 382 of file dsnlexer.cpp.

References DSN_SYMBOL, Expecting(), IsSymbol(), and NextTok().

◆ NeedSYMBOLorNUMBER()

int DSNLEXER::NeedSYMBOLorNUMBER ( )

Call NextTok() and then verifies that the token read in satisfies bool IsSymbol() or the next token is DSN_NUMBER.

Returns
the actual token read in.
Exceptions
IO_ERRORif the next token does not satisfy the above test.

Definition at line 393 of file dsnlexer.cpp.

References DSN_NUMBER, Expecting(), IsSymbol(), and NextTok().

◆ NextTok()

int DSNLEXER::NextTok ( )

Return the next token found in the input file or DSN_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).

Returns
the type of token found next.
Exceptions
IO_ERRORonly if the LINE_READER throws it.

Definition at line 518 of file dsnlexer.cpp.

References _, commentsAreTokens, CurLine(), CurLineNumber(), CurOffset(), curOffset, CurSource(), curText, curTok, DSN_COMMENT, DSN_DASH, DSN_EOF, DSN_LEFT, DSN_NUMBER, DSN_QUOTE_DEF, DSN_RIGHT, DSN_STRING, DSN_STRING_QUOTE, exit, findToken(), isNumber(), isSep(), isSpace(), isStringTerminator(), limit, next, prevTok, readLine(), specctraMode, start, stringDelimiter, and THROW_PARSE_ERROR.

Referenced by CADSTAR_ARCHIVE_PARSER::LoadArchiveFile(), PCAD2KICAD::LoadInputFile(), NeedLEFT(), NeedNUMBER(), NeedRIGHT(), NeedSYMBOL(), NeedSYMBOLorNUMBER(), ReadCommentLines(), Scan(), and scanList().

◆ parseDouble() [1/3]

double DSNLEXER::parseDouble ( )
protected

Parse the current token as an ASCII numeric string with possible leading whitespace into a double precision floating point number.

Exceptions
IO_ERRORif an error occurs attempting to convert the current token.
Returns
The result of the parsed token.

Definition at line 824 of file dsnlexer.cpp.

References _, CurLine(), CurLineNumber(), CurOffset(), CurSource(), CurStr(), CurText(), res, THROW_IO_ERROR, and THROW_PARSE_ERROR.

Referenced by DRAWING_SHEET_PARSER::parseDouble(), PCB_PLOT_PARAMS_PARSER::parseDouble(), and STROKE_PARAMS_PARSER::parseDouble().

◆ parseDouble() [2/3]

double DSNLEXER::parseDouble ( const char *  aExpected)
inlineprotected

Definition at line 511 of file dsnlexer.h.

References parseDouble().

◆ parseDouble() [3/3]

template<typename T >
double DSNLEXER::parseDouble ( aToken)
inlineprotected

Definition at line 518 of file dsnlexer.h.

References parseDouble().

◆ PopReader()

LINE_READER * DSNLEXER::PopReader ( )

Delete the top most LINE_READER from an internal stack of LINE_READERs and in the case of FILE_LINE_READER this means the associated FILE is closed.

The most recently used former LINE_READER on the stack becomes the current LINE_READER and its previous position in its input stream and the its latest line number should pertain. PopReader always starts reading from a new line upon returning to the previous LINE_READER. A pop is only possible if there are at least 2 #LINE_READERs on the stack, since popping the last one is not supported.

Returns
the LINE_READER that was in use before the pop, or NULL if there was not at least two readers on the stack and therefore the pop failed.

Definition at line 200 of file dsnlexer.cpp.

References dummy, limit, LINE_READER::Line(), next, reader, readerStack, and start.

◆ PrevTok()

int DSNLEXER::PrevTok ( ) const
inline

Return whatever NextTok() returned the 2nd to last time it was called.

Definition at line 246 of file dsnlexer.h.

◆ PushReader()

void DSNLEXER::PushReader ( LINE_READER aLineReader)

Manage a stack of LINE_READERs in order to handle nested file inclusion.

This function pushes aLineReader onto the top of a stack of LINE_READERs and makes it the current LINE_READER with its own #GetSource(), line number and line text. A grammar must be designed such that the "include" token (whatever its various names), and any of its parameters are not followed by anything on that same line, because PopReader always starts reading from a new line upon returning to the original LINE_READER.

Definition at line 188 of file dsnlexer.cpp.

References limit, next, reader, readerStack, and start.

Referenced by DSNLEXER().

◆ ReadCommentLines()

wxArrayString * DSNLEXER::ReadCommentLines ( )

Check the next sequence of tokens and reads them into a wxArrayString if they are comments.

Reading continues until a non-comment token is encountered, and such last read token remains as CurTok() and as CurText(). No push back or "un get" mechanism is used for this support. Upon return you simply avoid calling NextTok() for the next token, but rather CurTok().

Returns
Heap allocated block of comments or NULL if none. The caller owns the allocation and must delete if not NULL.

Definition at line 801 of file dsnlexer.cpp.

References DSN_COMMENT, FromUTF8(), NextTok(), and SetCommentsAreTokens().

◆ readLine()

int DSNLEXER::readLine ( )
inlineprotected

Definition at line 462 of file dsnlexer.h.

References next().

Referenced by NextTok().

◆ SetCommentsAreTokens()

bool DSNLEXER::SetCommentsAreTokens ( bool  val)
inline

Change the handling of comments.

If set true, comments are returned as single line strings with a terminating newline. Otherwise they are consumed by the lexer and not returned.

Definition at line 297 of file dsnlexer.h.

Referenced by ReadCommentLines().

◆ SetSpaceInQuotedTokens()

bool DSNLEXER::SetSpaceInQuotedTokens ( bool  val)
inline

Change the setting controlling whether a space in a quoted string isa terminator.

Parameters
valIf true, means

Definition at line 281 of file dsnlexer.h.

◆ SetSpecctraMode()

void DSNLEXER::SetSpecctraMode ( bool  aMode)

Change the behavior of this lexer into or out of "specctra mode".

If specctra mode, then: -#) stringDelimiter can be changed. -#) KiCad quoting protocol is not in effect. -#) space_in_quoted_tokens is functional else none of the above are true.

The default mode is non-specctra mode, meaning: -#) stringDelimiter cannot be changed. -#) KiCad quoting protocol is in effect. -#) space_in_quoted_tokens is not functional.

Definition at line 139 of file dsnlexer.cpp.

References space_in_quoted_tokens, specctraMode, and stringDelimiter.

◆ SetStringDelimiter()

char DSNLEXER::SetStringDelimiter ( char  aStringDelimiter)
inline

Change the string delimiter from the default " to some other character and return the old value.

Parameters
aStringDelimiterThe character in lowest 8 bits.
Returns
The old delimiter in the lowest 8 bits.

Definition at line 266 of file dsnlexer.h.

◆ SyncLineReaderWith()

bool DSNLEXER::SyncLineReaderWith ( DSNLEXER aLexer)

Usable only for DSN lexers which share the same LINE_READER.

Synchronizes the pointers handling the data read by the LINE_READER. Allows 2 #DNSLEXER objects to share the same current line, when switching from a #DNSLEXER to another #DNSLEXER

Parameters
aLexerthe model.
Returns
true if the sync can be made ( at least the same line reader ).

Definition at line 165 of file dsnlexer.cpp.

References curOffset, curText, limit, next, reader, and start.

◆ Syntax()

const char * DSNLEXER::Syntax ( int  aTok)
static

◆ Unexpected() [1/2]

void DSNLEXER::Unexpected ( const char *  aToken) const

Throw an IO_ERROR exception with an input file specific error message.

Parameters
aTokenis the token which was not expected at the current input location.
Exceptions
IO_ERRORwith the location within the input file of the problem.

Definition at line 357 of file dsnlexer.cpp.

References _, CurLine(), CurLineNumber(), CurOffset(), CurSource(), text, and THROW_PARSE_ERROR.

◆ Unexpected() [2/2]

void DSNLEXER::Unexpected ( int  aTok) const

Throw an IO_ERROR exception with an input file specific error message.

Parameters
aTokis the token/keyword type which was not expected at the current input location.
Exceptions
IO_ERRORwith the location within the input file of the problem.

Definition at line 341 of file dsnlexer.cpp.

References _, CurLine(), CurLineNumber(), CurOffset(), CurSource(), GetTokenString(), and THROW_PARSE_ERROR.

Referenced by Scan(), and scanList().

Member Data Documentation

◆ commentsAreTokens

bool DSNLEXER::commentsAreTokens
protected

true if should return comments as tokens

Definition at line 545 of file dsnlexer.h.

Referenced by init(), InitParserState(), and NextTok().

◆ curOffset

int DSNLEXER::curOffset
protected

offset within current line of the current token

Definition at line 548 of file dsnlexer.h.

Referenced by init(), InitParserState(), NextTok(), and SyncLineReaderWith().

◆ curText

std::string DSNLEXER::curText
protected

the text of the current token

Definition at line 551 of file dsnlexer.h.

Referenced by NextTok(), and SyncLineReaderWith().

◆ curTok

int DSNLEXER::curTok
protected

the current token obtained on last NextTok()

Definition at line 550 of file dsnlexer.h.

Referenced by init(), InitParserState(), and NextTok().

◆ dummy

char DSNLEXER::dummy[1]
protected

when there is no reader.

Definition at line 527 of file dsnlexer.h.

Referenced by PopReader().

◆ iOwnReaders

bool DSNLEXER::iOwnReaders
protected

on readerStack, should I delete them?

Definition at line 523 of file dsnlexer.h.

Referenced by ~DSNLEXER().

◆ keywordCount

unsigned DSNLEXER::keywordCount
protected

count of keywords table

Definition at line 554 of file dsnlexer.h.

Referenced by GetTokenText().

◆ keywords

const KEYWORD* DSNLEXER::keywords
protected

table sorted by CMake for bsearch()

Definition at line 553 of file dsnlexer.h.

Referenced by GetTokenText().

◆ keywordsLookup

const KEYWORD_MAP* DSNLEXER::keywordsLookup
protected

fast, specialized "C string" hashtable

Definition at line 555 of file dsnlexer.h.

Referenced by findToken().

◆ limit

const char* DSNLEXER::limit
protected

Definition at line 526 of file dsnlexer.h.

Referenced by NextTok(), PopReader(), PushReader(), and SyncLineReaderWith().

◆ next

const char* DSNLEXER::next
protected

Definition at line 525 of file dsnlexer.h.

Referenced by NextTok(), PopReader(), PushReader(), and SyncLineReaderWith().

◆ prevTok

int DSNLEXER::prevTok
protected

curTok from previous NextTok() call.

Definition at line 547 of file dsnlexer.h.

Referenced by init(), InitParserState(), and NextTok().

◆ reader

LINE_READER* DSNLEXER::reader
protected

Definition at line 534 of file dsnlexer.h.

Referenced by PopReader(), PushReader(), and SyncLineReaderWith().

◆ readerStack

READER_STACK DSNLEXER::readerStack
protected

all the LINE_READERs by pointer.

no ownership. ownership is via readerStack, maybe, if iOwnReaders

Definition at line 531 of file dsnlexer.h.

Referenced by PopReader(), PushReader(), and ~DSNLEXER().

◆ space_in_quoted_tokens

bool DSNLEXER::space_in_quoted_tokens
protected

blank spaces within quoted strings

Definition at line 543 of file dsnlexer.h.

Referenced by init(), and SetSpecctraMode().

◆ specctraMode

bool DSNLEXER::specctraMode
protected

if true, then: 1) stringDelimiter can be changed 2) Kicad quoting protocol is not in effect 3) space_in_quoted_tokens is functional else not.

Definition at line 536 of file dsnlexer.h.

Referenced by init(), NextTok(), and SetSpecctraMode().

◆ start

const char* DSNLEXER::start
protected

Definition at line 524 of file dsnlexer.h.

Referenced by NextTok(), PopReader(), PushReader(), and SyncLineReaderWith().

◆ stringDelimiter

char DSNLEXER::stringDelimiter
protected

Definition at line 542 of file dsnlexer.h.

Referenced by init(), NextTok(), and SetSpecctraMode().


The documentation for this class was generated from the following files: