modify some and define types for token

This commit is contained in:
2025-11-04 13:20:21 +09:00
parent cacb35ddb2
commit bbc1838b8a
3 changed files with 33 additions and 2 deletions

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}"`

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;

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,;
}