-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Self hosted parser completion #873
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
Conversation
Great work so far. It's been really exciting to watch your progress |
std/zig/parser.zig
Outdated
|
||
try testCanonical( | ||
\\test "test array" { | ||
\\ const a : [2]u8 = [2]u8{ 1, 2 }; |
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.
I think canonical var decl is:
const name: type = value;
(No space between colon and var name)
std/zig/parser.zig
Outdated
); | ||
|
||
try testCanonical( | ||
\\test "percendence" { |
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.
'precedence' typo?
I've now added test cases for what I hope is all of Zig's syntax. I've also added a checklist with all everything that is missing from the self-hosted parser. |
std/zig/parser.zig
Outdated
\\ x += 1; | ||
\\ suspend |p| { | ||
\\ } | ||
\\ const p = async simpleAsyncFn() cache unreachable; |
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.
I hate it when the cache is unreachable :)
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.
Lol, yes :)
@andrewrk The variable declaration syntax in the self-hosted parser is currently not being parsed correctly. In the C++ compiler, this is solved by parsing type expressions as prefix operators first and therefore requiring parentheses for infix operators to be used in type expressions. This solution cannot be used in the self-hosted parser because of the way expressions are parsed. Do we rewrite expression parsing to make this work or disallow assignment as an expression? |
There is also the option of checking if the type expression is an assignment and then transform |
Also, in the C++ compiler, this is allowed:
I don't think this has any use. |
* Slice/Array access is now not parsed in the expr contruction loop * State.ExprListItemOrEnd now takes a token id for the end token
This is also a problem when implementing initializers :/
Gets parsed as:
|
* I also moved some tests down, as they fail in ways I can't fix yet
* Now, the arraylist from the root node is passed through the states. * This allows us to reuse the code for enums, unions and structs
I think assignments should not be expressions. |
Alright. Then we just need to solve #760 :) |
* We cannot render asm expressions yet
* Only allowed in while continue expr and statement expr
* I parse it as a type in all contexts. This is not how the C++ compiler does it, but I think typechecking should catch this
From the appveyor build: Wow, I've not seen this happen yet. I guess we need to add a |
All tests passing, merged! Let's open new issues for whatever's left. |
Great work, @Hejsil. |
This is in no way done, but I thought, that instead of just pushing my work on the self-hosted parser to master, I would make this PR. This allows me to write a lot of tests that fail, and slowly work towards getting them all passing.
Checklist!
extern "c" fn puts(s: &const u8) c_int;
error
null
unreachable
this
switch
while
for
if
defer
catch
comptime
use
std
When all these are checked and the self-hosted parser can parse the entire std library and all tests, then it's ready for a merge.