93 FILE* aFile,
const wxString& aFileName );
105 const std::string& aSExpression,
const wxString& aSource = wxEmptyString );
115 DSNLEXER(
const std::string& aSExpression,
const wxString& aSource = wxEmptyString );
340 void Expecting(
const char* aTokenList )
const;
393 static const char*
Syntax(
int aTok );
417 return wxString::FromUTF8(
curText.c_str() );
433 return (
const char*)(*reader);
488 int findToken(
const std::string& aToken )
const;
516 template <
typename T>
Implement a lexical analyzer for the SPECCTRA DSN file format.
int NeedSYMBOLorNUMBER()
Call NextTok() and then verifies that the token read in satisfies bool IsSymbol() or the next token i...
void NeedLEFT()
Call NextTok() and then verifies that the token read in is a DSN_LEFT.
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.
static bool IsSymbol(int aTok)
Test a token to see if it is a symbol.
const char * GetTokenText(int aTok) const
Return the C string representation of a DSN_T value.
wxArrayString * ReadCommentLines()
Check the next sequence of tokens and reads them into a wxArrayString if they are comments.
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 NextTok()
Return the next token found in the input file or DSN_EOF when reaching the end of file.
int NeedSYMBOL()
Call NextTok() and then verifies that the token read in satisfies IsSymbol().
int curOffset
offset within current line of the current token
bool isStringTerminator(char cc) const
const KEYWORD * keywords
table sorted by CMake for bsearch()
void NeedRIGHT()
Call NextTok() and then verifies that the token read in is a DSN_RIGHT.
READER_STACK readerStack
all the LINE_READERs by pointer.
char dummy[1]
when there is no reader.
double parseDouble()
Parse the current token as an ASCII numeric string with possible leading whitespace into a double pre...
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.
void Expecting(int aTok) const
Throw an IO_ERROR exception with an input file specific error message.
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...
void Duplicate(int aTok)
Throw an IO_ERROR exception with a message saying specifically that aTok is a duplicate of one alread...
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.
wxString GetTokenString(int aTok) const
Return a quote wrapped wxString representation of a token value.
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
static const char * Syntax(int aTok)
bool SyncLineReaderWith(DSNLEXER &aLexer)
Usable only for DSN lexers which share the same LINE_READER.
void Unexpected(int aTok) const
Throw an IO_ERROR exception with an input file specific error message.
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...
virtual char * ReadLine()=0
Read a line of text into the buffer and increments the line number counter.
virtual const wxString & GetSource() const
Returns the name of the source of the lines in an abstract sense.
virtual unsigned LineNumber() const
Return the line number of the last line read from this LINE_READER.
unsigned Length() const
Return the number of bytes in the last line read from this LINE_READER.
char * Line() const
Return a pointer to the last line that was read in.
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.
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.