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