Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* Catching a double semicolon
@ 2007-03-06  0:55 Joel Reymont
  0 siblings, 0 replies; only message in thread
From: Joel Reymont @ 2007-03-06  0:55 UTC (permalink / raw)
  To: caml-list

Folks,

Any idea how to catch a double semicolon in the decs rule of this  
grammar?

I wish there was a way to get debugging output when a  
Parsing.Parser_error exception is triggered as I can't figure out  
what rule the parser is chocking on when I try an expression with two  
semicolons at the end.

I know it's chocking on a semicolon because when I insert a "catch  
all" error clause into the sections rule the error location points to  
it.

The rules below are working fine since my tests pass.

program: sections { $1 }

sections:
| section EOF { $1 }
| sections section EOF { $1 @ $2 }
| EOF { [] }

section:
| decs { List.rev $1 }
| statements { List.rev $1 }

decs:
| declarations SEMI { $1 :: [] }
| decs declarations SEMI { $2 :: $1 }

declarations:
| input_declarations { $1 }
| var_declarations { $1 }
| array_declarations { $1 }

input_declarations:
| INPUT COLON input_decs { InputDecs (List.rev $3) }
| INPUT COLON input_decs error { syntax_error "Missing semicolon" 4 }
| INPUT COLON error { syntax_error "Nothing after INPUT:" 3 }
| INPUT error { syntax_error "Missing ':' after INPUT" 2 }

	Thanks, Joel

--
http://wagerlabs.com/






^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-03-06  0:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-06  0:55 Catching a double semicolon Joel Reymont

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