add: some op

This commit is contained in:
Eatswap 2022-12-10 01:02:23 +08:00
parent 08c51a0232
commit 900df4f9b5
Signed by: Eatswap
GPG Key ID: BE661106A1F3FA0B
4 changed files with 19 additions and 8 deletions

View File

@ -33,6 +33,12 @@ blank [ \t\v\r]
{blank}+ { loc->step(); } {blank}+ { loc->step(); }
\n+ { loc->lines(yyleng); loc->step(); } \n+ { loc->lines(yyleng); loc->step(); }
"<=" { return token::TOKEN_LE; }
">=" { return token::TOKEN_GE; }
"<" { return token::TOKEN_LT; }
">" { return token::TOKEN_GT; }
"=" { return token::TOKEN_EQUAL; }
"/=" { return token::TOKEN_NE; }
"(" { return token::TOKEN_LPAREN; } "(" { return token::TOKEN_LPAREN; }
")" { return token::TOKEN_RPAREN; } ")" { return token::TOKEN_RPAREN; }
"+" { return token::TOKEN_PLUS; } "+" { return token::TOKEN_PLUS; }

View File

@ -41,6 +41,12 @@ namespace DragonLisp {
%define parse.assert %define parse.assert
%token %token
LE "<="
GE ">="
EQUAL "="
NE "/="
LT "<"
GT ">"
LPAREN "(" LPAREN "("
RPAREN ")" RPAREN ")"
PLUS "+" PLUS "+"

View File

@ -20,13 +20,6 @@ public:
void error(const DLParser::location_type& l, const std::string& m); void error(const DLParser::location_type& l, const std::string& m);
void error(const std::string& m); void error(const std::string& m);
enum Operator {
PLUS,
MINUS,
MULTIPLY,
DIVIDE
};
private: private:
DLParser* parser = nullptr; DLParser* parser = nullptr;
DLScanner* scanner = nullptr; DLScanner* scanner = nullptr;

View File

@ -4,10 +4,16 @@
namespace DragonLisp { namespace DragonLisp {
enum Token { enum Token {
LE,
GE,
EQUAL,
NE,
LT,
GT,
PLUS, PLUS,
MINUS, MINUS,
MULTIPLY, MULTIPLY,
DIVIDE DIVIDE,
}; };
} }