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

Implement Texas quotes («») in Rakudo #417

Closed
p6rt opened this issue Nov 19, 2008 · 7 comments
Closed

Implement Texas quotes («») in Rakudo #417

p6rt opened this issue Nov 19, 2008 · 7 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Nov 19, 2008

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

Searchable as RT60670$

@p6rt
Copy link
Author

p6rt commented Nov 19, 2008

From @masak

Rakudo r32873 cannot parse the Unicode version of Texas quotes («»),
and misunderstands the ASCII-friendly variant (<<>>).

$ ./perl6 -e 'say <a $b c>.perl'
["a", "\$b", "c"]
$ ./perl6 -e 'my $b = "foo"; say <<a $b c>>.perl'
1
$ ./perl6 -e 'my $b = "foo"; say «a $b c».perl'
Statement not terminated properly at line 1, near "\x{ab}a $b c\x{c2}\x{bb}."
[...]

@p6rt
Copy link
Author

p6rt commented Nov 19, 2008

From @moritz

On Wed Nov 19 07​:23​:37 2008, masak wrote​:

Rakudo r32873 cannot parse the Unicode version of Texas quotes («»),
and misunderstands the ASCII-friendly variant (<<>>).

$ ./perl6 -e 'say <a $b c>.perl'
["a", "\$b", "c"]
$ ./perl6 -e 'my $b = "foo"; say <<a $b c>>.perl'
1

That actually parses as a quote with contents '<a $b c', numerically
compared to (>) $_.perl.

$ ./perl6 -e 'my $b = "foo"; say <<a $b c>.perl'
["<a", "\$b", "c"]

I don't see a simple way to use a multi character separator to the rule
quote_expression.

$ ./perl6 -e 'my $b = "foo"; say «a $b c».perl'
Statement not terminated properly at line 1, near "\x{ab}a $b
c\x{c2}\x{bb}."
[...]

There's a commented out rule for this in src/parser/grammar.pg, line 716​:

  # | <.before '«' > <quote_expression​: :ww :qq> FIXME​: unicode

With that rule it still dies with the same error message.

So no trivial one-line fix :/

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Nov 19, 2008

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

@p6rt
Copy link
Author

p6rt commented Nov 25, 2008

From @pmichaud

On Wed, Nov 19, 2008 at 07​:23​:38AM -0800, Carl Mäsak wrote​:

Rakudo r32873 cannot parse the Unicode version of Texas quotes («»),
and misunderstands the ASCII-friendly variant (<<>>).

$ ./perl6 -e 'say <a $b c>.perl'
["a", "\$b", "c"]
$ ./perl6 -e 'my $b = "foo"; say <<a $b c>>.perl'
1
$ ./perl6 -e 'my $b = "foo"; say «a $b c».perl'
Statement not terminated properly at line 1, near "\x{ab}a $b c\x{c2}\x{bb}."
[...]

The ASCII versions of some of these are now added in r33209.

First, the texas quotes "work" except they don't properly split
interpolated values (I need to check into this). Thus​:

$ ./parrot perl6.pbc

my $b = 'foo'; say < a $b c >.perl;
["a", "\$b", "c"]
my $b = 'foo'; say << a $b c >>.perl;
["a", "foo", "c"]
my $b = 'foo'; say << a "$b $b" c >>.perl;
["a", "foo foo", "c"]
my $b = 'foo'; say << a '$b' c >>.perl;
["a", "\$b", "c"]
my $b = 3; say << a { $b + 4 } c >>.perl;
["a", "7", "c"]

Here's a case that doesn't yet work -- the interpolated value
isn't properly split.

my $b = 'foo bar'; say << a $b c >>.perl;
["a", "foo bar", "c"] # wrong

And, of course, as with double-quoted strings we aren't
interpolating arrays or hashes yet, but that will come soon.
(In the meantime one can use curlies to interpolate them.)

As a bonus, the multiple-bracket-quote variants of q also work now​:

say q << String with > in it. >>.perl;
" String with > in it. "
say q <<< String with >> and > in it. >>>.perl;
" String with >> and > in it. "
say qw << Word quoting <things> >>.perl;
["Word", "quoting", "<things>"]

We don't yet handle nested brackets, though -- I'll
wait for the full STD.pm-based quote parser for that.

The « French quotes » will need some slight modification to PGE
to be able to properly handle unicode strings in the grammar.
I'm not quite certain why it's not working already, but it should
be a relatively simple fix, and once it's in (and we have tests)
I think we can close this ticket.

Pm

@p6rt
Copy link
Author

p6rt commented Jan 26, 2009

From @masak

This still doesn't work on r35994, but gives a different error message​:

$ perl6 -e 'my $b = "foo"; say «a $b c».perl'
say requires an argument at line 1, near " \x{c2}\x{ab}a $b c\x{c2}"
[...]

@p6rt
Copy link
Author

p6rt commented Jun 2, 2009

From @pmichaud

This now works as of fc01cda. Closing ticket.

Pm

@p6rt
Copy link
Author

p6rt commented Jun 2, 2009

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

@p6rt p6rt closed this as completed Jun 2, 2009
@p6rt p6rt added the Todo label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant