Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
About default options ':ratchet' and ':sigspace' on rules
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
scweng@gmail.com  
View profile  
 More options May 30 2006, 3:31 am
Newsgroups: perl.perl6.language
Followup-To: perl.perl6.language
From: "scw...@gmail.com" <scw...@gmail.com>
Date: 30 May 2006 00:31:36 -0700
Local: Tues, May 30 2006 3:31 am
Subject: About default options ':ratchet' and ':sigspace' on rules
Hello,

I'm implementing "MiniPerl6" in pugs which is the first step of
writing perl 6 parser in perl 6.  In module Pugs::Grammar::MiniPerl6,
 http://svn.openfoundry.org/pugs/misc/pX/Common/Pugs-Grammar-MiniPerl6,
I use another perl 6 grammar to describe it.  It works well several
days before when the parsing engine written in perl 5 did not
implemented :ratchet and :sigspace flags.

The grammar file can be found here:
http//svn.openfoundry.org/pugs/misc/pX/Common/Pugs-Grammar-MiniPerl6/lib/Pu gs/Grammar/MiniPerl6.grammar

The "token" part is fine, but the "rule" part is extremely ugly.  I can
not add additional spaces to format it.

I'd like to suggest two changes to make it easier to write rules:

  1. Spaces at beginning and end of rule blocks should be ignored
     since space before and after current rule are most likely be
     defined in rules using current one.
  1a. I'm not sure if it's "clear" to define as this, but the spaces
      around the rule-level alternative could also be ignored.  For
      instance, look at the rule FunctionAppExpr defined in
      MiniPerl6 grammar file.

        rule FunctionAppExpr
{<Variable>|<Constants>|<ArrayRef>|<FunctionName>[<?ws>?<'('><?ws>?<Paramet ers><')'>]?}

      I could not even put a new line in it.  In the file, since there
      are production rules, I put the brases on strange positions
      to format it better.

  2. I am not sure the default rule of <ws>, I couldn't found it in
     S05.  Currently the engine use :P5/\s+/ but I would like it to
     be :P/\s*/ when it's before or after non-words and remains
     the same (\s+) otherwise.

I do not subscribe this group but subscribe daily digest, so it's OK to
reply on the list.  Suggestions welcome!

Cheers,
Shu-Chun Weng


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shu-chun Weng  
View profile  
 More options Jun 2 2006, 2:17 am
Newsgroups: perl.perl6.language
From: s...@csie.org (Shu-chun Weng)
Date: Fri, 2 Jun 2006 14:17:25 +0800
Local: Fri, Jun 2 2006 2:17 am
Subject: About default options ':ratchet' and ':sigspace' on rules
Hello,

 (used to post on google group but found it does not deliver)

I'm implementing "MiniPerl6" in pugs which is the first step of
writing perl 6 parser in perl 6.  In module Pugs::Grammar::MiniPerl6,
 http://svn.openfoundry.org/pugs/misc/pX/Common/Pugs-Grammar-MiniPerl6,
I use another perl 6 grammar to describe it.  It works well several
days before when the parsing engine written in perl 5 did not
implemented :ratchet and :sigspace flags.

The grammar file can be found here:
http//svn.openfoundry.org/pugs/misc/pX/Common/Pugs-Grammar-MiniPerl6/lib/Pu gs/Grammar/MiniPerl6.grammar

The "token" part is fine, but the "rule" part is extremely ugly.  I can
not add additional spaces to format it.

I'd like to suggest two changes to make it easier to write rules:

  1. Spaces at beginning and end of rule blocks should be ignored
     since space before and after current rule are most likely be
     defined in rules using current one.
  1a. I'm not sure if it's "clear" to define as this, but the spaces
      around the rule-level alternative could also be ignored.  For
      instance, look at the rule FunctionAppExpr defined in
      MiniPerl6 grammar file.

        rule FunctionAppExpr
{<Variable>|<Constants>|<ArrayRef>|<FunctionName>[<?ws>?<'('><?ws>?<Paramet ers><')'>]?}

      I could not even put a new line in it.  In the file, since there
      are production rules, I put the brases on strange positions
      to format it better.

  2. I am not sure the default rule of <ws>, I couldn't found it in
     S05.  Currently the engine use :P5/\s+/ but I would like it to
     be :P/\s*/ when it's before or after non-words and remains
     the same (\s+) otherwise.

I do not subscribe this group but subscribe daily digest, so it's OK to
reply on the list.  Suggestions welcome!

Cheers,
Shu-Chun Weng


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Patrick R. Michaud  
View profile  
 More options Jun 2 2006, 10:03 am
Newsgroups: perl.perl6.language
From: pmich...@pobox.com (Patrick R. Michaud)
Date: Fri, 2 Jun 2006 09:03:18 -0500
Local: Fri, Jun 2 2006 10:03 am
Subject: Re: About default options ':ratchet' and ':sigspace' on rules

On Fri, Jun 02, 2006 at 02:17:25PM +0800, Shu-chun Weng wrote:
>  1. Spaces at beginning and end of rule blocks should be ignored
>     since space before and after current rule are most likely be
>     defined in rules using current one.
>  1a. I'm not sure if it's "clear" to define as this, but the spaces
>      around the rule-level alternative could also be ignored.  

At one point I had been exploring along similar lines, but at the
moment I'd say we don't want to do this.  See below for an example...

>      For instance, look at the rule FunctionAppExpr defined in
>      MiniPerl6 grammar file.

>        rule FunctionAppExpr
> {<Variable>|<Constants>|<ArrayRef>|<FunctionName>[<?ws>?<'('><?ws>?<Paramet ers><')'>]?}

FWIW, I'd go ahead and write this as a token statement instead of
a rule:

    token FunctionAppExpr {
        | <Variable>
        | <Constants>
        | <ArrayRef>
        | <FunctionName> [ <?ws> \( <?ws> <Parameters> \) ]?
    }

In fact, now that I've written the above I'm more inclined to say
it's not a good idea to ignore some whitespace in rule definitions
but not others.  Consider:

    rule FunctionAppExpr {
        | <Variable>
        | <Constants>
        | <ArrayRef>
        | <FunctionName>[ \( <Parameters> \) ]?
    }

Can we quickly determine where the <?ws> are being generated?
What if the [...] portion had an alternation in it?

(And, if we ignore leading/trailing whitespace in rule blocks, do
we also ignore leading/trailing whitespace in subpatterns?)

In a couple of grammars I've developed already (especially the
one used for pgc.pir), having whitespace at the beginning of rules
and around alternations become <?ws> is useful and important.
In these cases, ignoring such whitespace would mean adding explicit
<?ws> in the rule to get things to work.  At that point it feels like
waterbed theory -- by "improving" things for the FunctionAppExpr
rule above we're pushing the complexity somewhere else.

In general I'd say that in a production such as FunctionAppExpr
where there are just a few places that need <?ws>, then it's
better to use 'token' and explicitly indicate the allowed
whitespace.

(Side observation: in  ...|<FunctionName>[<?ws>?<'('><?ws>?<Parameters><')'>]?}
above, there's no whitespace between <Parameters> and the closing paren.
Why not?)

>  2. I am not sure the default rule of <ws>, I couldn't found it in
>     S05.  Currently the engine use :P5/\s+/ but I would like it to
>     be :P/\s*/ when it's before or after non-words and remains
>     the same (\s+) otherwise.

PGE does the "\s* when before or after non-words and \s+ otherwise"
explicitly in its <ws> rule, which is written in PIR.  (Being able
to write subrules procedurally is I<really> nice.)  

In P5 it'd probably be something like

    (?:(?<!\w)|(?!\w))\s*|\s+

or maybe better is

    (?:(?<!\w)|(?!\w)|\s)\s*

Pm


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Shu-Chun Weng  
View profile  
 More options Jun 3 2006, 3:03 am
Newsgroups: perl.perl6.language
From: s...@csie.org (Shu-Chun Weng)
Date: Sat, 3 Jun 2006 15:03:22 +0800
Local: Sat, Jun 3 2006 3:03 am
Subject: Re: About default options ':ratchet' and ':sigspace' on rules
Hi,

Thanks for the comments :)

I'll then rewrite most of my rules into tokens.  And about the
definition of <?ws>, the "engine" I mentioned is Pugs::Complier::Rule,
so that if what PGE does is considered the "correct" way, I will
change the behavior of P::C::Rule.  By the way, if someone can add
it to S05 would make me more comfortable.

Shu-Chun Weng


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Audrey Tang  
View profile  
 More options Jun 3 2006, 10:12 am
Newsgroups: perl.perl6.language
From: audr...@audreyt.org (Audrey Tang)
Date: Sat, 3 Jun 2006 22:12:25 +0800
Local: Sat, Jun 3 2006 10:12 am
Subject: Re: About default options ':ratchet' and ':sigspace' on rules

在 2006/6/3 下午 3:03 時,Shu-Chun Weng 寫到:

> I'll then rewrite most of my rules into tokens.  And about the
> definition of <?ws>, the "engine" I mentioned is Pugs::Complier::Rule,
> so that if what PGE does is considered the "correct" way, I will
> change the behavior of P::C::Rule.

Yes, please do. :-)

> By the way, if someone can add
> it to S05 would make me more comfortable.

Done as r9442.

Cheers,
Audrey


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google