Re: "rule" declarator: Different results for 'unadorned' match vs unnamed/named captures? (in re Grammars...).

2021-03-12 Thread Ralph Mellor
On Thu, Mar 11, 2021 at 8:53 PM William Michels wrote: > > I think there's something going on with the examples below, as I'm > seeing different results when comparing a basic "rule" match vs either > unnamed or named "rule" captures. All your examples are correct according to my current understa

"rule" declarator: Different results for 'unadorned' match vs unnamed/named captures? (in re Grammars...).

2021-03-11 Thread William Michels via perl6-users
Hello, I've been chatting with raiph on SO regarding Grammar "tokens" vs "rules". The OP is here https://stackoverflow.com/q/62051742 and our discussion is here https://stackoverflow.com/a/62053666 . I think there's something going on with the examples below, as I'm seeing different results when

Re: grammars and indentation of input

2016-09-13 Thread Theo van den Heuvel
As so often it turned out that the reason my program did not work was elsewhere (in the grammar). My approach worked al along. It was instructive to look at the examples you guys mentioned. Thanks Theo

Re: Fwd: Re: grammars and indentation of input

2016-09-13 Thread Bennett Todd
Well put. The clearest description of Python's approach I've read, explained it as a lexer that tracked indentation level, and inserted appropriate tokens when it changed.

Re: Fwd: Re: grammars and indentation of input

2016-09-13 Thread Aaron Sherman
Oh, a side point: there's some confusion introduced by the lack of a scanner/lexer in modern all-in-one-parsers. Python, for example, uses a scanner and so its grammar is nominally not context sensitive, but its scanner very much is (maintaining a stack of indentation exactly as OP was asking abou

Re: grammars and indentation of input

2016-09-13 Thread Moritz Lenz
Hi, On 13.09.2016 18:55, Patrick R. Michaud wrote: > I don't have an example handy, but I can categorically say that > Perl 6 grammars are designed to support exactly this form of parsing. > It's almost exactly what I did in "pynie" -- a Python implementation > on top of Perl 6. The parsing was d

Re: grammars and indentation of input

2016-09-13 Thread Patrick R. Michaud
I don't have an example handy, but I can categorically say that Perl 6 grammars are designed to support exactly this form of parsing. It's almost exactly what I did in "pynie" -- a Python implementation on top of Perl 6. The parsing was done using a Perl 6 grammar. If I remember correctly, Pynie

Re: Fwd: Re: grammars and indentation of input

2016-09-13 Thread Bennett Todd
Hostile or not, thanks for your informative reply.

Re: Fwd: Re: grammars and indentation of input

2016-09-13 Thread Bennett Todd
Thank you, very much. Yes, I'm disappointed, but I'd rather know.

Re: Fwd: Re: grammars and indentation of input

2016-09-13 Thread Aaron Sherman
> > Having the minutia of the programmatic run-time state of the parse then > influence the parse itself, is at the heart of the perl5 phenomenon "only > Perl can parse perl" I don't mean to be hostile, but you're demonstrably wrong, here. (also it's "only perl can parse Perl" as in, only the "pe

Re: Fwd: Re: grammars and indentation of input

2016-09-13 Thread Patrick R. Michaud
On Tue, Sep 13, 2016 at 10:35:01AM -0400, Bennett Todd wrote: > Having the minutia of the programmatic run-time state of the parse then > influence the parse itself, is at the heart of the perl5 phenomenon "only > Perl can parse perl", which I rather hope isn't going to be preserved in > perl6.

Re: Fwd: Re: grammars and indentation of input

2016-09-13 Thread Theo van den Heuvel
Hi Bennett, There are many situations that require non-contextfree languages. Even though much of these could be solved in the AST-building step (called 'transduction' in my days) instead of the parsing step, that does not solve all cases. I am just wondering if and to what extent we can parse

Re: Fwd: Re: grammars and indentation of input

2016-09-13 Thread Bennett Todd
Having the minutia of the programmatic run-time state of the parse then influence the parse itself, is at the heart of the perl5 phenomenon "only Perl can parse perl", which I rather hope isn't going to be preserved in perl6.

Fwd: Re: grammars and indentation of input

2016-09-13 Thread Theo van den Heuvel
Thanks Timo and Brian, both examples are educational. However, they have a common limitation in that they both perform their magic after a Match object has been created. I was trying to influence the parsing step itself. I am experimenting to find if I can influence the parsing process progr

Re: grammars and indentation of input

2016-09-13 Thread Aaron Sherman
I don't see why optimization would frustrate this approach. You are doing the correct thing as far as I can tell, but with one exception. The current implementation (last I checked) was sometimes slow in binding values. You might need to force it between an assignment and passing a bound match as a

Re: grammars and indentation of input

2016-09-13 Thread Brian Duggan
I've also recently been experimenting with parsing an indent-based language -- specifically, a small subset of Slim () -- I push to a stack when I see a tag, and pop based on the depth of the indendation. Here's a working example: https://git.io/vig93 Brian

Re: grammars and indentation of input

2016-09-13 Thread Timo Paulssen
I haven't read your code, but your question immediately made me think of this module: https://github.com/masak/text-indented Would be interested to hear if this helps you! - Timo

Re: Grammars

2015-04-20 Thread Larry Wall
On Sun, Apr 19, 2015 at 06:31:30PM +0200, mt1957 wrote: : L.s., : : I found a small problem when writing a piece of grammar. A : simplified part of it is shown here; : ... : token tag-body { ~ } : token body-start { '[' } : token body-end { ']' } : token body-text { .*? } : ... : A coupl

Re: Grammars and biological data formats

2014-08-09 Thread Fields, Christopher J
On Aug 9, 2014, at 8:51 PM, "Fields, Christopher J" wrote: > > >> On Aug 9, 2014, at 5:25 PM, "t...@wakelift.de" wrote: >> >> >>> On 08/10/2014 12:21 AM, t...@wakelift.de wrote: >>> Something that does surprise me is that your tests seem to imply that :p >>> for subparse doesn't work. I'll l

Re: Grammars and biological data formats

2014-08-09 Thread Fields, Christopher J
> On Aug 9, 2014, at 5:25 PM, "t...@wakelift.de" wrote: > > >> On 08/10/2014 12:21 AM, t...@wakelift.de wrote: >> Something that does surprise me is that your tests seem to imply that :p >> for subparse doesn't work. I'll look into that, because I believe it >> ought to be implemented already.

Re: Grammars and biological data formats

2014-08-09 Thread Darren Duncan
I've already been thinking for awhile now that parsers need to be able to operate in a streaming fashion (when the grammars lend themselves to it, by not needing to lookahead, much if at all, to understand what they've already seen) so that strings that don't fit in memory all at once can be par

Re: Grammars and biological data formats

2014-08-09 Thread timo
On 08/10/2014 12:21 AM, t...@wakelift.de wrote: > Something that does surprise me is that your tests seem to imply that :p > for subparse doesn't work. I'll look into that, because I believe it > ought to be implemented already. Perhaps not properly hooked up, though. On #perl6 I got corrected qu

Re: Grammars and biological data formats

2014-08-09 Thread timo
(accidentally sent this privately only, now re-sending to the list) Hello Christopher, In the Perl 6 specification, there are plans for lazy and memory-releasing ways to parse strings that are either too large to fit into memory at once or that are generated lazily (like being streamed in through