tom-and-the-toothfairies / pathways

:older_woman: :hospital: :pill: :pill:
https://tomandthetoothfairies.info/
5 stars 0 forks source link

Report PML construct name-clash #142

Closed houli closed 7 years ago

houli commented 7 years ago

Collect names of all constructs in the PML, possibly also the line number and construct type for doing something like name clash of foo in sequence on line 32, iteration on line 45 and branch on line 47

houli commented 7 years ago

Just testing this out in iex to understand a bit more about leex and yecc will check the other parsing issue now @c-brenn. Seems like we just need to add the TokenChars to idents assuming that idents only ever appear as construct names.

Here's some crappy iex code that gets a lot of the way

File.read!("test/fixtures/no_ddis.pml") |> to_charlist |> :pml_lexer.string |> elem(1) |> Enum.filter(fn(x) -> elem(x, 0) == :ident end
# [{:ident, 1, 'foo'}, {:ident, 2, 'bar'}, {:ident, 3, 'baz'}, {:ident, 12, 'baz2'}]
c-brenn commented 7 years ago

Exactly - TokenChars contains the exact string matched by the lexer. After the lex/parse we can iterate over the structure to find name clashes.

houli commented 7 years ago

Even just for this feature though, if we don't get the full AST ready we can just use the lexer output for now

houli commented 7 years ago

Oh, netbeans_req_release.pml has demonstrated to me that identifiers can just appear in requires, provides etc, what does it mean, who knows!

c-brenn commented 7 years ago

the ident token could be a variable or a construct name. We don't know which until we're in the bowels of the parser. The parser takes the all of the tokens from the lexer at once, and returns a single data structure. I don't think the parser can (or should) cause side effects, so it can only pass the name out as part of the AST.

laurmurclar commented 7 years ago

@shawa are you taking this now?

shawa commented 7 years ago

Sure I'll give it a lash yeah

shawa commented 7 years ago

150

c-brenn commented 7 years ago

clashes are now returned from panacea, this is just a UI change now