Re: [Google Groups] Looking for help "Shift-Reduce Conflict"

67 views
Skip to first unread message

Dave Dolan

unread,
Mar 29, 2013, 8:07:33 PM3/29/13
to gold-pars...@googlegroups.com
The purpose of the grammar is to get the text into usable chunks.  You don't have to actually name production what the thing is. For example, don't bother creating <numeric_literal>, just use Number, don't create <variable_name> just use Identified.  Same with <char_literal> and quoted_string.  Having a non-terminal that ::= a single terminal will always produce a shift reduce conflict when it can be used in multiple places.

For example I fix this one for you (there are probably a few more changes yet you'll need to make but this should give you an idea of what I mean.)

  <num_factor> ::= Number   |  '(' <num_expression ')' | Identified


On Wed, Mar 20, 2013 at 12:24 AM, Chon Teh <tehbc....@gmail.com> wrote:
Hi
 
i am new to grammer,
I try to convert the below plsql_expresstion to gold grammer
 
After add in <char_expression> to <plsql_expression>, the
Test data:       value1 := v1 + v2;    become invalid.
 
That should be the confict for <variable_name> in <char_term> and <num_factor>.
 
Please advices.
 
Thank
 
Source
============
"Case Sensitive" = False
"Start Symbol"   = <Statements>
{String Ch 1}      = {Printable} - ["]
{String Ch 2}      = {Printable} - ['']
Number              =    {Digit}+('.'{Digit}+)?('.'?E[+-]?{Digit}+)?
quoted_string       =  ''{String Ch 2}*''
Identified          = {Letter}{AlphaNumeric}*

<Statements> ::= <assignment_statement>
<assignment_statement>  ::= Identified ':=' <plsql_expression> ';'

<plsql_expression>  ::= <num_expression>
                    | <char_expression>
                   
<num_expression> ::= <num_expression> <sign> <num_term>
                | <opt sign> <num_term>
<char_expression> ::= <char_expression> '||' <char_term>
                   | <char_term>
<char_term> ::= <char_literal>
             | <variable_name>
             | '(' <char_expression> ')'
             | 'NULL'
            
                                
<num_term> ::= <num_term> <Multi Exp> <num_factor>
            | <num_factor>
<opt sign> ::= <sign>
            |
<sign>  ::= '+'
         | '-'
        
<Multi Exp> ::= '*'
             |  '\'
                          
<num_factor>   ::= <numeric_literal>
                | '(' <num_expression> ')'
                | <variable_name>
               
<numeric_literal> ::= Number
<variable_name>     ::= Identified
<char_literal> ::= quoted_string                    
 

--
You received this message because you are subscribed to the Google Groups "GOLD Parsing System" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gold-parsing-sy...@googlegroups.com.
To post to this group, send email to gold-pars...@googlegroups.com.
Visit this group at http://groups.google.com/group/gold-parsing-system?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
---------------------------------------------------------------
Dave Dolan
http://davedolan.com/blog

Dave Dolan

unread,
Mar 29, 2013, 8:12:08 PM3/29/13
to gold-pars...@googlegroups.com
I didn't explain it all completely: A Shift-Reduce = when it can't decide whether or not to consume another token (to break a tie between two possibilities) or to 'reduce' and call it a match leaving the next token for the next production.   Usually it will attempt to 'fix' these by defaulting to "Shift".  This may not be the right action. Try it out and see if it still works for you. Sometimes you can ignore Shift-Reduces

Chon Teh

unread,
Apr 16, 2013, 11:11:42 PM4/16/13
to gold-pars...@googlegroups.com
Hi all,
Thank a lot for advice and information.
That is very helpful
 
Regards
Teh
Reply all
Reply to author
Forward
0 new messages