type token =
| TokE_EOF
| TokE_Comma
| TokE_Colon
| TokE_Eq
| TokE_Slash
| TokE_LBracket
| TokE_RBracket
| TokE_Id of (string)
| TokE_Caml of (string)
| TokE_InitBegin
| TokE_InitEnd
| TokE_ExprBegin
| TokE_ExprEnd
| TokE_BlockBegin
| TokE_CloseBlockBegin
| TokE_BlockEnd
| TokE_Text of (string)
open Parsing;;
# 27 "tmpl-engine/tmplParser.mly"
module T = Template
type block_description =
{ bd_id : string;
bd_args : (string * string) list;
bd_ocaml : string option }
exception Invalid_template
let get_block = fun ts -> function
| { bd_id = "block";
bd_args = [];
bd_ocaml = Some ocaml; } ->
T.Tmpl_Block (ocaml, ts)
| { bd_id = "iter";
bd_args = ["name", name];
bd_ocaml = Some ocaml; } ->
T.Tmpl_Iter (name, ocaml, ts)
| { bd_id = "for";
bd_args = ["name", name];
bd_ocaml = Some ocaml; } ->
T.Tmpl_For (name, ocaml, ts)
| { bd_id = "if";
bd_args = [];
bd_ocaml = Some ocaml; } ->
T.Tmpl_If (ocaml, ts)
| _ ->
raise Invalid_template
# 51 "tmpl-engine/tmplParser.ml"
let yytransl_const = [|
257 ;
258 ;
259 ;
260 ;
261 ;
262 ;
263 ;
266 ;
267 ;
268 ;
269 ;
270 ;
271 ;
272 ;
0|]
let yytransl_block = [|
264 ;
265 ;
273 ;
0|]
let yylhs = "\255\255\001\000\001\000\003\000\004\000\004\000\004\000\005\000\005\000\006\000\006\000\006\000\006\000\007\000\t\000\t\000\002\000\002\000\008\000\008\000\n\000\000\000"
let yylen = "\002\000\002\000\003\000\003\000\001\000\003\000\003\000\001\000\002\000\003\000\004\000\005\000\006\000\003\000\001\000\002\000\000\000\001\000\001\000\003\000\003\000\002\000"
let yydefred = "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\021\000\000\000\000\000\014\000\004\000\000\000\000\000\000\000\000\000\000\000\008\000\001\000\000\000\000\000\015\000\003\000\005\000\000\000\000\000\t\000\002\000\000\000\006\000\000\000\000\000\018\000\n\000\000\000\000\000\000\000\000\000\011\000\013\000\020\000\019\000\012\000"
let yydgoto = "\002\000\007\000\008\000\t\000\n\000\011\000\012\000\029\000\031\000\013\000 \000"
let yysindex = "\001\000\006\255\000\000\254\254\013\255\017\255\248\254\000\000\025\255\247\254\000\000\000\000\247\254\247\254\016\255\015\255\001\255\000\000\000\000\028\255\018\255\000\000\000\000\000\000\022\255\019\255\000\000\000\000\023\255\000\000\030\255\003\255\000\000\000\000\020\255\024\255\022\255\021\255\000\000\000\000\000\000\000\000\000\000"
let yyrindex = "\000\000%\255\000\000\000\000\000\000\000\000\255\254\000\000\000\000%\255\000\000\000\000\026\255\000\255\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
let yygindex = "\000\000\000\000\012\000\000\000\026\000\"\000\000\000\000\000\000\000\000\000\006\000"
let yytablesize = 42
let yytable = "\007\000\017\000\001\000\004\000\024\000\005\000$\000\014\000\006\000\006\000\025\000\007\000%\000\007\000\007\000\017\000\003\000\026\000\004\000&\000\005\000\019\000\015\000\006\000\020\000\016\000\018\000\022\000\023\000\027\000\030\000\"\000(\000\028\000#\000!\000'\000*\000\016\000\021\000\017\000\016\000)\000"
let yycheck = "\001\001\001\001\001\000\012\001\003\001\014\001\003\001\t\001\017\001\017\001\t\001\012\001\t\001\014\001\015\001\015\001\n\001\016\001\012\001\016\001\014\001\t\000\t\001\017\001\012\000\008\001\001\001\011\001\013\001\001\001\008\001\008\001\008\001\015\001\004\001\016\001\016\001\016\001\001\001\013\000\006\000\015\001$\000"
let yynames_const = "TokE_EOF\000TokE_Comma\000TokE_Colon\000TokE_Eq\000TokE_Slash\000TokE_LBracket\000TokE_RBracket\000TokE_InitBegin\000TokE_InitEnd\000TokE_ExprBegin\000TokE_ExprEnd\000TokE_BlockBegin\000TokE_CloseBlockBegin\000TokE_BlockEnd\000"
let yynames_block = "TokE_Id\000TokE_Caml\000TokE_Text\000"
let yyact = [|
(fun _ -> failwith "parser")
; (fun __caml_parser_env ->
let _1 = (Parsing.peek_val __caml_parser_env 1 : 'chunk_list_0) in
Obj.repr(
# 84 "tmpl-engine/tmplParser.mly"
( T.Tmpl (None, List.rev _1) )
# 164 "tmpl-engine/tmplParser.ml"
: Template.template))
; (fun __caml_parser_env ->
let _1 = (Parsing.peek_val __caml_parser_env 2 : 'init) in
let _2 = (Parsing.peek_val __caml_parser_env 1 : 'chunk_list_0) in
Obj.repr(
# 85 "tmpl-engine/tmplParser.mly"
( T.Tmpl (Some _1, List.rev _2) )
# 172 "tmpl-engine/tmplParser.ml"
: Template.template))
; (fun __caml_parser_env ->
let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in
Obj.repr(
# 89 "tmpl-engine/tmplParser.mly"
( _2 )
# 179 "tmpl-engine/tmplParser.ml"
: 'init))
; (fun __caml_parser_env ->
let _1 = (Parsing.peek_val __caml_parser_env 0 : 'text) in
Obj.repr(
# 94 "tmpl-engine/tmplParser.mly"
( T.Tmpl_Text _1 )
# 186 "tmpl-engine/tmplParser.ml"
: 'chunk))
; (fun __caml_parser_env ->
let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in
Obj.repr(
# 96 "tmpl-engine/tmplParser.mly"
( T.Tmpl_Caml _2 )
# 193 "tmpl-engine/tmplParser.ml"
: 'chunk))
; (fun __caml_parser_env ->
let _1 = (Parsing.peek_val __caml_parser_env 2 : 'block_begin) in
let _2 = (Parsing.peek_val __caml_parser_env 1 : 'chunk_list_0) in
let _3 = (Parsing.peek_val __caml_parser_env 0 : 'block_end) in
Obj.repr(
# 98 "tmpl-engine/tmplParser.mly"
( if _1.bd_id <> _3 then
raise Invalid_template;
get_block (List.rev _2) _1 )
# 204 "tmpl-engine/tmplParser.ml"
: 'chunk))
; (fun __caml_parser_env ->
let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in
Obj.repr(
# 104 "tmpl-engine/tmplParser.mly"
( _1 )
# 211 "tmpl-engine/tmplParser.ml"
: 'text))
; (fun __caml_parser_env ->
let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in
let _2 = (Parsing.peek_val __caml_parser_env 0 : 'text) in
Obj.repr(
# 105 "tmpl-engine/tmplParser.mly"
( _1 ^ _2 )
# 219 "tmpl-engine/tmplParser.ml"
: 'text))
; (fun __caml_parser_env ->
let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in
Obj.repr(
# 110 "tmpl-engine/tmplParser.mly"
( { bd_id = _2;
bd_args = [];
bd_ocaml = None; } )
# 228 "tmpl-engine/tmplParser.ml"
: 'block_begin))
; (fun __caml_parser_env ->
let _2 = (Parsing.peek_val __caml_parser_env 2 : string) in
let _3 = (Parsing.peek_val __caml_parser_env 1 : string) in
Obj.repr(
# 115 "tmpl-engine/tmplParser.mly"
( { bd_id = _2;
bd_args = [];
bd_ocaml = Some _3; } )
# 238 "tmpl-engine/tmplParser.ml"
: 'block_begin))
; (fun __caml_parser_env ->
let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in
let _4 = (Parsing.peek_val __caml_parser_env 1 : 'args_list_1) in
Obj.repr(
# 120 "tmpl-engine/tmplParser.mly"
( { bd_id = _2;
bd_args = _4;
bd_ocaml = None; } )
# 248 "tmpl-engine/tmplParser.ml"
: 'block_begin))
; (fun __caml_parser_env ->
let _2 = (Parsing.peek_val __caml_parser_env 4 : string) in
let _4 = (Parsing.peek_val __caml_parser_env 2 : 'args_list_1) in
let _5 = (Parsing.peek_val __caml_parser_env 1 : string) in
Obj.repr(
# 125 "tmpl-engine/tmplParser.mly"
( { bd_id = _2;
bd_args = _4;
bd_ocaml = Some _5; } )
# 259 "tmpl-engine/tmplParser.ml"
: 'block_begin))
; (fun __caml_parser_env ->
let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in
Obj.repr(
# 132 "tmpl-engine/tmplParser.mly"
( _2 )
# 266 "tmpl-engine/tmplParser.ml"
: 'block_end))
; (fun __caml_parser_env ->
let _1 = (Parsing.peek_val __caml_parser_env 0 : 'chunk) in
Obj.repr(
# 135 "tmpl-engine/tmplParser.mly"
( [_1] )
# 273 "tmpl-engine/tmplParser.ml"
: 'chunk_list_1))
; (fun __caml_parser_env ->
let _1 = (Parsing.peek_val __caml_parser_env 1 : 'chunk_list_1) in
let _2 = (Parsing.peek_val __caml_parser_env 0 : 'chunk) in
Obj.repr(
# 136 "tmpl-engine/tmplParser.mly"
( _2 :: _1 )
# 281 "tmpl-engine/tmplParser.ml"
: 'chunk_list_1))
; (fun __caml_parser_env ->
Obj.repr(
# 140 "tmpl-engine/tmplParser.mly"
( [] )
# 287 "tmpl-engine/tmplParser.ml"
: 'chunk_list_0))
; (fun __caml_parser_env ->
let _1 = (Parsing.peek_val __caml_parser_env 0 : 'chunk_list_1) in
Obj.repr(
# 141 "tmpl-engine/tmplParser.mly"
( _1 )
# 294 "tmpl-engine/tmplParser.ml"
: 'chunk_list_0))
; (fun __caml_parser_env ->
let _1 = (Parsing.peek_val __caml_parser_env 0 : 'arg) in
Obj.repr(
# 145 "tmpl-engine/tmplParser.mly"
( [_1] )
# 301 "tmpl-engine/tmplParser.ml"
: 'args_list_1))
; (fun __caml_parser_env ->
let _1 = (Parsing.peek_val __caml_parser_env 2 : 'args_list_1) in
let _3 = (Parsing.peek_val __caml_parser_env 0 : 'arg) in
Obj.repr(
# 146 "tmpl-engine/tmplParser.mly"
( _3 :: _1 )
# 309 "tmpl-engine/tmplParser.ml"
: 'args_list_1))
; (fun __caml_parser_env ->
let _1 = (Parsing.peek_val __caml_parser_env 2 : string) in
let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in
Obj.repr(
# 150 "tmpl-engine/tmplParser.mly"
( (_1, _3) )
# 317 "tmpl-engine/tmplParser.ml"
: 'arg))
; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0)))
|]
let yytables =
{ Parsing.actions=yyact;
Parsing.transl_const=yytransl_const;
Parsing.transl_block=yytransl_block;
Parsing.lhs=yylhs;
Parsing.len=yylen;
Parsing.defred=yydefred;
Parsing.dgoto=yydgoto;
Parsing.sindex=yysindex;
Parsing.rindex=yyrindex;
Parsing.gindex=yygindex;
Parsing.tablesize=yytablesize;
Parsing.table=yytable;
Parsing.check=yycheck;
Parsing.error_function=parse_error;
Parsing.names_const=yynames_const;
Parsing.names_block=yynames_block }
let main (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) =
(Parsing.yyparse yytables 1 lexfun lexbuf : Template.template)