modify some and define types for token

This commit is contained in:
yenru0 committed 2025-11-04 13:20:21 +09:00
1 parent cacb35ddb2
commit bbc1838b8a
3 files changed
+33 -2

No files matched your search

+2 -1
View File
@@ -10,9 +10,10 @@
* SEMI `;`
* COMMA `,`
* ARROW `->`
* STAR `*`
* COMMENT `#`
* NUM `[0-9]*(.[0-9]+)?`
* RETURN `return`
* IF `if`
* ELSE `else`
* STRING "{any}"
* STRING `"{any}"`
+30
View File
@@ -0,0 +1,30 @@
#pragma once
typedef enum {
LBRACK,
RBRACK,
LCURLY,
RCURLY,
ID,
SEMI,
COMMA,
ARROW,
STAR,
COMMENT,
NUM,
RETURN,
IF,
ELSE,
STRING_LITERAL,
ERROR
} TokenType;
typedef struct {
TokenType type;
char *data;
int line;
} Token;
+1 -1
View File
@@ -12,7 +12,7 @@ val [->int] main {
val str line input;
val int n to_int line,;
if < n 0 {
print "ILLEGAL"
print "illegal number"
} else {
print to_str fib n,;
}