-
I was trying to write a simple python-like grammar using this library. The grammar depends on detecting indentation and dedentation, like how Python does it. I can detect indentation with |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
This is non-trivial, see the corresponding discussions on Stack Overflow: https://stackoverflow.com/questions/4205442/peg-for-python-style-indentation, https://stackoverflow.com/questions/11659095/parse-indentation-level-with-peg-js I have not tried to do it myself with PetitParser, but know that other people have successfully written grammars for Markdown, Python and the like: http://scg.unibe.ch/research/indentParsing (the examples given here are for the Smalltalk version of this library). |
Beta Was this translation helpful? Give feedback.
-
With d03b23b I've committed initial support to make indentation based grammars easier (they are still complicated). The implementation is based on the ideas of https://stackoverflow.com/a/56926044/82303. |
Beta Was this translation helpful? Give feedback.
This is non-trivial, see the corresponding discussions on Stack Overflow: https://stackoverflow.com/questions/4205442/peg-for-python-style-indentation, https://stackoverflow.com/questions/11659095/parse-indentation-level-with-peg-js
I have not tried to do it myself with PetitParser, but know that other people have successfully written grammars for Markdown, Python and the like: http://scg.unibe.ch/research/indentParsing (the examples given here are for the Smalltalk version of this library).