Earlier quoted context omitted.
Nice, long go the days (20 yrs ago) i had to make a JS transpiler with lex+yacc. The pain
had to? or got to? Sounds great, please tell us more.
A Python interpreter rewritten in Rust, that can run pip
51–53 of 53 posts
Re: A Python interpreter rewritten in Rust, that can run pip
#52Earlier quoted context omitted.
had to? or got to? Sounds great, please tell us more.
i wanted to add lambdas to JS, this was back in 2001 i think, so i had this compiler from my compiler class, changed it to parse JS (+ my extra features like the ()=>{} syntax) and generate an AST in XML (instead of emitting bytecode), then i made a python script that took the XML and generated minified JS from it.
I love the AST in XML approach.
Re: A Python interpreter rewritten in Rust, that can run pip
#53Earlier quoted context omitted.
That Python can be described by an LL(1) grammar is frequently mentioned in discussions, but I don't know if it's formally documented anywhere. More specifically, the grammar [0] is in EBNF form and is ELL(1). That means that if each EBNF production is converted to a set of BNF productions in an LL(1)-compliant way, the BNF grammar as a whole is LL(1). It seems that the Python tools themselves do not check this [1],…
Parsing a superset of the language and then using extra checks to detect bad syntax accepted by the superset is a well known and very effective way of being error tolerant and implementing decent error recovery.
Solution?
async fn foo() {
}
fn main() {
let x = async { await foo() };
}
error: incorrect use of `await`
--> src/main.rs:6:13
|
6 | let x = async { await foo() };
| ^^^^^^^^^^^ help: `await` is a postfix operation: `foo().await`
Do exactly that: parse the incorrect form and emit a good diagnostic.