neverrare / butter Goto Github PK
View Code? Open in Web Editor NEWA tasty language for building efficient software. Currently in hiatus
License: Mozilla Public License 2.0
A tasty language for building efficient software. Currently in hiatus
License: Mozilla Public License 2.0
Does the compiler run on WebAssembly (wasm)? Is such feature planned?
Butter have it, yet there's no document for it.
Record call syntax, more specifically function calls with named arguments (e.g. fun(arg = 10)
), is currently disabled due to a bug where the parser would stack overflow when parsing certain codes: tuple with splat (e.g. (10, *(20,))
) and record with splat (e.g. (a = 10, *(b = 20))
).
This bug is hard to debug, at least for myself. Desperately, I tried to disable some part of the parser and found out by doing so to some extent would "fix" the bug at the expense that some syntax wouldn't be supported for now. I found out that disabling record call is the most minimum I could disable to "fix" this bug.
The problem doesn't make sense for me, nevertheless I'll continue to develop other parts of butter such as type inference. I tried to fix this problem without disabling some part of the parser (which also doesn't make sense for me) but it wasn't fruitful and haven't come to conclusion for some time.
If you like to tackle this issue (how courageous of you), please be wary that this issue isn't approachable for contributors due to factors such as the parser is quite complex and there isn't a clear instruction for reproducing this bug. I'm sorry for that, I'll work on it with the following todo list.
todo for myself:
Obtain a local clone of Butter and install Cargo.
Open parser/src/expr/infix.rs in the text editor of your choice. There, you'll see the following code along with the line number. The code may recently be updated and the line number may not match, just use it as a reference.
105 // #14
106 tuple().map(PartialAst::TupleCall),
107
108 // attempt(tuple()).map(PartialAst::TupleCall),
109 // super::record::record().map(PartialAst::RecordCall),
Put the line 106 in comment then uncomment the line 108 and 109, this will re-enable the record call parser and the bug.
Run the command cargo run -- parser-repl
, this will start the parser REPL after the compilation is done, then enter either (10, *(20,))
or (a = 10, *(b = 20))
.
This is expected to parse correctly and output the ast, but instead, the parser stack overflows.
butter/doc/language/control_flow.md
Line 162 in fa5759c
As found out in #14, the parser functions have huge stack frame size that causes stack overflow too early even for parsing codes that isn't deeply nested.
This may also be an opportunity to refactor the parser codes.
Update: With handful of guess-works without actually measuring stack usage, I found out that building in release mode helps significantly. It seems like majority of stack values are debug stuffs. Even better, using Linux (I'm using Alpine WSL) instead of Windows also help even in debug mode. Thus, this seems like a Windows issue (MSVC issue?). Nevertheless, this still hints memory issue within the parser and could annoy contributors using Windows, so it is still better to address this issue, but this wouldn't be prioritized.
butter/core/src/parser/expr.rs
Line 66 in 4ab4d94
Currently, the lexer stops when it finds a problem. It should continue as much as possible to allow more problems to be detected.
butter/core/src/lexer/float.rs
Line 5 in 50525fb
This is necessary for testing out type inference/checking especially for complex codes. We already have REPL which outputs type for given expression but this wasn't enough, it can only handle a subset of code. So we need typed hir printer. It must be pretty!
_
!
|
||
&
&&
-
+
-
*
/
//
%
==
!=
<
>
<=
>=
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.