Commit Graph

685 Commits

Author SHA1 Message Date
greg
10c3a60515 Some symbol-table refactoring 2019-01-20 00:23:08 -08:00
greg
a63dcf91b0 Replace // with quot 2019-01-10 20:57:13 -08:00
greg
479a098e0f Make note to fix parsing bug 2019-01-09 17:37:51 -08:00
greg
1085b528fe Don't care about case-sensitivity 2019-01-08 02:38:10 -08:00
greg
9b3b5c5541 Token offsets 2019-01-08 02:11:19 -08:00
greg
ab8e24a276 ParseError always has token now 2019-01-08 01:04:46 -08:00
greg
09e2d8579d Remove all ParseErrors that don't return the failed token 2019-01-08 01:00:40 -08:00
greg
ee7861cbd0 Fix how impl blocks work
This gets rid of a token-less parseerror
2019-01-08 00:51:56 -08:00
greg
b88def8a2e Make error msg better 2019-01-07 16:52:46 -08:00
greg
30676722a3 Transition to edition 2018 2019-01-07 13:00:37 -08:00
greg
801c90aaa7 Reorder parameters in pass functions 2019-01-07 02:43:31 -08:00
greg
fa295aab28 Show location of error in parse error 2019-01-07 01:52:54 -08:00
greg
a0f4abb9a3 Add SourceReference 2019-01-06 01:58:16 -08:00
greg
78b454fb32 Delete this line 2019-01-05 20:41:49 -08:00
greg
5491169d55 Refactor parsing structure
TokenHandler should contain all the methods for actually manipulating
tokens, Parser should only contain the recursive descent methods
2019-01-05 20:23:07 -08:00
greg
2b338fd3c9 Move .next() onto token_handler 2019-01-05 18:29:24 -08:00
greg
821f321261 More Node-wrapping of Expression 2019-01-05 18:11:51 -08:00
greg
846eeae04c More use of Token instead of TokenKind 2019-01-05 17:50:54 -08:00
greg
22f2750853 More use of Token in error messages 2019-01-05 17:40:05 -08:00
greg
f2f8ac7ee8 Make parserrors have token 2019-01-05 17:32:49 -08:00
greg
d0c5dce92b Use get_kind() 2019-01-05 17:28:35 -08:00
greg
8eda74c9a5 Starting to keep track of locations of errors in file 2019-01-05 17:18:10 -08:00
greg
2efac109ef Node for TupleLiteral 2019-01-05 16:06:55 -08:00
greg
215e2bbb0d PrefixOp have Node 2019-01-05 16:02:30 -08:00
greg
2590def3be More Node-wrapping 2019-01-05 15:54:03 -08:00
greg
879a7de83d Wrap Expression in Node 2019-01-05 15:47:44 -08:00
greg
4c2e0b8a21 Get rid of old code from old ideas 2019-01-05 15:35:51 -08:00
greg
282c42da3c Adding Node intermediate type to AST 2019-01-05 01:44:32 -08:00
greg
7ac97ca6e8 Kill ast_visitor 2018-11-26 01:57:44 -08:00
greg
26a8ff307f Add generic Node type 2018-11-20 03:21:10 -08:00
greg
6be208b51d Minor fix for parsing error messages 2018-11-20 03:03:08 -08:00
greg
e00948cad9 Add ast_visitor mod 2018-11-17 02:09:16 -08:00
greg
0af6fed505 Clear up some code a bit 2018-11-17 01:10:23 -08:00
greg
1f527f7949 Rename TokenType -> TokenKind 2018-11-16 23:17:34 -08:00
greg
b198984fc5 implement From for Expression-types 2018-11-16 14:06:04 -08:00
greg
58779f8470 Rename method, make sourcemap optional 2018-11-16 12:58:10 -08:00
greg
a0fa50392c Fix compile error 2018-11-16 12:46:29 -08:00
greg
d357876b16 WIP source map stuff 2018-11-16 04:12:07 -08:00
greg
e42f0c644c Introduce source map 2018-11-16 03:56:55 -08:00
greg
2ec7bf3b9a Some initial work on passing token metadata to AST 2018-11-16 03:51:03 -08:00
greg
5147e1a3eb Handle underscores in identifiers 2018-11-15 16:19:53 -08:00
greg
955c073174 Got typechecker unused errors down to one 2018-11-13 02:39:02 -08:00
greg
7c46a29141 Start adding doc comments 2018-11-11 18:04:44 -08:00
greg
0adc761e72 Kill an unimplemented!() 2018-11-11 02:48:51 -08:00
greg
b2039a7b67 Parameterize Type type over existential/universal 2018-11-10 16:33:42 -08:00
greg
b4c4531e4d Rename for more concision 2018-11-10 14:11:29 -08:00
greg
2d36ad44d6 Converting over types
WIP
2018-11-09 02:50:29 -08:00
greg
21132a369c Paramaterize Type 2018-11-09 02:05:59 -08:00
greg
ff0294c56e Typechecking shouldn't fail yet 2018-11-09 02:02:08 -08:00
greg
e39356c0e5 Even more type work 2018-11-09 00:21:34 -08:00
greg
d44bb02d61 Even more types 2018-11-08 20:30:17 -08:00
greg
9056e9b0e1 More type work2 2018-11-08 02:29:54 -08:00
greg
e9b90412ce More type work 2018-11-08 02:12:01 -08:00
greg
65c47c20fc Change name of monad in which type inference happens 2018-11-07 17:01:07 -08:00
greg
fab3fb8ec2 More basic types + test 2018-11-07 16:39:32 -08:00
greg
0d5ccd21fe TConst 2018-11-07 15:39:40 -08:00
greg
69b7b9f528 Print out types to REPL 2018-11-07 13:44:28 -08:00
greg
9a09f40222 More typing work 2018-11-07 03:39:31 -08:00
greg
020819550b More typechecking infrastructure 2018-11-06 16:47:34 -08:00
greg
15f9dbe7a6 Typechecking infrastructure 2018-11-06 13:44:52 -08:00
greg
836bed1207 Added janky map to prelude 2018-11-06 03:02:32 -08:00
greg
cee5b085d5 Simpler syntax for single param in lambdas
This kind of implies that I might want -> for function types after all,
instead of :
2018-11-06 02:58:57 -08:00
greg
837a55c718 Test for nested function call 2018-11-06 02:42:28 -08:00
greg
f4f89b39b6 Handle nested function calls 2018-11-06 02:40:10 -08:00
greg
c6b4ed7ee4 Basic lambdas 2018-11-06 01:19:16 -08:00
greg
be425860af Starting on lambdas 2018-11-05 21:13:31 -08:00
greg
17e88b33f2 Eval test doesn't need to be a macro
Can be a fn
2018-11-05 21:07:06 -08:00
greg
47f7eb1ef6 Make prelude be separate file 2018-11-05 20:55:03 -08:00
greg
72d0cfe466 More macro test consolidation 2018-11-05 20:52:18 -08:00
greg
cea2f63b44 Use macros to make types more concise 2018-11-05 20:12:10 -08:00
greg
eec315dd58 Get rid of exprstatement! macro
For shorter exst! one
2018-11-05 19:58:55 -08:00
greg
1e9aa91c5d More concise test macros 2018-11-05 19:57:11 -08:00
greg
9813609ad7 Minor test refactoring 2018-11-05 19:17:53 -08:00
greg
5953d9d815 type annotations on lambdas 2018-11-05 19:10:34 -08:00
greg
a74e09c761 Change lambda syntax 2018-11-05 18:51:01 -08:00
greg
ad53d4394b Get rid of println 2018-11-05 14:52:51 -08:00
greg
151246e1c5 Test for pattern-matching 2018-11-05 14:11:49 -08:00
greg
77d2826918 Pattern-match on structured objects 2018-11-05 14:01:14 -08:00
greg
1bd48ed5db Fix problem with parsing commas
I should probably rethink how delimited block expressions like if-blocks
(and eventually for-blocks) work
2018-11-05 13:07:08 -08:00
greg
c394b81746 More pattern-matching 2018-11-05 04:02:04 -08:00
greg
ec29077247 More tuple-matching
Also discovered parser bug
2018-11-05 03:41:03 -08:00
greg
62043ac2d1 Starting on pattern-matching tuples
Lots of duplicated code here
2018-11-05 03:17:03 -08:00
greg
bada386979 More work on subpattern matching 2018-11-03 12:53:09 -07:00
greg
e71d404071 Finished this refactor 2018-11-02 19:54:04 -07:00
greg
cab4702bd6 Refactoring matching - WIP
doesn't work yet
2018-11-01 02:43:47 -07:00
greg
ec5a9d457e String patterns 2018-10-31 01:45:16 -07:00
greg
bfbc1580aa Make tag optional 2018-10-30 23:36:55 -07:00
greg
2d6c9010b9 More work here 2018-10-30 18:53:34 -07:00
greg
f4ff92302f Use subpattern abstraction 2018-10-30 18:46:06 -07:00
greg
e88ed97b06 Add subpattern struct 2018-10-30 18:39:25 -07:00
greg
b8df09e956 Change eval strategy to use conditional sigil 2018-10-29 01:50:43 -07:00
greg
d7f0147a4f Add conditional target placeholder expr 2018-10-28 12:45:45 -07:00
greg
f883512882 New abstraction layer in Schala-lang parser
Just for manipulating tokens
2018-10-21 16:33:21 -07:00
greg
37070a6b3e Move pass chain generation from macro to codegen 2018-10-20 18:00:05 -07:00
greg
d7baf065fb Changing what method to call to start parsing 2018-10-20 15:41:09 -07:00
greg
6b42f8b8de Change how parsing works 2018-10-20 14:27:00 -07:00
greg
7de536ade0 Install failure crate 2018-10-20 11:17:18 -07:00
greg
4679a9fc7f Remove compiler warnings 2018-10-20 00:55:37 -07:00
greg
c25354b2c7 Get rid of typechecking code (for now)
I'm tired of seeing the errors. See branch last_commit_with_typechecking
2018-10-20 00:41:56 -07:00
greg
5f8b842bf2 Delete newline 2018-10-20 00:22:41 -07:00
greg
fef66e345b Subpattern field 2018-10-19 17:43:22 -07:00
greg
e57d33eae7 More work on more patterns
-need to convert guard into a possibly-empty vec
2018-10-19 17:27:06 -07:00
greg
dca9ad06c3 Handle HalfExpr closer to correct 2018-10-19 11:02:10 -07:00
greg
354148c5ba rename codegen -> chala-lang-codegen 2018-10-19 09:57:35 -07:00
greg
6219a06d6f Converted all parser methods to use the annotation 2018-10-19 02:56:11 -07:00
greg
3b20b40eb7 Proc macro generated code for parsing seems to work 2018-10-19 02:45:35 -07:00
greg
4ecf63c54d Okay the proc_macro is actually doing something
At the cost of breaking code
2018-10-19 02:36:23 -07:00
greg
3d00667caf Add test for ignored pattern 2018-10-18 15:55:24 -07:00
greg
4b9c7e38dd Rename TypeName -> TypeIdentifier 2018-10-18 13:27:09 -07:00
greg
dff204069f Starting to implement Ignored pattern 2018-10-18 01:54:36 -07:00
greg
f2282f0101 case_match_expression split out into its own method 2018-10-18 01:49:42 -07:00
greg
40ccea8c05 Separate assign_expression method 2018-10-18 01:46:30 -07:00
greg
cae6f2f768 Rename schala-codegen -> schala-repl-codegen 2018-10-18 01:09:29 -07:00
greg
1be6991f55 Making eval expression method a bit less complex
by splitting it into submethods
2018-10-17 20:46:16 -07:00
greg
1b60bd38ff Add codegen crate for schala-lang 2018-10-17 15:29:32 -07:00
greg
3b20b9e209 Put schala-lang crates into a subdirectory 2018-10-17 14:51:48 -07:00
greg
de0e150536 Fix if-block parsing to handle newlines 2018-10-17 13:44:29 -07:00
greg
baf51fb147 Boolean patterns 2018-10-17 12:43:09 -07:00
greg
dc9e493fa1 Handle more patterns at reduce_ast level 2018-10-16 17:18:03 -07:00
greg
d57a8045a9 Rename test helper 2018-10-16 04:11:18 -07:00
greg
50d5176b45 Fix bug add test 2018-10-16 04:10:28 -07:00
greg
501eaeee87 Implement numeric pattern matching 2018-10-16 03:54:08 -07:00
greg
8619c94217 Start handling numeric patterns
Still need to add eval support for this
2018-10-16 01:38:41 -07:00
greg
9927a6b1fd Implement custom interpreter directives - and a wtf?
See the comment about &mut self vs &self
2018-10-15 20:29:23 -07:00
greg
abe2db25b2 full if matching working with basic patterns 2018-10-15 19:54:17 -07:00
greg
a99a5f10a4 Indicate index explicitly in SymbolTable debug 2018-10-15 19:37:02 -07:00
greg
80eb703f5e Finally got get_doc hookup in codegen macro working 2018-09-29 01:20:31 -07:00
greg
4fccff5e27 Working on improved proc_macro handling 2018-09-27 04:07:42 -07:00
greg
5d4505241a get rid of completed todo 2018-09-22 00:26:38 -07:00
greg
f67793308e Part of the work for a doc handler 2018-09-22 00:24:27 -07:00
greg
693766fa59 Proc macros are stable now 2018-09-21 19:46:31 -07:00
greg
1abbe2e448 Add guard to Alternative
The semantics are:
    -if tag is Some(_), assume the condition is a constructor,
    and compare tags
    - if guard is Some(_), evaluate true/false *after* having
    applied any bound variables

