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;
297 m_knowsBar = knowsBar;
308 bool old = commentsAreTokens;
309 commentsAreTokens = val;
325 wxArrayString* ReadCommentLines();
333 static bool IsSymbol(
int aTok );
343 void Expecting(
int aTok )
const;
352 void Expecting(
const char* aTokenList )
const;
361 void Unexpected(
int aTok )
const;
369 void Unexpected(
const char* aToken )
const;
379 void Duplicate(
int aTok );
405 const char* GetTokenText(
int aTok )
const;
410 wxString GetTokenString(
int aTok )
const;
412 static const char* Syntax(
int aTok );
419 return curText.c_str();
441 return wxString::FromUTF8( curText.c_str() );
449 return reader->LineNumber();
457 return (
const char*)(*reader);
467 return reader->GetSource();
477 return curOffset + 1;
485 inline bool isSep(
char cc );
493 unsigned len = reader->Length();
497 start = reader->Line();
514 int findToken(
const std::string& aToken )
const;
518 if( !space_in_quoted_tokens && cc ==
' ' )
521 if( cc == stringDelimiter )
538 NeedNUMBER( aExpected );
542 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().
std::string curSeparator
The text of the separator preceeding the current text.
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_...
const std::string & CurSeparator() const
int curOffset
Offset within current line of the current token.
LINE_READER * reader
No ownership. ownership is via readerStack, maybe, if iOwnReaders.
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.
void SetKnowsBar(bool knowsBar=true)
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.
bool m_knowsBar
True if the lexer knows about the bar token.
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.
static bool IsNumber(char x)
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.