Closed houli closed 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'}]
Exactly - TokenChars
contains the exact string matched by the lexer. After the lex/parse we can iterate over the structure to find name clashes.
Even just for this feature though, if we don't get the full AST ready we can just use the lexer output for now
Oh, netbeans_req_release.pml
has demonstrated to me that identifiers can just appear in requires, provides etc, what does it mean, who knows!
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.
@shawa are you taking this now?
Sure I'll give it a lash yeah
clashes are now returned from panacea, this is just a UI change now
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