parser stuff
This commit is contained in:
parent
c2a5b66318
commit
353d38a5a4
@ -51,6 +51,19 @@ export class Lexer {
|
||||
}
|
||||
return { ...this.token("int", pos), intValue: parseInt(textValue) };
|
||||
}
|
||||
|
||||
if (this.test("0")) {
|
||||
this.step()
|
||||
if (!this.done() && this.test(/[0-9]/)) {
|
||||
console.error(
|
||||
`Lexer: invalid number`
|
||||
+ ` at ${pos.line}:${pos.col}`,
|
||||
);
|
||||
return this.token("error", pos);
|
||||
}
|
||||
return { ...this.token("int", pos), intValue: 0};
|
||||
}
|
||||
|
||||
if (this.test("\"")) {
|
||||
this.step();
|
||||
let value = "";
|
||||
|
@ -46,4 +46,13 @@ export type ExprKind =
|
||||
| { type: "null"}
|
||||
| { type: "loop", body: Expr }
|
||||
| { type: "block", stmts: Stmt[], expr?: Expr }
|
||||
;
|
||||
;
|
||||
|
||||
export type Sym = {
|
||||
ident: string,
|
||||
type: "let" | "fn" | "fn_param" | "builtin",
|
||||
pos?: Pos,
|
||||
stmt?: Stmt,
|
||||
param?: Param,
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user