[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Odd parser behaviour
From: |
Tim Van Holder |
Subject: |
Re: Odd parser behaviour |
Date: |
Mon, 25 Sep 2006 11:55:33 +0200 |
User-agent: |
Thunderbird 1.5.0.7 (Windows/20060909) |
Heiko Wundram wrote:
> Am Montag, 25. September 2006 10:34 schrieb Tim Van Holder:
>> If seeing a portion of the actual grammar where I encountered the
>> behaviour would be clearer, let me know and I'll post it.
>
> Sure, please post that.
I consider the topic more or less closed now, but here goes anyway:
Applied to my real grammar (portion reproduced below), the problem is
that bison should accept
MODIFY MAP FOO FOR DFLD BAR ATTRIBUTES BRIGHT
COMPUTE A = B
but instead it errored out on the COMPUTE during modification_option
(the "opt_ERROR opt_MESSAGE opt_IS active_or_suppress" path).
The grammar has since been changed to replace
| opt_ERROR opt_MESSAGE opt_IS active_or_suppress
with
| t_ERROR opt_MESSAGE opt_IS active_or_suppress
| t_MESSAGE opt_IS active_or_suppress
| t_IS active_or_suppress
| active_or_suppress
(with associated actions to build the correct AST).
Using a * rule instead of + for modification_option, as you originally
suggested would mean
MODIFY MAP FOO FOR DFLD BAR
could be accepted, which is not allowed by the syntax.
Grammar fragment:
%start dml_element
%%
dml_element
: ...
| statement
{
...
YYACCEPT
}
| ...
;
statement
: ...
| modify_statement
| ...
;
// <modify-statement> := MODIFY ...
// | MOFIFY MAP <simple-identifier>
// (PERMANENT | TEMPORARY)? <for-fields-clause>?
// '.'?
// | MODIFY ...
modify_statement
: t_MODIFY ...
| t_MODIFY t_MAP simple_identifier opt_permanent_or_temporary
opt_for_fields_clause opt_period
| t_MODIFY ...
;
opt_permanent_or_temporary
: // empty
| t_PERMANENT
| t_TEMPORARY
;
// <for-fields-clause> := FOR <fields-specification> <modification-option>+
opt_for_fields_clause
: // empty
| t_FOR fields_specification plus_modification_option
;
// <fields-specification> := CURRENT
// | ALL FIELDS
// | ALL (BUT | EXCEPT) CURRENT
// | ALL (CORRECT | ERROR) FIELDS
// | ALL? <simple-dfld-specification>+
// | ALL? (BUT | EXCEPT)
<simple-dfld-specification>+
fields_specification
: t_CURRENT
| t_ALL t_FIELDS
| t_ALL but_or_except t_CURRENT
| t_ALL correct_or_error t_FIELDS
| opt_ALL plus_simple_dfld_specification
| t_ALL but_or_except plus_simple_dfld_specification
| but_or_except plus_simple_dfld_specification
;
opt_ALL
: // empty
| t_ALL
;
but_or_except
: t_BUT
| t_EXCEPT
;
correct_or_error
: t_CORRECT
| t_ERROR
;
plus_modification_option
: modification_option
| plus_modification_option modification_option
;
// <modification-option> := (BACKSCAN | NOBACKSCAN)
// | OUTPUT DATA IS?
// (YES | NO | ERASE | ATTRIBUTE)
// | INPUT DATA IS? (YES | NO)
// | (RIGHT | LEFT) JUSTIFY
// | PAD <variable-name-or-string-literal>
// | PAD (LOW-VALUE | HIGH-VALUE)
// | EDIT IS? (ERROR | CORRECT)
// | (REQUIRED | OPTIONAL)
// | ERROR? MESSAGE? IS? (ACTIVE | SUPPRESS)
// | ATTRIBUTES <attribute>+
modification_option
: backscan_or_nobackscan
| t_OUTPUT t_DATA opt_IS yes_no_erase_or_attribute
| t_INPUT t_DATA opt_IS yes_or_no
| right_or_left t_JUSTIFY
| t_PAD variable_name_or_string_literal
| t_PAD low_value_or_high_value
| t_EDIT opt_IS correct_or_error
| required_or_optional
| opt_ERROR opt_MESSAGE opt_IS active_or_suppress
| t_ATTRIBUTES plus_attribute
;
backscan_or_nobackscan
: t_BACKSCAN
| t_NOBACKSCAN
;
right_or_left
: t_RIGHT
| t_LEFT
;
required_or_optional
: t_REQUIRED
| t_OPTIONAL
;
active_or_suppress
: t_ACTIVE
| t_SUPPRESS
;
opt_ERROR
: // empty
| t_MESSAGE
;
opt_MESSAGE
: // empty
| t_MESSAGE
;
plus_attribute
: attribute
| plus_attribute attribute
;
// <attribute> := SKIP
// | (ALPHAMERIC | NUMERIC)
// | (PROTECTED | UNPROCTECTED)
// | (DISPLAY | DARK | BRIGHT)
// | DETECT
// | (MDT | NOMDT)
// | (BLINK | NOBLINK)
// | (REVERSE-VIDEO | NORMAL-VIDEO)
// | (UNDERSCORE | NOUNDERSCORE)
// | (BLUE | RED | PINK | GREEN | TURQUOISE | YELLOW |
// WHITE | NOCOLOR)
attribute
: t_SKIP
| t_ALPHAMERIC
| t_NUMERIC
| t_PROTECTED
| t_UNPROTECTED
| t_DISPLAY
| t_DARK
| t_BRIGHT
| t_DETECT
| t_MDT
| t_NOMDT
| t_BLINK
| t_NOBLINK
| t_REVERSE_VIDEO
| t_NORMAL_VIDEO
| t_UNDERSCORE
| t_NOUNDERSCORE
| t_BLUE
| t_RED
| t_PINK
| t_GREEN
| t_TURQUOISE
| t_YELLOW
| t_WHITE
| t_NOCOLOR
;
- Odd parser behaviour, Tim Van Holder, 2006/09/24
- Re: Odd parser behaviour, Heiko Wundram, 2006/09/24
- Re: Odd parser behaviour, Tim Van Holder, 2006/09/25
- Re: Odd parser behaviour, Heiko Wundram, 2006/09/25
- Re: Odd parser behaviour, Hans Aberg, 2006/09/25
- Re: Odd parser behaviour, Tim Van Holder, 2006/09/25
- Re: Odd parser behaviour, Heiko Wundram, 2006/09/25
- Re: Odd parser behaviour, Hans Aberg, 2006/09/25
- Re: Odd parser behaviour, Heiko Wundram, 2006/09/25
- Re: Odd parser behaviour,
Tim Van Holder <=