Commit 061a47bb authored by Benoit Barbot's avatar Benoit Barbot
Browse files

prechange parser

parent 2bde48b9
......@@ -29,11 +29,14 @@ rule token = parse
| ',' {COMMA}
| ":" {COLON}
| "--" {PATHDELIM}
| ".." {CONTROLDELIM}
| "controls" {CONTROLS}
| "begin" {BEGIN}
| "end" {END}
| "tikzpicture" {TIKZPICTURE}
| "node" {NODE}
| "draw" {DRAW}
| "path" {PATH}
| "at" {AT}
| ['a'-'z' 'A'-'Z' '>' '-' '<' '='] [ '>' '-' '<' '=' 'a'-'z' 'A'-'Z' '_' '0'-'9']* as lxm {
STRING(lxm)
......
......@@ -13,8 +13,8 @@
%token EOF
%token BEGIN END
%token TIKZPICTURE
%token NODE DRAW AT
%token PATHDELIM
%token NODE DRAW AT PATH CONTROLS
%token PATHDELIM CONTROLDELIM
%start main
%type <(((float*float)*string*string) list)*((string list*string*string*(float*float) list ) list)> main
......@@ -35,9 +35,13 @@ body:
}
| BACKSLASH DRAW draw body {
let (al,start,fin,pl) = $3 in
Printf.printf "\\draw %s -> %s;\n" start fin;
let n,a = $4 in n,$3::a }
| BACKSLASH END { [],[] };
Printf.printf "\\draw %s -> %s;\n" start fin;
let n,a = $4 in n,$3::a }
| BACKSLASH PATH draw body {
let (al,start,fin,pl) = $3 in
Printf.printf "\\path %s -> %s;\n" start fin;
let n,a = $4 in n,("draw"::al,start,fin,pl)::a }
| BACKSLASH END { [],[] };
node:
AT LPAR FLOAT COMMA FLOAT RPAR LSQBRAK attribute_list RSQBRAK LPAR STRING RPAR LBRAK STRING RBRAK SEMICOLON { ($3,$5),$11,$14 };
......@@ -49,9 +53,15 @@ draw:
pathlist:
LPAR FLOAT COMMA FLOAT RPAR PATHDELIM pathlist { let l,f = $7 in (($2,$4)::l,f) }
| LPAR STRING RPAR { [],$2 }
attribute_list:
| STRING { [$1] }
| STRING COMMA attribute_list { $1::$3 }
| attribute { [$1] }
| attribute COMMA attribute_list { $1::$3 }
| {[]}
attribute:
| DRAW { "draw" }
| STRING { $1 }
| STRING STRING { $1^" "^$2 }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment