Commit Graph

22 Commits

Author SHA1 Message Date
e456189c86 ExpressionStatement in the AST to represent the typse of expressions that is supported in monkey.
Hand written test in the AST to test the String() function for accuracy



git-svn-id: https://svn.tlawal.org/svn/monkey@22 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
2022-05-30 05:51:27 +00:00
fdf6a8a552 - Some minor formatting.
- Parser can now handle return statements.

git-svn-id: https://svn.tlawal.org/svn/monkey@21 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
2022-05-27 15:07:19 +00:00
58f6bab88f Clarity.
git-svn-id: https://svn.tlawal.org/svn/monkey@20 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
2022-05-26 19:25:31 +00:00
145d61ba57 - The parser can now check for errors.
- The test now handles checking for errors.

git-svn-id: https://svn.tlawal.org/svn/monkey@19 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
2022-05-26 19:23:01 +00:00
4a3edec5e6 git-svn-id: https://svn.tlawal.org/svn/monkey@18 f6afcba9-9ef1-4bdd-9b72-7484f5705bac 2022-05-26 19:20:51 +00:00
2e18493a4a Test now passes, wonder what I did wrong.
git-svn-id: https://svn.tlawal.org/svn/monkey@17 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
2022-05-26 17:19:15 +00:00
b8e8fc8b6e Stubborn bug, could not figure out what causing it. Will just re-write the entire thing.
```panic: runtime error: invalid memory address or nil pointer dereference [recovered] 
        panic: runtime error: invalid memory address or nil pointer dereference     
[signal 0xc0000005 code=0x0 addr=0x10 pc=0xbcf660]                                  
                                                                                    
goroutine 6 [running]:                                                              
testing.tRunner.func1.2({0xbe4c60, 0xce2c10})                                       
        C:/Program Files/Go/src/testing/testing.go:1389 +0x24e                      
testing.tRunner.func1()                                                             
        C:/Program Files/Go/src/testing/testing.go:1392 +0x39f                      
panic({0xbe4c60, 0xce2c10})                                                         
        C:/Program Files/Go/src/runtime/panic.go:838 +0x207                         
monkey/ast.(*LetStatement).TokenLiteral(0xc000022940?)                              
        D:/monkey/ast/ast.go:37                                                     
monkey/parser.testLetStatement(0xc000132000, {0xc32638, 0x0}, {0xc0106a, 0x1})      
        D:/monkey/parser/parser_test.go:43 +0x49                                    
monkey/parser.TestLetStatements(0xc000132000)                                       
        D:/monkey/parser/parser_test.go:36 +0x1ba                                   
testing.tRunner(0xc000132000, 0xc0d940)                                             
        C:/Program Files/Go/src/testing/testing.go:1439 +0x102                      
created by testing.(*T).Run                                                         
        C:/Program Files/Go/src/testing/testing.go:1486 +0x35f                      
FAIL    monkey/parser   0.180s                                                      
FAIL
```

git-svn-id: https://svn.tlawal.org/svn/monkey@16 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
2022-05-26 16:35:08 +00:00
4f90d0cbd1 Formatting
git-svn-id: https://svn.tlawal.org/svn/monkey@15 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
2022-05-26 16:33:09 +00:00
c7dbccbe71 Basic structure of the parser, I now understand what is going on. I think ¯\_(?)_/¯
git-svn-id: https://svn.tlawal.org/svn/monkey@14 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
2022-05-24 17:05:02 +00:00
b78944e3d7 Typo
git-svn-id: https://svn.tlawal.org/svn/monkey@13 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
2022-05-23 17:35:55 +00:00
4691f6c3e5 Basic AST to represent expressions, statement, identifiers
I now understand how it works.

git-svn-id: https://svn.tlawal.org/svn/monkey@12 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
2022-05-23 14:26:34 +00:00
d37bdfa644 Don't understand how it works.
git-svn-id: https://svn.tlawal.org/svn/monkey@11 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
2022-05-23 14:25:45 +00:00
f8f7ec04c7 Basic AST to represent expressions, statement, identifiers
I now understand how it works.

git-svn-id: https://svn.tlawal.org/svn/monkey@10 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
2022-05-23 14:24:35 +00:00
69ffeb209c Do not show username at interpreter startup.
Now Monk not monkey
Formatting and code clarity


git-svn-id: https://svn.tlawal.org/svn/monkey@9 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
2022-05-23 14:18:27 +00:00
0aa17eeee4 git-svn-id: https://svn.tlawal.org/svn/monkey@8 f6afcba9-9ef1-4bdd-9b72-7484f5705bac 2022-05-22 17:26:31 +00:00
cf651aa1b8 ast and parser
git-svn-id: https://svn.tlawal.org/svn/monkey@7 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
2022-05-22 06:51:19 +00:00
7a74beea8a Todos
git-svn-id: https://svn.tlawal.org/svn/monkey@6 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
2022-05-19 00:25:09 +00:00
1ea1289b7a READ-EVALUATE-PRINT-LOOP now works and spits out tokens of input. YAY!!!
git-svn-id: https://svn.tlawal.org/svn/monkey@5 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
2022-05-12 22:39:29 +00:00
ee8ab63809 Rename new -> New and next_token -> NextToken, because of go's weird requirement that first letter
of public methods in a package that would be used in another package must be capitalized.

git-svn-id: https://svn.tlawal.org/svn/monkey@4 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
2022-05-12 22:38:47 +00:00
fec8dd9152 Basic READ-EVALUATE-PRINT-LOOP
git-svn-id: https://svn.tlawal.org/svn/monkey@3 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
2022-05-12 22:15:41 +00:00
cebc052f32 - The lexer can now peek forward into the input stream.
- Added the rest of the basic math operators.
- Added > and <.
- Test, Test, Test.
- Added if, else, return, true, false.
- Lexer can now differentiate between '=' and '==' and '!' and '!='.

git-svn-id: https://svn.tlawal.org/svn/monkey@2 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
2022-05-12 22:04:29 +00:00
44d9b2c7ec Monkey can now lex its basic types and keywords.
git-svn-id: https://svn.tlawal.org/svn/monkey@1 f6afcba9-9ef1-4bdd-9b72-7484f5705bac
2022-05-12 20:51:16 +00:00