With this, I can technically get rid of bare conditionals now, since
they are the same as an Alternative with a None tag
2018-08-27 12:45:08 -07:00
greg
065bdd6bda Starting custom operators
Can now parse custom operators. Maybe I want to make it so that you
have to put explicit backticks if you define a custom operator,
currently you can just do: fn +() { .. }
2018-08-24 16:49:59 -07:00
greg
e125e8b440 Add spaceship operator for getting an ord 2018-08-24 16:29:28 -07:00
greg
8565c7dfb3 Some work on reduced ast pattern 2018-08-24 16:04:18 -07:00
greg
f885d5dfb6 Remove type alias 2018-08-22 23:22:08 -07:00
greg
b85725125c Start using HalfExp 2018-08-22 16:41:31 -07:00
greg
2d961d6402 Fix other pattern parsing bugs 2018-08-21 20:02:10 -07:00
greg
fa7b6ce96b Handle negatives in patterns correctly 2018-08-21 19:57:45 -07:00
greg
1d5e5aa735 Some type renaming in builtins
Builtins will remain entirely separate from the actual type
representation, whatever that ends up being
2018-08-19 22:00:20 -07:00
greg
2c298c7247 Add warning for undefined operator
In practice this will probably always not typecheck, but it's a valid
parse
2018-08-19 21:40:30 -07:00
greg
f00fee0e37 Rename StateStack -> ScopeStack 2018-08-19 21:31:45 -07:00
greg
0d13b5e3bc Preliminary support for binops in if-discriminators
The BNF grammar is a bit more liberal than any successfully-compiled
schala program should be, in that it allows things like `if x < is
pattern`. It's okay if that parses successfully and then is an error at
typechecking.
2018-08-19 21:25:07 -07:00
greg
98f597f00a Implement comparison operators correctly 2018-08-19 21:11:43 -07:00
greg
fb71881409 Refactor binop parsing 2018-08-19 20:33:50 -07:00
greg
d1c3b4a81b Starting on halfexprs / binops 2018-08-19 18:44:54 -07:00
greg
f9181b5786 use expr_or_block where appropriate 2018-08-19 15:58:31 -07:00
greg
0e914cf057 Error message for parsing guards 2018-08-19 15:12:34 -07:00
greg
04ea8c5ebc More unused code removal 2018-08-19 15:06:01 -07:00
greg
492ef4ae19 Clear up some unused code to reduce compile noise
And add some notes to the README
2018-08-19 15:03:41 -07:00
greg
75a7a4499d Added some more cases to the match handling 2018-08-19 10:53:43 -07:00
greg
97bee58fbe More work with guards 2018-08-15 22:34:04 -07:00
greg
34c2b43371 More work on if matching 2018-08-15 18:32:44 -07:00
greg
88b617de52 More atlernatives work 2018-08-15 11:44:55 -07:00
greg
482674b19a Start on expr_or_block
WIP doesn't work yet
2018-08-15 09:34:00 -07:00
greg
a72b387ceb Remove some more dead code warnings 2018-08-14 23:19:27 -07:00
greg
864e932e9f Getting rid of more unused items 2018-08-14 23:09:11 -07:00
greg
d7e73be44c Getting rid of some unused warnings 2018-08-14 23:07:00 -07:00
greg
0c0690e86e Provide error message here 2018-08-14 21:53:57 -07:00
greg
6d18f80185 Use Result in test 2018-08-14 21:46:48 -07:00
greg
6825de3916 new_frame -> new_scope 2018-08-14 21:45:45 -07:00
greg
1b78fbff82 Tests for basic pattern matching 2018-08-14 21:39:33 -07:00
greg
897c1181a9 Basic pattern matching working 2018-08-14 21:17:43 -07:00
greg
6833bc4f00 Start on CaseMatch eval 2018-08-14 12:43:06 -07:00
greg
f2ded78776 ReducedAST: Match -> CaseMatch
makes it easier to grep for
2018-08-14 12:37:18 -07:00
greg
9debdd8d66 Primitive tuple 2018-08-14 02:03:05 -07:00
greg
8067c862f3 Switch out types for evaluator 2018-08-14 00:11:13 -07:00
greg
f9c2fc3f9d Make code more concise 2018-08-07 17:09:53 -07:00
greg
5ead1e5d44 NewConstructor -> Constructor 2018-08-05 19:14:02 -07:00
greg
348a6f7c76 More work on pattern-matching
I think I need to entirely change the types in the evaluator.
ReducedAST should only care about NewConstructor (which I gotta rename),
and the evaluator is the only place that an implementation of a
primitive constructed type should live (see Peyton-Jones implementing a
functional langauge p. 70)
2018-08-05 19:11:42 -07:00
greg
5f336ec1a9 Add lookup_by_name to symbol table 2018-08-05 18:19:48 -07:00
greg
da59fae0d3 More work on pattern-matching 2018-08-05 18:01:42 -07:00
greg
5b5689accf Changing representation of primitive objects 2018-08-05 17:15:58 -07:00
greg
32acf89814 New Constructor 2018-08-05 16:04:52 -07:00
greg
c637a922a9 Start implementing constructors/matches
as per Implementing Functional Programming Languages by Peyton-Jones
2018-08-05 14:23:08 -07:00
greg
42d0aba21c Add index of variants to symbol table
Also new prelude type, just for testing
2018-08-05 13:59:13 -07:00
greg
bc6d4d19b5 reduced ast match 2018-07-26 00:52:46 -07:00
greg
a2b1b0f953 Pattern-matching in reduced AST 2018-07-26 00:52:46 -07:00
greg
75bf4b5697 Fill out variants to be reduced 2018-07-26 00:52:46 -07:00
greg
98e812968b Fix parsing additional options 2018-07-26 00:52:46 -07:00
greg
250c486143 Fix derive code 2018-07-26 00:52:46 -07:00
greg
38eb065511 Broken proc macro custom derive code 2018-07-26 00:52:46 -07:00
greg
4ca57e4aea Change name of debug options struct 2018-07-26 00:52:46 -07:00
greg
82502ad0ad Move some parsing code around 2018-07-26 00:52:46 -07:00
greg
7d68b2a05a Get rid of code related to old match stuff 2018-07-26 00:52:46 -07:00
greg
c2db212c78 Some more guard arm stuff + dealing with split binexp
... in if-blocks. Need to do some re-architecture I think
2018-07-26 00:52:46 -07:00
greg
837a180b09 Starting work on guard arms 2018-07-26 00:52:46 -07:00
greg
5ecd298e6a Record Pattern 2018-07-26 00:52:46 -07:00
greg
8aa33d0872 Starting on guards 2018-07-26 00:52:46 -07:00
greg
21a8868bcf Fixed test 2018-07-26 00:52:46 -07:00
greg
5a91957fa1 Some incomplete parse work 2018-07-26 00:52:46 -07:00
greg
176d43e56f Remove old comment 2018-07-26 00:52:46 -07:00
greg
90ecde89c9 Mutable types 2018-07-26 00:52:46 -07:00
greg
65c2cd521b Mutable types
This bit of syntax is meant for extendable enum types
2018-07-26 00:52:46 -07:00
greg
f7dbbddad1 Let and let mut syntax 2018-07-26 00:52:46 -07:00
greg
43ff08b04c Add some debugging info around parse error 2018-07-26 00:52:46 -07:00
greg
00692aa89e Support for underscores 2018-07-26 00:52:46 -07:00
greg
5e48eb2dee Broken - some pass abstraction work 2018-07-26 00:52:46 -07:00
greg
3597ad4eef Compact parsing 2018-07-26 00:52:46 -07:00
greg
072eab1a80 Thread debug opts around where they need to be 2018-07-26 00:52:46 -07:00
greg
55a8cabd7c Some basic pattern stuff 2018-07-26 00:52:46 -07:00
greg
3c022fc4ef Clarified BNF 2018-07-26 00:52:46 -07:00
greg
0a02c21e70 Some more Patterns work
-at first brush, a pattern is like a single Variant with a list of free
vars
2018-07-26 00:52:46 -07:00
greg
927f427a86 Starting work on patterns 2018-07-26 00:52:46 -07:00
greg
005aba7a10 Test alt form 2018-07-26 00:52:46 -07:00
greg
7882e92ab5 Fix old style if 2018-07-26 00:52:46 -07:00
greg
f582ab4eaa Test for new style parsing 2018-07-26 00:52:46 -07:00
greg
f2dce38647 Broken, but compiling, move to new if paradigm 2018-07-26 00:52:46 -07:00
greg
ba4cd9da39 Kill match keyword + data structures
And add new unified keywords
2018-07-26 00:52:46 -07:00
greg
654eeef428 Clarified grammar BNF some 2018-07-26 00:52:46 -07:00
greg
a96fbc9592 Fix match expression parsing 2018-07-26 00:52:46 -07:00
greg
196954326e Print bare data constructor 2018-07-26 00:52:46 -07:00
greg
3f2fff276c Constructor eval 2018-07-26 00:52:46 -07:00
greg
ebcea685f3 Fix looking up functions 2018-07-26 00:52:46 -07:00
greg
3b9084810e Add constructor reduced ast node; fix test 2018-07-26 00:52:46 -07:00
greg
7809cda240 Pass symbol_table to ast reduce
To distinguish between values and data constructors
2018-07-26 00:52:46 -07:00
greg
f1679e83b7 Start trying to fix tests 2018-07-26 00:52:46 -07:00
greg
f98d8e2bb0 Move AST into its own module 2018-07-26 00:52:46 -07:00
greg
d0a0cc8209 Rename ast_reducing -> reduced_ast 2018-07-26 00:52:46 -07:00
greg
5aa0e10e7a Some ADT work 2018-07-26 00:52:46 -07:00
greg
27729cefdf Some improvements to the thing 2018-07-26 00:52:46 -07:00
greg
df76e7c120 Pretty-print type table 2018-07-26 00:52:46 -07:00
greg
889610f0b0 Pretty-print Symbol Table 2018-07-26 00:52:46 -07:00
greg
3beabf4678 Start eval-ing data constructors 2018-07-26 00:52:46 -07:00
greg
25790f8643 Added super-janky prelude capability 2018-07-26 00:52:46 -07:00
greg
ff5446af3f Add symbols from symbol table into global type context 2018-07-26 00:52:46 -07:00
greg
5d84153c9e Want bin expressions typed soon 2018-07-26 00:52:46 -07:00
greg
0b0f6b6b50 Symbol table handles functions better 2018-07-26 00:52:46 -07:00
greg
856a360aba Types need handle to symbol table 2018-07-26 00:52:46 -07:00
greg
81ca9ee20f Add some data structures back 2018-07-26 00:52:46 -07:00
greg
4caf8096b3 Add Scheme, TypeEnv, Substitution data structs 2018-07-26 00:52:46 -07:00
greg
c65907388d Some ADT work 2018-07-26 00:52:46 -07:00
greg
33c22c8bbc Typecheck values 2018-07-26 00:52:46 -07:00
greg
4a27af2136 Add a super-basic test 2018-07-26 00:52:46 -07:00
greg
07af54b78a More work 2018-07-26 00:52:46 -07:00
greg
c4666b82ec Basics 2018-07-26 00:52:46 -07:00
greg
274dd1ccb0 Basic stuff 2018-07-26 00:52:46 -07:00
greg
70ec79c4b3 Lol starting over from scratch again
H-M is hard :/
2018-07-26 00:52:46 -07:00
greg
f88d2331e3 printf debugs for problems with function typing 2018-07-26 00:52:46 -07:00
greg
c8f961abbf Functions 2018-07-26 00:52:46 -07:00
greg
d040d76bfa Start handling function case 2018-07-26 00:52:46 -07:00
greg
887ba46b0b Fix this thing 2018-07-26 00:52:46 -07:00
greg
a80db9e4c2 Debug types
WIP
2018-07-26 00:52:46 -07:00
greg
c986233a95 Adding bindings seems to work?
I'm playing real fast and loose though
2018-07-26 00:52:46 -07:00
greg
bb29df4a73 Variable binding insertion infrastructure 2018-07-26 00:52:46 -07:00
greg
4db3595d7c More work on variables 2018-07-26 00:52:46 -07:00
greg
217ee73fc9 Literals 2018-07-26 00:52:46 -07:00
greg
93309c025e Some work 2018-07-26 00:52:46 -07:00
greg
b67512a9e1 Add Infer struct 2018-07-26 00:52:46 -07:00
greg
8e6f605fab Type alias "TypeName" 2018-07-26 00:52:46 -07:00
greg
ba4185b0fb Back to including typechecking code in pipeline 2018-07-26 00:52:46 -07:00
greg
7a2a4df297 Clearing out most of the cruft from typechecking 2018-07-26 00:52:46 -07:00
greg
642e9da8ee Move everything symbol-table-related into a separate module 2018-07-26 00:52:46 -07:00
greg
cea7427847 put TypeEnvironment on TypeContext 2018-07-26 00:52:46 -07:00
greg
3156c31dfc Variable lookup 2018-07-26 00:52:46 -07:00
greg
2e457cd5e8 First real inferring 2018-07-26 00:52:46 -07:00
greg
843d895f2b infer infra 2018-07-26 00:52:46 -07:00
greg
734c53ce0d Starting to deal with actual expr inferring 2018-07-26 00:52:46 -07:00
greg
3a3b8dd440 TypeEnvironment lives in Infer 2018-07-26 00:52:46 -07:00
greg
c96a56a7ac fresh 2018-07-26 00:52:46 -07:00
greg
4017857a3a Unification 2018-07-26 00:52:46 -07:00
greg
9e0f8b8a14 InferError 2018-07-26 00:52:46 -07:00
greg
7121624f77 Type Env 2018-07-26 00:52:46 -07:00
greg
48e795decc apply_substitution for PolyTypes
If I made an error it's likely here...
2018-07-26 00:52:46 -07:00
greg
a26da934f4 Substitution monotypes 2018-07-26 00:52:46 -07:00
greg
1de1cd9cfd For H-M, add types and some impls 2018-07-26 00:52:46 -07:00
greg
6f639b9030 Type type structure 2018-07-26 00:52:46 -07:00
greg
8f0104ebc7 Deletion 2018-07-26 00:52:46 -07:00
greg
36cd7e080d Even more deletions 2018-07-26 00:52:46 -07:00
greg
f48a25779c Lol just get rid of all the old code, start from scratch again 2018-07-26 00:52:46 -07:00
greg
808a1bfc98 Still more deletions 2018-07-26 00:52:46 -07:00
greg
c7e46c1cfa KIll any commented code 2018-07-26 00:52:46 -07:00
greg
98cfcfc18d Eval shouldn't be aware of types 2018-07-26 00:52:46 -07:00
greg
b4c7ea3d02 Show bindings too in debug 2018-07-26 00:52:46 -07:00
greg
e7c89ed840 Some more refactoring 2018-07-26 00:52:46 -07:00
greg
b0e38f7f5b Refactor 2018-07-26 00:52:46 -07:00
greg
276662d98a Some code rearrangements 2018-07-26 00:52:46 -07:00
greg
e8e9265b26 Use less verbose match syntax 2018-07-26 00:52:46 -07:00
greg
cb316a973e Getting back to hindley-milner
First, clear out some of this cruft in the compiler warnings
2018-07-26 00:52:46 -07:00
greg
e64861b602 Some eval tests 2018-07-26 00:52:46 -07:00
greg
1673fd1cf9 Fix test 2018-07-26 00:52:46 -07:00
greg
c00effcbdd Add _ 2018-07-26 00:52:46 -07:00
greg
8378170fbd Kill comments 2018-07-26 00:52:46 -07:00
greg
7ab385d398 Bring custom ADTs to the repl 2018-07-26 00:52:46 -07:00
greg
9fb148bb02 Make compile again 2018-07-26 00:52:46 -07:00
greg
97df2fa344 I dunno 2018-07-26 00:52:46 -07:00
greg
a08134a747 Delete old code in eval 2018-07-26 00:52:46 -07:00
greg
3ac50f974d Pass around reference to type context in evaluator 2018-07-26 00:52:46 -07:00
greg
afc4281e7f Evaluate function arguments in context before applying them 2018-07-26 00:52:46 -07:00
greg
8d6fea942f Handle function definition before use
And some other ReducedAST - Evaluation niceties
2018-07-26 00:52:46 -07:00
greg
6d93c758a2 Add function to symbol table 2018-07-26 00:52:46 -07:00
greg
aff421cd99 Working with symbol table
Note that symbol table is a different object now than the previous
binding table that was used for type-checking. That binding table is not
currently debugged and should be debugged in a separate debug output with
typechecking proper.
2018-07-26 00:52:46 -07:00
greg
493d76da0b Add symbol table data structure to typechecking 2018-07-26 00:52:46 -07:00
greg
eb681fbff9 Make parse error message nicer 2018-07-26 00:52:46 -07:00
greg
f3e3843528 Decomplexify delimited! 2018-07-26 00:52:46 -07:00
greg
6b90e19eb1 Simplify expect! macro
Ends up printing a debug print, but whatever, will fix later
2018-07-26 00:52:46 -07:00
greg
210ae47c8b Get rid of lambda 2018-07-26 00:52:46 -07:00
greg
70794d8ff1 For expression parsing 2018-07-26 00:52:46 -07:00
greg
532c8c45b4 Parse while expressions
Decided to add while expressions to the language to make for-parsing
easier. Plus some other random notes
2018-07-26 00:52:46 -07:00
greg
24b532df06 This doesn't need to be a closure 2018-07-26 00:52:46 -07:00
greg
ac576be604 Trim newline in getline()
Ineffiicent but whatever
2018-07-26 00:52:46 -07:00
greg
6bf106a1a3 Equality 2018-07-26 00:52:46 -07:00
greg
44e585fca2 Conditionals 2018-07-26 00:52:46 -07:00
greg
3f836eb74f Kill some warnings 2018-07-26 00:52:46 -07:00
greg
abf25d648d Change repl behavior of strings 2018-07-26 00:52:46 -07:00
greg
1f6e6d9b31 Tuples 2018-07-26 00:52:46 -07:00
greg
e2703121d8 Kill unneeded import 2018-07-26 00:52:46 -07:00
greg
e5b6b41422 Error msg 2018-07-26 00:52:46 -07:00
greg
6c5e3dea5d Assignment 2018-07-26 00:52:46 -07:00
greg
bd8bf1945c Super simple janky input 2018-07-26 00:52:46 -07:00
greg
9e393d2753 Kill old type structure 2018-07-26 00:52:46 -07:00
greg
822420a9d5 Add an eval test 2018-07-26 00:52:46 -07:00
greg
6f8dc9bedd rename IntLiteral -> NatLiteral 2018-07-26 00:52:46 -07:00
greg
e0cec8b8a6 print, println as builtins 2018-07-26 00:52:46 -07:00
greg
1a84f62818 Kill some old code, make very_simple example print 2018-07-26 00:52:46 -07:00
greg
b1966d7199 Function calling works kind of 2018-07-26 00:52:46 -07:00
greg
fdbb21990d Retrieve function from memory when called 2018-07-26 00:52:46 -07:00
greg
1011ff08f3 Use new rust 1.26 less verbose syntax 2018-07-26 00:52:46 -07:00
greg
6d8d2aecbd Functions 2018-07-26 00:52:46 -07:00
greg
848306ad1a Reduce defined function 2018-07-26 00:52:46 -07:00
greg
e6f0710e41 Debug ast rewrite 2018-07-26 00:52:46 -07:00
greg
78ba4e1ed3 Variable lookup 2018-07-26 00:52:46 -07:00
greg
481afb0f87 Fix debugging and debug eval 2018-07-26 00:52:46 -07:00
greg
01986e7474 starting bindings 2018-07-26 00:52:46 -07:00
greg
9cf5260d4b Use impl Trait to simplify type signatures 2018-07-26 00:52:46 -07:00
greg
18c8176134 Get rid of unneeded imports 2018-07-26 00:52:46 -07:00
greg
2cb7d35008 Use EvalResult type 2018-07-26 00:52:46 -07:00
greg
bd1eed884f State type manipulations 2018-07-26 00:52:46 -07:00
greg
67917612e6 Swap over eval code to new paradigm
While keeping the old code commented for reference
2018-07-26 00:52:46 -07:00
greg
b4a16cdc55 Prefix ops 2018-07-26 00:52:46 -07:00
greg
4d5ab95946 Fix bug with / parsing 2018-07-26 00:52:46 -07:00
greg
ce71254b69 Implement a lot more ops 2018-07-26 00:52:46 -07:00
greg
065e58f87e Successfully interpreting addition 2018-07-26 00:52:46 -07:00
greg
6768cebc48 Literals 2018-07-26 00:52:46 -07:00
greg
ec5580d20b prefix op reduction 2018-07-26 00:52:46 -07:00
greg
9de66a9af3 Unimplemented sigil 2018-07-26 00:52:46 -07:00
greg
633b4fe7a4 Nats, some binop reduction 2018-07-26 00:52:46 -07:00
greg
87c3b8e234 Some work 2018-07-26 00:52:46 -07:00
greg
16a463b1a0 Method-style 2018-07-26 00:52:46 -07:00
greg
c3be644133 Optional scope name 2018-07-26 00:52:46 -07:00
greg
e7615fda8b Add new_frame method 2018-07-26 00:52:46 -07:00
greg
111657b567 Add generic stack data structure
I'll want to use this soon enough
2018-07-26 00:52:46 -07:00
greg
c5e8d3e080 Random notes re: symbol table
I'm proably gonna want to redo the symbol table stuff after reading Language
Implementation Patterns, esp. to accomodate scopes
2018-07-26 00:52:46 -07:00
greg
4f49c183b0 Float + reduce binop/prefixop 2018-07-26 00:52:46 -07:00
greg
81368179bb More boilerplate 2018-07-26 00:52:46 -07:00
greg
30128d7d34 Easy work 2018-07-26 00:52:46 -07:00
greg
6c718e5d4f Start AST-reducing 2018-07-26 00:52:46 -07:00
greg
774ddd665b Infrastructure to evaluate reduced AST 2018-07-26 00:52:46 -07:00
greg
0bb0ecea76 Add new ast reducing pass 2018-07-26 00:52:46 -07:00
greg
7686707602 Type alias Vec<String> -> Block 2018-07-26 00:52:46 -07:00