📄 syntaxanalyzer.h
字号:
#pragma once
/*
* Class CSyntaxAnalyzer - Parse and execute
*/
class CSyntaxAnalyzer
{
private:
// Runtime context
CContext *m_Context;
// Tokenlist from the lexer
tokenlist_t *m_tokenlist;
// Tokenlist iterator
tokenlist_t::iterator m_tokenIterator;
// Are we reading or creating variables (ie. in a DIM statement)
bool m_Dim;
public:
// Allow full construction
CSyntaxAnalyzer(void);
~CSyntaxAnalyzer(void);
CSyntaxAnalyzer(CContext *Context, tokenlist_t *TokenList);
// Set the runtime context (runtime context is required)
void SetContext(CContext * Context);
// Get the runtime context
CContext * GetContext(void);
// Set the token list for the current run
void SetTokenList(tokenlist_t * TokenList);
// Get the current token list
tokenlist_t * GetTokenList(void);
// Analyze a program statement
void Analyze(void);
// Wrapper for parsing an expression, for
// defined functions
float Expression(string strExpression);
private:
// Parse a program statement
void sProgramStatement(void);
// Get a line number from the token stream
int sLineNumber(void);
// Get a statement from the token stream
void sStatement(void);
// Get a LET statement from the token stream
bool sLetStatement(void);
// Get a READ statement from the token stream
bool sReadStatement(void);
// Get a DATA statement from the token strea
bool sDataStatement(void);
// Get a PRINT statement from the token stream
bool sPrintStatement(void);
// Get a GOTO statement from the token stream
bool sGotoStatement(void);
// Get an IF THEN statement from the token stream
bool sIfThenStatement(void);
// Get a FOR statement from the input stream
bool sForStatement(void);
// Get a NEXT statement from the token stream
bool sNextStatement(void);
// Get a REM statement from the token stream
bool sRemStatement(void);
// Get a DIM statement from the token stream
bool sDimStatement(void);
// Get a DEF statement from the token stream
bool sDefStatement(void);
// Get a GOSUB statement from the token stream
bool sGoSubStatement(void);
// Get a RETURN statement from the token stream
bool sReturnStatement(void);
// Get a STOP statement from the token stream
bool sStopStatement(void);
// Get an END statement from the input stream
bool sEndStatement(void);
// Get a variable from the token stream
CSymbol * sVariable(void);
// Get a variable list from the token stream
list<CSymbol *> * sVariableList(void);
// Get a string from the token list
string sString(void);
// Get a list of evaluated expressions
list<float> * sExpressionList(void);
// Get a label/expression list from the token stream
string sLabelExpressionList(void);
// Get a label/express from the token stream, return it as a string
string sLabelExpression(void);
// Evaluate an expression
float sExpression(void);
// Get a signed term from the token stream
float sSignedTerm(void);
// Get a term from the token stream
float sTerm(void);
// Get a factor from the input stream
float sFactor(void);
// Return true and increment token iterator if the next operator is an exponentiation operator
bool sExponentiationOperator(void);
// Return with a character for +/- and increment iterator, or return NULL and leave iterator alone
char sAdditiveOperator(void);
// Return a mulop and increment iterator, or return NULL
char sMultiplicativeOperator(void);
// Return relop and increment iterator, or return NULL
relop_t sRelationalOperator(void);
// Return a constant from the token stream
float sConstant(void);
// Get an exponent portion of a constant (x.xEx)
int sExponent(void);
// Get an identifier from the token stream
float sIdentifier(void);
// Get an unsubscripted variable from the token stream
string sUnsubscriptedVariable(void);
// Get a subscripted variable from the token stream
string sSubscriptedVariable(void);
// Get a single digit from the token stream
int sDigit(void);
// Get a function from the token stream
float sFunction(void);
// Get a function identifier from the token stream
string sFunctionIdentifier(void);
// Returns -1 for left parenthesis, 1 for right parenthesis, and 0 for no parenthesis
int sParenthesis(void);
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -