|Re: [asciidoc-lang-dev] Whitespace handling|
On 07/03/2021 02:11, Lex Trotman wrote:> On Fri, 5 Mar 2021 at 23:30,
Sylvain Leroux <sylvain@xxxxxxxxxxx
> <mailto:sylvain@xxxxxxxxxxx>> wrote:
> On 03/03/2021 02:14, Lex Trotman wrote:
> > Interesting question since the spacing is context, not part of the
> > markup itself, just like the character on the other side.
> Correct. In my own experiments, to identify the context, I used the
> lookahead/lookbehind features of the Parsing _expression_ grammar
> ) I implemented. This adds some "context sensibility" on top of an
> otherwise context-free grammar.
> : http://www.inf.puc-rio.br/%7Eroberto/docs/peg.pdf
> Yes, I'm also using a PEG, but for my experiments I separated the lexer
> (LEG) and the parser (PEG) so there can be a clear table of markup
> tokens. Those tokens do indeed have copious uses of previous and
> following non-consuming operators :-).
> I have found I needed to extend the PEG to handle nesting of sections
> and lists without writing out a limited depth set, how do you address it?
For now, I use two separate PEGs. One is for the inline parser, the
other one for block-level parsing.
The PEG for the inline parser is quite stable, and I don't encounter
significant difficulties when adding new features.
The PEG for the block-level parsing is a different beast, though. It
replaces a (multiple times rewrote) hand-written parser. For now, it is
used as a tokenizer rather than a recursive descent parser. And the
actual block hierarchy construction is delegated to a stateful object in
the spirit of the factory method pattern
I tried to implement a recursive grammar for the block-level parser. But
I struggled at finding a way to match the delimiter in nested blocks
I suspect there is an elegant way of doing that since PEG "can count",
but I yet have to find how. FWIW, I discovered PEG with this project, so
my knowledge of the technology is still fragile.
asciidoc-lang-dev mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
Back to the top