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 );
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 );
441 return wxString::FromUTF8(
curText.c_str() );
449 return reader->LineNumber();
457 return (
const char*)(*reader);
467 return reader->GetSource();
485 inline bool isSep(
char cc );
493 unsigned len =
reader->Length();
514 int findToken(
const std::string& aToken )
const;
542 template <
typename T>
int NeedSYMBOLorNUMBER()
Call NextTok() and then verifies that the token read in satisfies bool IsSymbol() or the next token i...
std::string curText
The text of the current token.
unsigned keywordCount
Count of keywords table.
int NeedNUMBER(const char *aExpectation)
Call NextTok() and then verifies that the token read is type DSN_NUMBER.
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.
int findToken(const std::string &aToken) const
Take aToken string and looks up the string in the keywords table.
const char * CurText() const
Return a pointer to the current token's text.
const char * GetTokenText(int aTok) const
Return the C string representation of a DSN_T value.
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_...
int NextTok()
Return the next token found in the input file or DSN_EOF when reaching the end of file.
const std::string & CurSeparator() const
int NeedSYMBOL()
Call NextTok() and then verifies that the token read in satisfies IsSymbol().
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.
char dummy[1]
When there is no reader.
void SetSpecctraMode(bool aMode)
Change the behavior of this lexer into or out of "specctra mode".
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.
LINE_READER * PopReader()
Delete the top most LINE_READER from an internal stack of LINE_READERs and in the case of FILE_LINE_R...
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.
void InitParserState()
Reinit variables used during parsing, to ensure od states are not used in a new parsing must be calle...
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.
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.
bool SyncLineReaderWith(DSNLEXER &aLexer)
Usable only for DSN lexers which share the same LINE_READER.
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?
void PushReader(LINE_READER *aLineReader)
Manage a stack of LINE_READERs in order to handle nested file inclusion.
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 ...
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.