0

I'm tryingto make a parser with PegJS

I'm trying to parse something like this..

I would like to email john@gmail.com today or tomorrow.

How would you make a parser that matches on certain phrases, like email john@gmail.com and throw away the surrounding characters and space (if they exists).

The problem I keep having is that is the matchers consume the whole line, phrase and all—before more detailed matchers have a chance to go.

Also, can someone break down negative look aheads? (the mechanics and there syntax)
It seems they are the answer, but I'm having a hard time find information on them.

Thank you,
Geo.

ebohlman
  • 14,795
  • 5
  • 33
  • 35
GN.
  • 8,672
  • 10
  • 61
  • 126

1 Answers1

1

Ok I figured it out. This work.

find_tokens = 
 (!tokens .)* 
 result: (token: tokens { return token; })
 (!tokens .)*
 { return result; }
GN.
  • 8,672
  • 10
  • 61
  • 126