Website Summary Files Commits Branches @commit @diff @stats
path: root / spasm / src / asm / lexer.re
diff options
context:
space:
mode:
Commitc32eda4e697803824e79878c74d541b81fbd04d8 (patch)
Author
 dtrendafilov <trendafilov.dn@gmail.com>
2018-11-15 11:35:44 +0200
Committer
 GitHub <noreply@github.com>
2018-11-15 11:35:44 +0200
Filesace7bdc0df3791b6db8878d52ba98cb368e180b8 /spasm/src/asm/lexer.re
IPL-c32eda4e697803824e79878c74d541b81fbd04d8.tar
IPL-c32eda4e697803824e79878c74d541b81fbd04d8.tar.gz
IPL-c32eda4e697803824e79878c74d541b81fbd04d8.zip
Parenta7cd9d4f8d83024402bacb39786e5e1a018a0a04 (diff)
Parentd7b2e339ff06c64bcb1322eec396d4995da6b17a (diff)
Merge pull request #48 from SofiaCPP/feature/spasm_asm
Spasm tests and latest instruction set
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;