summaryrefslogtreecommitdiff
path: root/math/parser.mly
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2006-10-11 18:12:39 +0000
committerPierre Schmitz <pierre@archlinux.de>2006-10-11 18:12:39 +0000
commit183851b06bd6c52f3cae5375f433da720d410447 (patch)
treea477257decbf3360127f6739c2f9d0ec57a03d39 /math/parser.mly
MediaWiki 1.7.1 wiederhergestellt
Diffstat (limited to 'math/parser.mly')
-rw-r--r--math/parser.mly103
1 files changed, 103 insertions, 0 deletions
diff --git a/math/parser.mly b/math/parser.mly
new file mode 100644
index 00000000..4787db37
--- /dev/null
+++ b/math/parser.mly
@@ -0,0 +1,103 @@
+%{
+ open Tex
+ open Render_info
+
+ let sq_close_ri = HTMLABLEC(FONT_UFH,"]", "]")
+%}
+%token <Render_info.t> LITERAL DELIMITER
+%token <string> FUN_AR2 FUN_INFIX FUN_AR1 DECL FUN_AR1opt BIG
+%token <string*string> BOX
+%token <string*(string*string)> FUN_AR1hl
+%token <string*Render_info.font_force> FUN_AR1hf DECLh
+%token <string*(Tex.t->Tex.t->string*string*string)> FUN_AR2h
+%token <string*(Tex.t list->Tex.t list->string*string*string)> FUN_INFIXh
+%token EOF CURLY_OPEN CURLY_CLOSE SUB SUP SQ_CLOSE NEXT_CELL NEXT_ROW
+%token BEGIN__MATRIX BEGIN_PMATRIX BEGIN_BMATRIX BEGIN_BBMATRIX BEGIN_VMATRIX BEGIN_VVMATRIX BEGIN_CASES
+%token END__MATRIX END_PMATRIX END_BMATRIX END_BBMATRIX END_VMATRIX END_VVMATRIX END_CASES
+%token LEFT RIGHT
+
+%type <Tex.t list> tex_expr
+%start tex_expr
+
+%%
+tex_expr:
+ expr EOF { $1 }
+ | ne_expr FUN_INFIX ne_expr EOF
+ { [TEX_INFIX($2,$1,$3)] }
+ | ne_expr FUN_INFIXh ne_expr EOF
+ { let t,h=$2 in [TEX_INFIXh(t,h,$1,$3)] }
+expr:
+ /* */ { [] }
+ | ne_expr { $1 }
+ne_expr:
+ lit_aq expr { $1 :: $2 }
+ | litsq_aq expr { $1 :: $2 }
+ | DECLh expr { let t,h = $1 in [TEX_DECLh(t,h,$2)] }
+litsq_aq:
+ litsq_zq { $1 }
+ | litsq_dq { let base,downi = $1 in TEX_DQ(base,downi) }
+ | litsq_uq { let base,upi = $1 in TEX_UQ(base,upi)}
+ | litsq_fq { $1 }
+litsq_fq:
+ litsq_dq SUP lit { let base,downi = $1 in TEX_FQ(base,downi,$3) }
+ | litsq_uq SUB lit { let base,upi = $1 in TEX_FQ(base,$3,upi) }
+litsq_uq:
+ litsq_zq SUP lit { $1,$3 }
+litsq_dq:
+ litsq_zq SUB lit { $1,$3 }
+litsq_zq:
+ | SQ_CLOSE { TEX_LITERAL sq_close_ri }
+expr_nosqc:
+ /* */ { [] }
+ | lit_aq expr_nosqc { $1 :: $2 }
+lit_aq:
+ lit { $1 }
+ | lit_dq { let base,downi = $1 in TEX_DQ(base,downi) }
+ | lit_uq { let base,upi = $1 in TEX_UQ(base,upi)}
+ | lit_fq { $1 }
+lit_fq:
+ lit_dq SUP lit { let base,downi = $1 in TEX_FQ(base,downi,$3) }
+ | lit_uq SUB lit { let base,upi = $1 in TEX_FQ(base,$3,upi) }
+lit_uq:
+ lit SUP lit { $1,$3 }
+lit_dq:
+ lit SUB lit { $1,$3 }
+left:
+ LEFT DELIMITER { $2 }
+ | LEFT SQ_CLOSE { sq_close_ri }
+right:
+ RIGHT DELIMITER { $2 }
+ | RIGHT SQ_CLOSE { sq_close_ri }
+lit:
+ LITERAL { TEX_LITERAL $1 }
+ | DELIMITER { TEX_LITERAL $1 }
+ | BIG DELIMITER { TEX_BIG ($1,$2) }
+ | BIG SQ_CLOSE { TEX_BIG ($1,sq_close_ri) }
+ | left expr right { TEX_LR ($1,$3,$2) }
+ | FUN_AR1 lit { TEX_FUN1($1,$2) }
+ | FUN_AR1hl lit { let t,h=$1 in TEX_FUN1hl(t,h,$2) }
+ | FUN_AR1hf lit { let t,h=$1 in TEX_FUN1hf(t,h,$2) }
+ | FUN_AR1opt expr_nosqc SQ_CLOSE lit { TEX_FUN2sq($1,TEX_CURLY $2,$4) }
+ | FUN_AR2 lit lit { TEX_FUN2($1,$2,$3) }
+ | FUN_AR2h lit lit { let t,h=$1 in TEX_FUN2h(t,h,$2,$3) }
+ | BOX { let bt,s = $1 in TEX_BOX (bt,s) }
+ | CURLY_OPEN expr CURLY_CLOSE
+ { TEX_CURLY $2 }
+ | CURLY_OPEN ne_expr FUN_INFIX ne_expr CURLY_CLOSE
+ { TEX_INFIX($3,$2,$4) }
+ | CURLY_OPEN ne_expr FUN_INFIXh ne_expr CURLY_CLOSE
+ { let t,h=$3 in TEX_INFIXh(t,h,$2,$4) }
+ | BEGIN__MATRIX matrix END__MATRIX { TEX_MATRIX ("matrix", $2) }
+ | BEGIN_PMATRIX matrix END_PMATRIX { TEX_MATRIX ("pmatrix", $2) }
+ | BEGIN_BMATRIX matrix END_BMATRIX { TEX_MATRIX ("bmatrix", $2) }
+ | BEGIN_BBMATRIX matrix END_BBMATRIX { TEX_MATRIX ("Bmatrix", $2) }
+ | BEGIN_VMATRIX matrix END_VMATRIX { TEX_MATRIX ("vmatrix", $2) }
+ | BEGIN_VVMATRIX matrix END_VVMATRIX { TEX_MATRIX ("Vmatrix", $2) }
+ | BEGIN_CASES matrix END_CASES { TEX_MATRIX ("cases", $2) }
+matrix:
+ line { [$1] }
+ | line NEXT_ROW matrix { $1::$3 }
+line:
+ expr { [$1] }
+ | expr NEXT_CELL line { $1::$3 }
+;;