95 FILE* aFile,
const wxString& aFileName );
107 const std::string& aSExpression,
const wxString& aSource = wxEmptyString );
117 DSNLEXER(
const std::string& aSExpression,
const wxString& aSource = wxEmptyString );
141 void InitParserState();
152 bool SyncLineReaderWith(
DSNLEXER& aLexer );
167 void SetSpecctraMode(
bool aMode );
226 int NeedSYMBOLorNUMBER();
234 int NeedNUMBER(
const char* aExpectation );
257 return findToken( curText );
269 char old = stringDelimiter;
272 stringDelimiter = aStringDelimiter;
284 bool old = space_in_quoted_tokens;
287 space_in_quoted_tokens = val;
300 bool old = commentsAreTokens;
301 commentsAreTokens = val;
317 wxArrayString* ReadCommentLines();
325 static bool IsSymbol(
int aTok );
333 void Expecting(
int aTok )
const;
342 void Expecting(
const char* aTokenList )
const;
351 void Unexpected(
int aTok )
const;
359 void Unexpected(
const char* aToken )
const;
369 void Duplicate(
int aTok );
395 const char* GetTokenText(
int aTok )
const;
400 wxString GetTokenString(
int aTok )
const;
402 static const char* Syntax(
int aTok );
409 return curText.c_str();
426 return wxString::FromUTF8( curText.c_str() );
434 return reader->LineNumber();
442 return (
const char*)(*reader);
452 return reader->GetSource();
462 return curOffset + 1;
476 unsigned len = reader->Length();
480 start = reader->Line();
497 int findToken(
const std::string& aToken )
const;
501 if( !space_in_quoted_tokens && cc ==
' ' )
504 if( cc == stringDelimiter )
521 NeedNUMBER( aExpected );
525 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.