-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to New Parser #55
base: main
Are you sure you want to change the base?
Conversation
@@ -1234,7 +1234,7 @@ module Compilation = | |||
|
|||
let ast, diagnostics = | |||
let nodes, diagnostics = | |||
List.map Parse.parseFile sources | |||
List.map LegacyParse.parseFile sources | |||
|> List.fold (fun (nodes, diags) (n, d) -> (List.append nodes [ n ], List.append d diags)) ([], []) | |||
|
|||
{ Location = TextLocation.Missing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably want to come up with a better way of modelling this. The previous parser was run on each input, and then we pasted them together into a single big SEQ. Instead I guess we should have a wrapper Compilation
type, which contains a set of BoundCompilationUnits
. We can bind them in sequence, and propagate some state (lib definitions etc.). The key is we don't want to have public items from one unit just become 'magically' available in another. This will probably want to be different for script compilations however. In that case we'd want multiple passes at compilation to share definitions from the previous.
We may want to handle this by just having the last compilation unit in the compilation be treated specially and allow definitions from that to leak into the root binder scope. That way inherited compilations from scripting would have access to the previous definitions.
src/Feersum/ParseRepl.fs
Outdated
ReadLine.Read("[]> ") | ||
|> Parse.readProgram "repl.scm" | ||
|
||
let private print (result: ParseResult<Program>) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some kind of ast explorer which allows you to cd and ls around the tree might be nice.
@@ -6,6 +6,14 @@ open Feersum.CompilerServices.Diagnostics | |||
open Feersum.CompilerServices.Syntax | |||
open Feersum.CompilerServices.Utils | |||
|
|||
module private BinderDiagnostics = | |||
|
|||
// TODO: remove this and replace with better binder errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Distinct binder diagnostics.
ctx.Diagnostics.Emit | ||
BinderDiagnostics.bindError | ||
(List.last formals).Location | ||
"Saw dot but no ID in formals" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dots should be handled by the parse, not the bind
match node.Kind with | ||
| AstNodeKind.Ident i -> BoundDatum.Ident i | ||
| AstNodeKind.Constant c -> BoundDatum.SelfEval(BoundLiteral.FromConstant c) | ||
| AstNodeKind.Dot -> BoundDatum.Ident "." // FIXME: This is definitely not right |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix me. Datum dots.
inherit Expression(red) | ||
|
||
member public _.OpeningParen = | ||
red.ChildrenWithTokens() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should / could lazies work here?
if s.Line = e.Line then | ||
sprintf | ||
"%s(%d,%d-%d): %s: %s" | ||
(s.Source |> normaliseName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks click through and problem matching in VS Code. Maybe Code needs a PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2ccc457
to
309f86c
Compare
f49cb8a
to
de9feb9
Compare
de9feb9
to
7c274b4
Compare
9d1b6f8
to
9df82a1
Compare
ac7f645
to
67b8269
Compare
4aede6a
to
27dd7a0
Compare
Compilations are now run on `CompileInput`s containing either a `Program` or `ScriptProgram`. This is then lowered to a legacy tree for binding but should allow compile API surface changes to be fleshed out. Some `eval` tests working directly with legacy trees may benefit from a syntax builder API.
Fixes a bug where trailing junk would not be identified as an error in parsing.
Sketching out the structure of syntax factories. These now need implementing for the remaining node types. Heavily inspired by `Teasel`'s `SyntaxFactory` work.
Factory for bool nodes.
Update the REPL to allow statements to cross lines.
Introduce factories for string and character values. This should mean we now have all the main constant types covered.
Bring back some of the `EvalTests` by adding in factories for our root program types.
Add factory support for quoted values.
1565ddb
to
0a758ad
Compare
Introduce the form and symbol factories, and use them to implement the remaining disabled `eval` tests.
Rather than relying on dup and storing the value on the statck while we perform the `#f` check we can instead store the temporary value in a local. This simplifies the codepath for the `true` case.
0a758ad
to
4be1099
Compare
These files are getting unwieldly and unreadable when embedded in json. Update the assertions to read them from disk instead.
spec/builtin-macros.ast
Outdated
" | ||
ATMOSPHERE: (98..162) ";; exporting or re-exporting macro definitions currently." | ||
ATMOSPHERE: (162..167) " | ||
" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to teach Firethorn
some escapes?
Upgrade to the latest versions of most packages. This includes a breaking change to the debug output of `Firethorn` so test needed re-generating too.
Bringing the new parser up to speed. Replacing all uses of the old parser with the new one, and
binning the old parser.
TODO: