In case you’ve ever wondered what a “name” in Ada looks like graphically.
I did this manually so it might contain errors, but I’m potentially looking into automating it from the ARM since it’s very cumbersome and error-prone work.
In case you’ve ever wondered what a “name” in Ada looks like graphically.
I did this manually so it might contain errors, but I’m potentially looking into automating it from the ARM since it’s very cumbersome and error-prone work.
Interesting! (and frightening :). On the 4th line down, there’s a missing )
after <expression>
You might want to do it from the RM sources due to names having italicised parts which determine semantically what it is.
I’ve seen packages which can generate rail road diagrams from markdown/latex, so it would make sense to target that, so you don’t have to do the rendering yourself.
Thanks @simonjwright , that’s a major reason why I was looking into maybe automating this. @Lucretia I had looked into using the ARM for this – right now I’m using railroad-diagrams to generate these, and was thinking of writing out scripts which use that and then using that tool to build them all.
I was just pointing out that when you use on the RHS you need to point out what the semantic meaning is too.
True, but it looks like name
is a very general term in the grammar.
I understand there’s other rules in place to resolve the generality here, I’m trying to understand how this would get parsed since it looks left-recursive and overly general. I was going to look at GCC to see what it does, if it uses a grammar with the left-recursion removed or has some other handling such as using those semantic meanings in the parse:
E.g. generality: you wouldn’t expect a type conversion or qualified expression on the right here.
nonlimited_with_clause ::= [private] with library_unit_name {, library_unit_name};
e.g. Left recursion:
name ::= selected_component | #... and more which not concerned with example, as any a -> +ad through a chain of rules seems to apply
selected_component ::= prefix . selector_name
selector_name ::= identifier | character_literal | operator_symbol
prefix ::= name | implicit_dereference
You might want to look at the Ada grammar for tree-sitter (GitHub - briot/tree-sitter-ada: Ada grammar for tree-sitter) and the tree-sitter parser itself (GitHub - tree-sitter/tree-sitter: An incremental parsing system for programming tools) for maybe a simpler approach than GCC.
The grammar is relatively close to the ARM, but maybe not 100%, so I don’t know whether it will help you.