Creating a REPL

32 views
Skip to first unread message

Mike Austin

unread,
May 21, 2017, 4:31:16 AM5/21/17
to PEG.js: Parser Generator for JavaScript
My language is working great, so now I'd like to write a simple REPL. A REPL is a little different in that it usually reads one statement at a time. It also handles multiple lines differently when inputting functions for example. I've got a few questions:

Should I break down rules into REPLable chunks? Should I use a separate grammar file? Also, only peg$parse is exported. How should I call peg$parseSourceElement() for example?

Thanks!
Mile

Guilherme Vieira

unread,
May 21, 2017, 10:02:54 PM5/21/17
to Mike Austin, PEG.js: Parser Generator for JavaScript
Hi, Mike. Take a look at the allowedStartRules option of PegJS' generate function, that might help you keep the REPL and the module grammar the same.

Atenciosamente / Sincerely,
Guilherme Prá Vieira


--
You received this message because you are subscribed to the Google Groups "PEG.js: Parser Generator for JavaScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pegjs+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mike Austin

unread,
May 22, 2017, 2:02:34 AM5/22/17
to PEG.js: Parser Generator for JavaScript, mike.aus...@gmail.com
Ahh, good idea. Thanks, I'll try that!
To unsubscribe from this group and stop receiving emails from it, send an email to pegjs+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages