Make an exact parser
daviwesley opened this issue · 2 comments
I am using the following code
import NimbleParsec
# Type ::= "int" "[" "]" | "boolean" | "int" | Identifier
array_int = string("int []") |> label("int[]")
int = string("int") |> label("int")
bool = string("boolean") |> label("boolean")
defparsec(:types, choice([array_int, int, bool]))
When I test the using int
it says ok but when I test using intd
it is still saying ok, but I want to catch the exact word int
and reject any variation like intd, intuiw, intc...
, how can I achieve this?
Hi @daviwesley, can you please post to the Elixir Forum for general questions? More people there will be available to help. When you do so, also include examples of how you are calling the code and which results you are getting and what result you expect. The more information, the better. For your particular problem, you may want to look at eos
, end_of_string
or similar (I don't fully recall the name).
hi @josevalim , I have posted on Elixir Forum and your suggestion is right, I used eos()
and worked fine :)