dbfwork: 'to_number(x)' is treated as simply 'x'
[ocaml-dbf.git] / simplesqlparse.mly
blobe5d49ced2c7d6739f580214250d5b86f2549f334
1 %{
2 open Simplesqlcommon
3 ;;
6 %}
8 %token Ignore_token
9 %token <string> Ident
10 %token <string> Str
11 %token <string> Num
12 %token LParen RParen Comma Sep Eof Create Table Insert Into Values 
14 %start sqlcmdsep
15 %type <bool> sqlcmdsep
19 sqlcmdsep:
20   sqlcmd Sep
21     { !Simplesqlcommon.execute_sql_command_val $1
22     ; false
23     }
24 | sqlcmd Eof
25     { !Simplesqlcommon.execute_sql_command_val $1
26     ; true
27     }
28 | Eof
29     { true }
32 sqlcmd:
33   Create Table Ident LParen colspeclist RParen
34     { Create_table ($3, $5) }
35 | Insert Into Ident LParen identlist1 RParen Values LParen sqlexprlist RParen
36     { Insert ($3, $5, $9) }
37 | Ignore_token
38     { Ignore_command }
41 colspeclist:
42   colspec Comma colspeclist
43     { $1 :: $3 }
44 | colspec
45     { [ $1 ] }
48 colspec:
49   Ident Ident optcolspecsize
50     { ($1, $2, $3) }
53 optcolspecsize:
54     { None }
55 | colspecsize
56     { Some $1 }
59 colspecsize:
60   LParen Num RParen
61     { ((int_of_sqlnum $2), 0) }
62 | LParen Num Comma Num RParen
63     { ((int_of_sqlnum $2), (int_of_sqlnum $4)) }
66 identlist1:
67   Ident Comma identlist1
68     { $1 :: $3 }
69 | Ident
70     { [ $1 ] }
73 sqlexprlist:
74   sqlexpr Comma sqlexprlist
75     { $1 :: $3 }
76 | sqlexpr
77     { [ $1 ] }
80 sqlexpr:
81   Ident
82     { SEIdent $1 }
83 | Num
84     { let (a, b) = split_number $1 in SENum (a, b) }
85 | Str
86     { SEStr $1 }
87 | Ident LParen sqlexprlist RParen
88     { SECall ($1, $3) }