94 FILE* aFile,
const wxString& aFileName );
106 const std::string& aSExpression,
const wxString& aSource = wxEmptyString );
116 DSNLEXER(
const std::string& aSExpression,
const wxString& aSource = wxEmptyString );
140 void InitParserState();
151 bool SyncLineReaderWith(
DSNLEXER& aLexer );
166 void SetSpecctraMode(
bool aMode );
225 int NeedSYMBOLorNUMBER();
233 int NeedNUMBER(
const char* aExpectation );
256 return findToken( curText );
268 char old = stringDelimiter;
271 stringDelimiter = aStringDelimiter;
283 bool old = space_in_quoted_tokens;
286 space_in_quoted_tokens = val;
299 bool old = commentsAreTokens;
300 commentsAreTokens = val;
316 wxArrayString* ReadCommentLines();
324 static bool IsSymbol(
int aTok );
332 void Expecting(
int aTok )
const;
341 void Expecting(
const char* aTokenList )
const;
350 void Unexpected(
int aTok )
const;
358 void Unexpected(
const char* aToken )
const;
368 void Duplicate(
int aTok );
387 const char* GetTokenText(
int aTok )
const;
392 wxString GetTokenString(
int aTok )
const;
394 static const char* Syntax(
int aTok );
401 return curText.c_str();
418 return wxString::FromUTF8( curText.c_str() );
426 return reader->LineNumber();
434 return (
const char*)(*reader);
444 return reader->GetSource();
454 return curOffset + 1;
468 unsigned len = reader->Length();
472 start = reader->Line();
489 int findToken(
const std::string& aToken )
const;
493 if( !space_in_quoted_tokens && cc ==
' ' )
496 if( cc == stringDelimiter )
513 NeedNUMBER( aExpected );
517 template <
typename T>
Implement a lexical analyzer for the SPECCTRA DSN file format.
std::string curText
the text of the current token
unsigned keywordCount
count of keywords table
std::vector< LINE_READER * > READER_STACK
bool SetSpaceInQuotedTokens(bool val)
Change the setting controlling whether a space in a quoted string isa terminator.
bool commentsAreTokens
true if should return comments as tokens
const char * CurText() const
Return a pointer to the current token's text.
int curTok
the current token obtained on last NextTok()
bool space_in_quoted_tokens
blank spaces within quoted strings
int PrevTok() const
Return whatever NextTok() returned the 2nd to last time it was called.
bool specctraMode
if true, then: 1) stringDelimiter can be changed 2) Kicad quoting protocol is not in effect 3) space_...
int curOffset
offset within current line of the current token
bool isStringTerminator(char cc) const
const KEYWORD * keywords
table sorted by CMake for bsearch()
READER_STACK readerStack
all the LINE_READERs by pointer.
wxString FromUTF8() const
Return the current token text as a wxString, assuming that the input byte stream is UTF8 encoded.
const wxString & CurSource() const
Return the current LINE_READER source.
const std::string & CurStr() const
Return a reference to current token in std::string form.
const char * CurLine() const
Return the current line of text from which the CurText() would return its token.
bool SetCommentsAreTokens(bool val)
Change the handling of comments.
double parseDouble(T aToken)
int GetCurStrAsToken() const
Used to support "loose" matches (quoted tokens).
int CurTok() const
Return whatever NextTok() returned the last time it was called.
double parseDouble(const char *aExpected)
int CurOffset() const
Return the byte offset within the current line, using a 1 based index.
char SetStringDelimiter(char aStringDelimiter)
Change the string delimiter from the default " to some other character and return the old value.
int prevTok
curTok from previous NextTok() call.
const KEYWORD_MAP * keywordsLookup
fast, specialized "C string" hashtable
int CurLineNumber() const
Return the current line number within my LINE_READER.
bool iOwnReaders
on readerStack, should I delete them?
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
DSN_SYNTAX_T
List all the DSN lexer's tokens that are supported in lexing.
std::unordered_map< const char *, int, fnv_1a, iequal_to > KEYWORD_MAP
A hashtable made of a const char* and an int.
double parseDouble(LINE_READER &aReader, const char *aLine, const char **aOutput)
Parses an ASCII point string with possible leading whitespace into a double precision floating point ...
std::vector< FAB_LAYER_COLOR > dummy
Hold a keyword string and its unique integer token.
int token
a zero based index into an array of KEYWORDs
const char * name
unique keyword.