Website Summary Files Commits Branches @commit @diff @stats
path: root / spasm / src / asm / lexer.re
diff options
context:
space:
mode:
Commitd7b2e339ff06c64bcb1322eec396d4995da6b17a (patch)
Author
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2018-11-15 10:11:01 +0200
Committer
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2018-11-15 10:16:21 +0200
Filesace7bdc0df3791b6db8878d52ba98cb368e180b8 /spasm/src/asm/lexer.re
IPL-d7b2e339ff06c64bcb1322eec396d4995da6b17a.tar
IPL-d7b2e339ff06c64bcb1322eec396d4995da6b17a.tar.gz
IPL-d7b2e339ff06c64bcb1322eec396d4995da6b17a.zip
Parentfb7e4dbb3ec65de00987f2ccfc6d29ebfcec12c7 (diff)
Implemented push and pop with numbers
1 files changed, 22 insertions, 5 deletions
-rw-r--r--spasm/src/asm/lexer.re27
diff --git a/spasm/src/asm/lexer.re b/spasm/src/asm/lexer.re
index 298e340..c182653 100644
--- a/spasm/src/asm/lexer.re
+++ b/spasm/src/asm/lexer.re
@@ -52,6 +52,7 @@ DIGIT = [0-9] ;
XDIGIT = [0-9a-fA-F] ;
INTEGER = "-"? "0" | ([1-9] DIGIT*) ;
+NONNEGATIVE = "0" | ([1-9] DIGIT*) ;
XINTEGER = "0" [xX] XDIGIT+ ;
IDENTIFIER = [a-zA-Z_] [0-9a-zA-Z_]* ;
@@ -63,6 +64,22 @@ INTEGER {
continue;
}
+"r" NONNEGATIVE {
+ ts.push_token (Token (Token::Integer, lineno,
+ token_start + 1, cursor));
+ token_start = cursor;
+
+ continue;
+ }
+"a" NONNEGATIVE {
+ Token t(Token::Integer, lineno,
+ token_start + 1, cursor);
+ t.set_int(-t.value_int());
+ ts.push_token(t);
+ token_start = cursor;
+ continue;
+ }
+
XINTEGER {
ts.push_token (Token (Token::XInteger, lineno,
token_start, cursor));
@@ -71,14 +88,14 @@ XINTEGER {
continue;
}
-"push" {
- ts.push_token (Token (Token::Push, lineno));
+"pushr" {
+ ts.push_token (Token (Token::PushFrom, lineno));
token_start = cursor;
continue;
}
-"alloc" {
- ts.push_token (Token (Token::Alloc, lineno));
+"push" {
+ ts.push_token (Token (Token::Push, lineno));
token_start = cursor;
continue;
@@ -89,7 +106,7 @@ XINTEGER {
continue;
}
-"popto" {
+"popr" {
ts.push_token (Token (Token::PopTo, lineno));
token_start = cursor;