[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Grammatica-users] unexpected token problem - optional tokens...
From: |
Michal Korzybski |
Subject: |
[Grammatica-users] unexpected token problem - optional tokens... |
Date: |
Sat, 07 Oct 2006 23:39:24 +0100 |
User-agent: |
Thunderbird 1.5.0.7 (X11/20060921) |
Hi,
I'm trying to write a little grammar file to parse SQLPlus scripts
(Oracle) - only some parts of them, e.g. creation of a sequence.
Everything looks fine, but I have a problem with "unexpected token"
parser error message and do not know why it happens and how to fix it...
The tokenizer returns the following stream of tokens:
Tokens from data.txt:
T_OPEN_P(1001): "(", line: 3, col: 1
T_CLOSE_P(1002): ")", line: 3, col: 2
T_DECLARE(1026): "declare(...)", line: 4, col: 1
T_CREATE(1006): "Create", line: 17, col: 1
T_SEQUENCE(1007): "sequence", line: 17, col: 8
T_CURR_DATASET(1008): "&&dataset", line: 17, col: 17
T_DOT(1004): ".", line: 17, col: 26
T_IDENT(1027): "seq_table", line: 17, col: 27
T_SLASH(1005): "/", line: 18, col: 1
And I have the following productions defined:
plsql = ( T_DECLARE | T_OPEN_P | T_CLOSE_P | create_seq )+;
create_seq = T_CREATE T_SEQUENCE object_name
( ( increment_by | start_with )
| ( max_value | T_NOMAXVALUE )
| ( min_value | T_NOMINVALUE )
| ( T_CYCLE | T_NOCYCLE )
| ( cache | T_NOCACHE )
| ( T_ORDER | T_NOORDER ) )* T_SCOLON?
T_SLASH;
object_name = (schema_pref)? T_IDENT;
schema_pref = (T_IDENT | T_CURR_DATASET) T_DOT;
increment_by = T_INCREMENT T_BY T_INT_POS;
start_with = T_START T_WITH T_INT_POS;
max_value = T_MAXVALUE T_INT_POS;
min_value = T_MINVALUE T_INT_POS;
cache = T_CACHE T_INT_POS;
The parser complains:
plsql(2001)
T_OPEN_P(1001): "(", line: 3, col: 1
T_CLOSE_P(1002): ")", line: 3, col: 2
T_DECLARE(1026): "declare(...)", line: 4, col: 1
create_seq(2002)
T_CREATE(1006): "create", line: 17, col: 1
T_SEQUENCE(1007): "sequence", line: 17, col: 8
object_name(2003)
Error: in data.txt: line 17:
unexpected token "&&dataset", expected <T_IDENT>
create sequence &&dataset.seq_table
The "&&dataset" token is the T_CURR_DATASET.
Another thing is that I'd like to define somehow that there may be
either e.g. T_ORDER or T_NOORDER token used, but not both. I tried to
make all the alternatives optional (T_ORDER | T_NOORDER)? instead of
setting the whole group as "*" but then I had to use the tokens in
specified order (e.g. "cache" after "cycle"). How can it be defined?
Any help will be much appreciated.
Regards,
Michal
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Grammatica-users] unexpected token problem - optional tokens...,
Michal Korzybski <=