Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling a token "text", "null" or "ws" in Rakudo makes matching fail #231

Closed
p6rt opened this issue Aug 12, 2008 · 7 comments
Closed

Calling a token "text", "null" or "ws" in Rakudo makes matching fail #231

p6rt opened this issue Aug 12, 2008 · 7 comments

Comments

@p6rt
Copy link

p6rt commented Aug 12, 2008

Migrated from rt.perl.org#57864 (status was 'resolved')

Searchable as RT57864$

@p6rt
Copy link
Author

p6rt commented Aug 12, 2008

From @masak

r30183​:
$ ./perl6 -e 'grammar A { token TOP { <foo> }; token foo { d } }; "d"
~~ A​::TOP' # works
$ ./perl6 -e 'grammar A { token TOP { <text> }; token text { d } };
"d" ~~ A​::TOP' # fails!
Null PMC access in type()
[...]

Same goes for 'rule text' or 'regex test'. My uneducated guess is that
something inside PGE is called 'text' and clashes.

@p6rt
Copy link
Author

p6rt commented Sep 14, 2008

From @pmichaud

On Tue Aug 12 11​:58​:42 2008, masak wrote​:

r30183​:
$ ./perl6 -e 'grammar A { token TOP { <foo> }; token foo { d } }; "d"
~~ A​::TOP' # works
$ ./perl6 -e 'grammar A { token TOP { <text> }; token text { d } };
"d" ~~ A​::TOP' # fails!
Null PMC access in type()
[...]

Same goes for 'rule text' or 'regex test'. My uneducated guess is that
something inside PGE is called 'text' and clashes.

You're correct -- .text is a method on Match objects (see S05), and at
the moment that tends to conflict with any rules named 'text' in a
grammar. This may be fixed when we convert PGE to generate multimethods
for regexes instead of normal methods, but ultimately there's a deep
underlying conflict with Match methods and grammar methods that we'll
need to resolve somehow.

Thanks,

Pm

@p6rt
Copy link
Author

p6rt commented Sep 14, 2008

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Nov 1, 2008

From @chrisdolan

On Sun Sep 14 07​:51​:56 2008, pmichaud wrote​:

You're correct -- .text is a method on Match objects (see S05), and at
the moment that tends to conflict with any rules named 'text' in a
grammar. This may be fixed when we convert PGE to generate multimethods
for regexes instead of normal methods, but ultimately there's a deep
underlying conflict with Match methods and grammar methods that we'll
need to resolve somehow.

It seems to be Regex.pir that is taking all of the invocations. I have
discovered that, beyond <text>, I cannot create tokens/rules named
"null", "ws", etc. The latter is particularly problematic in writing
parsers in Perl6. The following simple example shows the failure​:

grammar WSOverride {
  token TOP { <tok_foo> <.ws> <tok_bar> };
  token tok_foo { foo };
  token tok_bar { bar };
  token ws { [ \h | \v | '%' ]+ };
}

ok('foo bar' ~~ WSOverride​::TOP); # succeeds
ok("foo\nbar" ~~ WSOverride​::TOP); # succeeds
ok("foo%%%\nbar" ~~ WSOverride​::TOP); # fails

@p6rt
Copy link
Author

p6rt commented Nov 6, 2008

From @pmichaud

On Fri, Oct 31, 2008 at 08​:47​:09PM -0700, Chris Dolan via RT wrote​:

It seems to be Regex.pir that is taking all of the invocations. I have
discovered that, beyond <text>, I cannot create tokens/rules named
"null", "ws", etc. The latter is particularly problematic in writing
parsers in Perl6. The following simple example shows the failure​:

grammar WSOverride {
token TOP { <tok_foo> <.ws> <tok_bar> };
token tok_foo { foo };
token tok_bar { bar };
token ws { [ \h | \v | '%' ]+ };
}

ok('foo bar' ~~ WSOverride​::TOP); # succeeds
ok("foo\nbar" ~~ WSOverride​::TOP); # succeeds
ok("foo%%%\nbar" ~~ WSOverride​::TOP); # fails

First, note that C< 'foo bar' ~~ WSOverride​::TOP > isn't
really the correct syntax for invoking a rule -- but the
synopses don't really specify what the correct syntax is yet.
At the moment we do know that it's not likely to be
C< 'foo' ~~ Grammar​::rule >.

Beyond that, the problem appears to be that Rakudo is not
presently creating its grammars properly -- it appears to
be deriving them directly from Any instead of from a PGE
grammar class of some sort. As a result, inheritance and
method dispatch don't seem to be working quite properly,
and we'll need to get that fixed.

Pm

@p6rt
Copy link
Author

p6rt commented May 7, 2009

From @masak

Resolving this ticket, since the original problem seems to have been solved.

Beyond that, the problem appears to be that Rakudo is not
presently creating its grammars properly -- it appears to
be deriving them directly from Any instead of from a PGE
grammar class of some sort. As a result, inheritance and
method dispatch don't seem to be working quite properly,
and we'll need to get that fixed.

Ticket [perl #​65474] covers this issue, along with an example of what fails.

@p6rt
Copy link
Author

p6rt commented May 7, 2009

@masak - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed May 7, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant