Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Question to the list: BNF interface notation
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
 
rns  
View profile  
 More options Nov 5 2012, 1:31 pm
From: rns <sor...@gmail.com>
Date: Mon, 5 Nov 2012 10:31:58 -0800 (PST)
Local: Mon, Nov 5 2012 1:31 pm
Subject: Re: Question to the list: BNF interface notation

Sounds good. One question: how about adding a question mark

sum ::= term (op_add)*?* term  action => do_addition

to specify that the symbols enclosed in parent are optional? This would sit
well with your intent to introduce parens for grouping, too.

On Monday, November 5, 2012 8:27:01 PM UTC+2, Jeffrey Kegler wrote:

>  I intend in the BNF interface to introduce parentheses, which will
> indicate that the semantics do not see the enclosed symbols.  This can be
> seen a generalization of the current keep/discard separators issue in
> sequences.  I need this generalization is needed for some other features I
> am working on.

> What I intend is that, for example, in the rule

> sum ::= term (op_add) term  action => do_addition

> the semantics would see the two 'term' values, but would not see the
> op_add.  You'd write the semantics like this:

> do_addition {
>    my (undef, $a, $b) = @_;
>    return $a + $b;
> }

> On the other hand if the rule were written as follows

> sum ::= term op_add term  action => do_addition

> the traditional semantics would be written

> do_addition {
>    my (undef, $a, undef, $b) = @_;
>    return $a + $b;
> }

> Reasons for the discard-if-parenthesized convention:  Parenthesis
> traditionally suggest hidden or optional.  Also, I may allow parentheses
> for grouping, in which case the semantics of the parenthesized part would
> become quite complex.  If an alternative to discarding a complex
> parenthesized group was allowed, it would need special additional notation
> anyway.

> Possible reasons to dislike it:  In Perl 5 regexes, parentheses by default
> mean capture and, for regexes, capture is roughly analogous to semantic
> visibility.  I regret breaking from the Perl convention, but parentheses in
> Perl regexes *are* ugly and semantically overloaded, and I think the
> notation suggested above will be more graceful.

> Feedback from this list has changed my mind in the past, and I'd like to
> hear from you.

> -- jeffrey


 
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.