Sorry, an error occurred while loading the content.
Browse Groups

• ## Re: [antlr-interest] infinite recursion

(3)
• NextPrevious
• ... I can t see a finite sentence satisfying the above productions. Any sentence must start with K ( there is no other reduction.) And once you see a K then it
Message 1 of 3 , Apr 11, 2001
View Source
lazimolmaz wrote:
>
> Hi,
>
> How do I arrangement following rules for antlr ?
>
> a: b | c ;
>
> b: K a ;
>
> c: a b
> | a X b
> | a Y b
> | a Z b
> ;
>

I can't see a finite sentence satisfying the above productions.

Any sentence must start with K ( there is no other reduction.)

And once you see a K then it MUST be followed with an 'a' .
But the only way a an 'a' can be a follow is that , it must start with
a K. So the recursion never ends.

However the rules could be contracted as:

a : K a | K a ( X | Y | Z )? K a ;

or

a : K a ( X | Y | Z )? K a ;

which will parse a countably infinite K's possibly followed by a ( X | Y
| Z )?
and another countably infinite K's , countably infinite times, which
still leaves it as only countably infinite, but nevertheless hard on the
computing resources, if not your patience.

Maybe you meant

c: /* empty */
| a b
| a X b
| a Y b
| a Z b
;

Or

a: b | c | ;

Or

b: K
| K a
;

Or maybe I am wrong....

Sinan
• ... with ... X | Y ... on the ... Thanks for answer. Sorry, there is a few translation error in my question. I m sending real question and errors
Message 2 of 3 , Apr 11, 2001
View Source
--- In antlr-interest@y..., Sinan <sinan.karasu@b...> wrote:
> lazimolmaz wrote:
> >
> > Hi,
> >
> > How do I arrangement following rules for antlr ?
> >
> > a: b | c ;
> >
> > b: K a ;
> >
> > c: a b
> > | a X b
> > | a Y b
> > | a Z b
> > ;
> >
>
> I can't see a finite sentence satisfying the above productions.
>
> Any sentence must start with K ( there is no other reduction.)
>
> And once you see a K then it MUST be followed with an 'a' .
> But the only way a an 'a' can be a follow is that , it must start
with
> a K. So the recursion never ends.
>
> However the rules could be contracted as:
>
> a : K a | K a ( X | Y | Z )? K a ;
>
> or
>
> a : K a ( X | Y | Z )? K a ;
>
> which will parse a countably infinite K's possibly followed by a (
X | Y
> | Z )?
> and another countably infinite K's , countably infinite times, which
> still leaves it as only countably infinite, but nevertheless hard
on the
> computing resources, if not your patience.
>
> Maybe you meant
>
> c: /* empty */
> | a b
> | a X b
> | a Y b
> | a Z b
> ;
>
> Or
>
> a: b | c | ;
>
> Or
>
> b: K
> | K a
> ;
>
> Or maybe I am wrong....
>
> Sinan

Sorry, there is a few translation error in my question.

I'm sending real question and errors

table_reference
: table_primary
| joined_table
;

table_primary
: table_or_query_name
( ( "as" )? correlation_name ( LPAREN
derived_column_list RPAREN )? )?
| derived_table
( "as" )? correlation_name ( LPAREN
derived_column_list RPAREN )?
| lateral_derived_table ( "AS" )? correlation_name
( LPAREN derived_column_list RPAREN )?
| collection_derived_table ( "AS" )? correlation_name
( LPAREN derived_column_list RPAREN )?
| only_spec
( ( "AS" )? correlation_name
( LPAREN derived_column_list RPAREN )? )?
| LPAREN joined_table RPAREN
;

only_spec
: "ONLY" LPAREN table_or_query_name RPAREN
;

lateral_derived_table
: "LATERAL" LPAREN query_expression RPAREN
;

collection_derived_table
: "UNNEST" LPAREN collection_value_expression RPAREN
( "WITH" "ORDINALITY" )?
;

derived_table
: table_subquery
;

table_or_query_name
: table_name
| query_name
;

derived_column_list
: column_name_list
;

column_name_list
: column_name ( COMMA column_name )*
;

//---7.7--------------------------------------------------------------
---------

joined_table
: cross_join
| qualified_join
| natural_join
| union_join
;

cross_join
: table_reference "CROSS" "JOIN" table_primary
;

qualified_join
: table_reference ( join_type )? "JOIN" table_reference
join_specification
;

natural_join
: table_reference "NATURAL" ( join_type )? "JOIN"
table_primary
;

union_join
: table_reference "UNION" "JOIN" table_primary
;

join_specification
: join_condition
| named_columns_join
;

join_condition
: "ON" search_condition
;

named_columns_join
: "USING" LPAREN join_column_list RPAREN
;

join_type
: "INNER"
| outer_join_type ( "OUTER" )?
;

outer_join_type
: "LEFT"
| "RIGHT"
| "FULL"
;

join_column_list
: column_name_list
;

infinite recursion to rule joined_table from rule table_reference
infinite recursion to rule joined_table from rule cross_join
infinite recursion to rule joined_table from rule joined_table
infinite recursion to rule joined_table from rule qualified_join
infinite recursion to rule joined_table from rule joined_table
infinite recursion to rule joined_table from rule natural_join
infinite recursion to rule joined_table from rule joined_table
infinite recursion to rule joined_table from rule union_join
infinite recursion to rule joined_table from rule joined_table
infinite recursion to rule joined_table from rule non_join_query_term
infinite recursion to rule joined_table from rule
non_join_query_expression
infinite recursion to rule joined_table from rule
non_join_query_expression
infinite recursion to rule joined_table from rule
query_expression_body
infinite recursion to rule joined_table from rule
query_expression_body
infinite recursion to rule joined_table from rule query_expression
infinite recursion to rule joined_table from rule from_subquery
infinite recursion to rule joined_table from rule
insert_columns_and_source
infinite recursion to rule joined_table from rule insert_statement
infinite recursion to rule joined_table from rule query_expression
Your message has been successfully submitted and would be delivered to recipients shortly.
• Changes have not been saved
Press OK to abandon changes or Cancel to continue editing
• Your browser is not supported
Kindly note that Groups does not support 7.0 or earlier versions of Internet Explorer. We recommend upgrading to the latest Internet Explorer, Google Chrome, or Firefox. If you are using IE 9 or later, make sure you turn off Compatibility View.