📄 mathlex.h
字号:
//
// Graphite For WinCE(Pocket PC)
// Initially Written By Hyouck "Hawk" Kim, peakhunt@yahoo.com
// 2002, All Rights Reserved
//
// This is GPLed, open source based, software development project.
// For more question about GPL,
// visit http://www.gnu.org/licenses/gpl.txt
//
//
// Revision History
// Nov/30/2002, Initial Release hkim
//
//
#pragma once
typedef enum mathTokenType
{
MATH_TOKEN_TYPE_OP,
MATH_TOKEN_TYPE_VAR,
MATH_TOKEN_TYPE_NUM,
MATH_TOKEN_TYPE_FUNC,
MATH_TOKEN_TYPE_OPENING_PAREN,
MATH_TOKEN_TYPE_CLOSING_PAREN,
MATH_TOKEN_TYPE_UNRECOGNIZED,
} MathTokenType;
class CMathToken
{
public:
CMathToken(CString& str, MathTokenType type);
CMathToken(const CMathToken& rhs);
public:
CString m_str;
MathTokenType m_type;
};
class CMathLex
{
public:
CMathLex(CString& str);
~CMathLex(void);
CMathToken* getNextToken(void);
private:
CString m_input;
int m_ndx;
public:
bool isReservedFunc(CString& str);
};
/* This is our parser syntax
On WINCE, we don't have lex and yacc yet.
So, till we port it to WinCE,
we gotta hand code it.
arith: expr
;
expr: term moreterms
;
term: factor morefactors
;
moreterms: '+' term { push(+) } moreterms
| '-' term { push(-) } moreterms
| empty
;
factor: ( expr )
| var { push(id) }
| num { push(var) }
| func_term { push(func) } "(" expr ")"
;
morefactors: '*' factor { push(*) } morefactors
| '/' factor { push(/) } morefactors
| empty
;
func_term: "sin" | "cos" | "tan"
;
*/
class CTokenList;
class CMathParser
{
public:
CMathParser(CString& str, CTokenList* list);
bool parse(void);
protected:
void arith(void);
void expr(void);
public:
void factor(void);
void term(void);
bool match(CString& str);
CString m_errString;
CTokenList* m_list;
private:
CMathLex m_scanner;
bool m_success;
CMathToken* m_lookahead;
CTokenList* m_tokenParsed;
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -