Website Summary Files Commits Branches @commit @diff @stats
path: root / spasm / src / asm / lexer.re
diff options
context:
space:
mode:
Commit72d9bbcc3154142af79fb686d9dc7e4d1fa1badb (patch)
Author
 dtrendafilov <trendafilov.dn@gmail.com>
2018-11-29 09:13:12 +0200
Committer
 GitHub <noreply@github.com>
2018-11-29 09:13:12 +0200
Files3cea4377cba9370f3f2248557f82831d617d89d1 /spasm/src/asm/lexer.re
IPL-72d9bbcc3154142af79fb686d9dc7e4d1fa1badb.tar
IPL-72d9bbcc3154142af79fb686d9dc7e4d1fa1badb.tar.gz
IPL-72d9bbcc3154142af79fb686d9dc7e4d1fa1badb.zip
Parentcdfd42d72030a031e5c5d810fcd53441902b5cff (diff)
Feature/strings (#75)
* The assembler supports string opcode * disabled the string test until implmented * strings can be printed
1 files changed, 18 insertions, 2 deletions
-rw-r--r--spasm/src/asm/lexer.re20
diff --git a/spasm/src/asm/lexer.re b/spasm/src/asm/lexer.re
index fabeaf7..bdf792d 100644
--- a/spasm/src/asm/lexer.re
+++ b/spasm/src/asm/lexer.re
@@ -56,6 +56,8 @@ NONNEGATIVE = "0" | ([1-9] DIGIT*) ;
XINTEGER = "0" [xX] XDIGIT+ ;
FLOATING = "-"? "0" | ([1-9] DIGIT*) "." NONNEGATIVE ;
IDENTIFIER = [a-zA-Z_] [0-9a-zA-Z_]* ;
+SSTRING = "'" ([^']|"\\'")* "'" ;
+DSTRING = "\"" ([^"]|"\\\"")* "\"" ;
INTEGER {
ts.push_token (Token (Token::Integer, lineno,
@@ -198,13 +200,20 @@ XINTEGER {
token_start = cursor;
continue;
- }
+ }
"const" {
ts.push_token (Token (Token::Const, lineno));
token_start = cursor;
continue;
- }
+ }
+
+"string" {
+ ts.push_token (Token (Token::String, lineno));
+ token_start = cursor;
+
+ continue;
+ }
"call" {
ts.push_token (Token (Token::Call, lineno));
@@ -247,6 +256,13 @@ IDENTIFIER {
continue;
}
+SSTRING | DSTRING {
+ ts.push_token (Token (Token::StringValue, lineno, token_start + 1,
+ cursor - 1));
+ token_start = cursor;
+
+ continue;
+ }
[ ]+ {
token_start = cursor;