Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is a grammar: stars mean they are repeated, not pointers.


Yes, the language there is Zephyr ASDL [1]. I actually changed this:

    Dict(expr* keys, expr* values)
to

    Dict(List[expr] keys, List[expr] values)
in our fork for https://oilshell.org/ , and it made a lot more sense to contributors.

It's funny how "sticky" syntax is -- two contributors ALSO read * as "pointer" ! So I changed it to be consistent with MyPy syntax earlier this year, and now I think I should have done that a long time ago.

(It would also make sense to change it to keys: List[expr], as that's the Python 3 syntax for types)

---

The funny thing is that while the web page says "Abstract Grammar", I would not call Zephyr ASDL a grammar.

Python has a separate Grammar/Grammar file, that is distinct from this file Python/Python.asdl.

A grammar describes a set of strings, and that's not what ASDL does.

It describes the data structure that the valid strings get transformed to after parsing, and there is not a 1:1 correspondence (e.g. due to the difference between a CST and AST, and other post-parsing validation).

I mentioned that here: https://www.oilshell.org/blog/2016/12/11.html#it-describes-a...

(Pretty sure "ungrammar" from rust-analyzer is nodding at this -- https://rust-analyzer.github.io//blog/2020/10/24/introducing... -- it's "ASDL for concrete syntax trees", i.e. it's not a grammar because it doesn't describe strings; it describes trees)

[1] https://www.oilshell.org/blog/tags.html?tag=ASDL#ASDL




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: