Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* ocamlyacc loop?
@ 2004-11-27  9:18 skaller
  2004-11-27 14:55 ` [Caml-list] " skaller
  0 siblings, 1 reply; 2+ messages in thread
From: skaller @ 2004-11-27  9:18 UTC (permalink / raw)
  To: caml-list

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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] ocamlyacc loop?
  2004-11-27  9:18 ocamlyacc loop? skaller
@ 2004-11-27 14:55 ` skaller
  0 siblings, 0 replies; 2+ messages in thread
From: skaller @ 2004-11-27 14:55 UTC (permalink / raw)
  To: caml-list

On Sat, 2004-11-27 at 20:18, skaller wrote:
> I have an unambiguous ocamlyacc grammar which is dying
> on a particular input term with a stack overflow.

Argg. no it isn't. Please ignore my message.
The problem was actually in the routine *printing*
the parse tree. It said the (moral equivalent of):

let rec string_of_expr e =
match e with
| `AST_the q -> "the " ^ string_of_expr e

It should have said 'q' not 'e'... :)

-- 
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




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-11-27 14:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-27  9:18 ocamlyacc loop? skaller
2004-11-27 14:55 ` [Caml-list] " skaller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox