From 900df4f9b561dd52d9364b604b188a20d8ad1345 Mon Sep 17 00:00:00 2001 From: Eatswap Date: Sat, 10 Dec 2022 01:02:23 +0800 Subject: [PATCH] add: some op --- DragonLisp.l | 6 ++++++ DragonLisp.y | 6 ++++++ DragonLispDriver.hh | 7 ------- token.h | 8 +++++++- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/DragonLisp.l b/DragonLisp.l index f7c4591..f8d0d08 100644 --- a/DragonLisp.l +++ b/DragonLisp.l @@ -33,6 +33,12 @@ blank [ \t\v\r] {blank}+ { 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_RPAREN; } "+" { return token::TOKEN_PLUS; } diff --git a/DragonLisp.y b/DragonLisp.y index de32373..e5fd7f0 100644 --- a/DragonLisp.y +++ b/DragonLisp.y @@ -41,6 +41,12 @@ namespace DragonLisp { %define parse.assert %token + LE "<=" + GE ">=" + EQUAL "=" + NE "/=" + LT "<" + GT ">" LPAREN "(" RPAREN ")" PLUS "+" diff --git a/DragonLispDriver.hh b/DragonLispDriver.hh index a358421..4ff9968 100644 --- a/DragonLispDriver.hh +++ b/DragonLispDriver.hh @@ -20,13 +20,6 @@ public: void error(const DLParser::location_type& l, const std::string& m); void error(const std::string& m); - enum Operator { - PLUS, - MINUS, - MULTIPLY, - DIVIDE - }; - private: DLParser* parser = nullptr; DLScanner* scanner = nullptr; diff --git a/token.h b/token.h index d6e7b6d..d644ac7 100644 --- a/token.h +++ b/token.h @@ -4,10 +4,16 @@ namespace DragonLisp { enum Token { + LE, + GE, + EQUAL, + NE, + LT, + GT, PLUS, MINUS, MULTIPLY, - DIVIDE + DIVIDE, }; }