mirror of
https://git.sfja.dk/Mikkel/slige.git
synced 2025-01-18 10:36:31 +00:00
parser stuff
This commit is contained in:
parent
af8ce1d47a
commit
6ce48aae2a
@ -91,7 +91,11 @@ export class Parser {
|
||||
if (this.test("}")) {
|
||||
this.step();
|
||||
return this.expr({ type: "block", stmts }, pos);
|
||||
} else if (this.test("fn")) {
|
||||
} else if (this.test("return") || this.test("break") || this.test("let")) {
|
||||
stmts.push(this.parseSingleLineBlockStmt());
|
||||
this.eatSemicolon();
|
||||
}
|
||||
else if (this.test("fn")) {
|
||||
stmts.push(this.parseSingleLineBlockStmt());
|
||||
stmts.push(this.parseFn());
|
||||
} else if (this.test("{") || this.test("if") || this.test("loop")) {
|
||||
|
@ -1,15 +1,15 @@
|
||||
|
||||
fn sum(a, b) {
|
||||
+ a b;
|
||||
}
|
||||
//fn sum(a, b) {
|
||||
// + a b;
|
||||
//}
|
||||
//
|
||||
//add(2,3); // -> 5
|
||||
//
|
||||
//let a = "Hello";
|
||||
//
|
||||
//let b = "world";
|
||||
|
||||
add(2,3); // -> 5
|
||||
|
||||
let a = "Hello";
|
||||
|
||||
let b = "world";
|
||||
|
||||
//println(+ (+ a " ") (+ b "!")); // -> "Hello world!"
|
||||
println(+ + + a " " b "!"); // -> "Hello world!"
|
||||
|
||||
if == a b {
|
||||
println("whaaaat");
|
||||
@ -19,11 +19,11 @@ else {
|
||||
}
|
||||
|
||||
loop {
|
||||
// let i = 0;
|
||||
//
|
||||
// if >= i 10 {
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// i = i + 1;
|
||||
let i = 0;
|
||||
|
||||
if >= i 10 {
|
||||
break;
|
||||
}
|
||||
|
||||
i = + i 1;
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
import { Lexer } from "./Lexer.ts";
|
||||
import { Parser } from "./Parser.ts";
|
||||
|
||||
//const text = await Deno.readTextFile("example-no-types.slg");
|
||||
const text = await Deno.readTextFile("example.slg");
|
||||
const text = await Deno.readTextFile("example-no-types.slg");
|
||||
// const text = await Deno.readTextFile("example.slg");
|
||||
|
||||
const lexer = new Lexer(text);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user