Version française
Home     About     Download     Resources     Contact us    
Browse thread
ocamlyacc loop?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: ocamlyacc loop?
I have an unambiguous ocamlyacc grammar which is dying
on a particular input term with a stack overflow.

I'm assuming I have caused an infinite loop somehow
with the grammar, but I'm not exactly sure how this
can happen. Perhaps something like this:

y:  x { $1 } | TOKEN
x: y { $1 }

starting with y, input TOKEN, would loop forever.

Unfortunately, debugging prints only go in executable
code and show completed reductions. Any hint on how
to find this problem?

The actual problem is weird:

x; // parses ok
the x; // loops forever

but I know from the debugging the 'the x' term is
actually reduced correctly: with this grammar production:

dollar_name:
  | DOLLAR qname
  | THE qname 
  | qname 


x; // works
$x; // works
the x; // fails

I have some trouble understanding this: the tokens THE and DOLLAR
are used exactly once, in the same way as you see. Yet the
parse loops forever with THE and not with $.

It almost looks like there is an infinite loop in the
client reduction code.

I get this diagnostic output:

Reducing plain old name
Reducing simple parts
Reducing qualified_name
Reducing THE term
Reducing dollar_name
Reducing factor
Reducing coercion

which show coercion is reduced, but not application,
here's more of the grammar:

application:
  | application coercion
  | coercion 

coercion:
  | coercion COLON factor          
  | suffixed_name                  
  | factor  

factor:
  | dollar_name
  | factor DOT ... more stuff

-- 
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net