Source

hello / sql / parser.mly

Kota UENISHI c9e85cc 














































%{

  open Printf
  let _ = Parsing.set_trace false;;
  let debugprint = ref false;;
  
  let print str = if !debugprint then print_endline str;;
  
  let parse_error s = print ("parse_error->"^s);;

%}

%token SELECT
%token INSERT
%token DELETE
%token UPDATE
%token INTO
%token VALUES
%token SET
%token FROM
%token WHERE
%token LIMIT
%token DOT
%token LBRACE RBRACE
%token COMMA
%token ASTERISK
%token GT LT EQ NEQ NOT

%token <int> INT

%token <string> LITERAL


%type <Sql.query> input

%%

input: | exp { $1 };

exp:
  | SELECT columns FROM TABLE { Sql.Select($2, $4) };

columns:
  | COLUMN { [$1] }
  | COLUMN COMMA columns { $1::$3 }
;