Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: caml-list <caml-list@inria.fr>
Subject: ocamlyacc loop?
Date: 27 Nov 2004 20:18:55 +1100	[thread overview]
Message-ID: <1101547134.9291.605.camel@pelican.wigram> (raw)

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




             reply	other threads:[~2004-11-27  9:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-27  9:18 skaller [this message]
2004-11-27 14:55 ` [Caml-list] " skaller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1101547134.9291.605.camel@pelican.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox