Browse thread
Catching a double semicolon
- Joel Reymont
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Joel Reymont <joelr1@g...> |
| Subject: | Catching a double semicolon |
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/