Merge "Simplify parsing of mediawiki_function_names"

This commit is contained in:
jenkins-bot 2024-09-22 12:56:15 +00:00 committed by Gerrit Code Review
commit 5489d8d693
3 changed files with 574 additions and 619 deletions

View file

@ -453,83 +453,83 @@ class Parser {
$this->line(), $this->column()); $this->line(), $this->column());
} }
} }
private function peg_f26($b, $r) { return new Big($b, $r); } private function peg_f26($f) { return $this->tu->mediawiki_function_names($f); }
private function peg_f27($b) { return new Big($b, "]"); } private function peg_f27($f) {
private function peg_f28($l, $e, $r) {return new Lr($l, $r, $e); }
private function peg_f29($name, $e, $l) { return new Fun2sq($name, $e->setCurly(), $l); }
private function peg_f30($name, $l) { return new Fun1($name, $l); }
private function peg_f31($name, $l) {return new Fun1nb($name, $l); }
private function peg_f32($name, $l) { return new Mhchem($name, $l); }
private function peg_f33($name, $l1, $l2) { return new Fun2($name, $l1, $l2); }
private function peg_f34($name, $l1, $l2, $l3, $l4) { return new Fun4($name, $l1, $l2, $l3, $l4); }
private function peg_f35($name, $l1, $l2) { return new Fun2nb($name, $l1, $l2); }
private function peg_f36($e) { return $e->setCurly(); }
private function peg_f37($e1, $name, $e2) { return new Infix($name, $e1, $e2); }
private function peg_f38($m) { return $m->setTop( 'matrix' ); }
private function peg_f39($m) { return $m->setTop( 'pmatrix' ); }
private function peg_f40($m) { return $m->setTop( 'bmatrix' ); }
private function peg_f41($m) { return $m->setTop( 'Bmatrix' ); }
private function peg_f42($m) { return $m->setTop( 'vmatrix' ); }
private function peg_f43($m) { return $m->setTop( 'Vmatrix' ); }
private function peg_f44($m) { return $m->setTop( 'array' ); }
private function peg_f45($m) { return $m->setTop( 'aligned' ); }
private function peg_f46($m) { return $m->setTop( 'alignedat' ); }
private function peg_f47($m) { return $m->setTop( 'smallmatrix' ); }
private function peg_f48($m) { return $m->setTop( 'cases' ); }
private function peg_f49() { throw new SyntaxError("Illegal TeX function", [], $this->text(), $this->offset(),
$this->line(), $this->column()); }
private function peg_f50($f) { return !$this->tu->getAllFunctionsAt($f); }
private function peg_f51($f) { throw new SyntaxError("Illegal TeX function", [], $f, $this->offset(), $this->line(), $this->column()); }
private function peg_f52($cs, $m) { return $m->setColumnSpecs( $cs ); }
private function peg_f53($as, $m) { return $m->setColumnSpecs( $as ); }
private function peg_f54($l, $m) { return $m; }
private function peg_f55($l, $tail) { if ($tail === null) { return new Matrix( 'matrix', new TexArray( $l ) ); }
return new Matrix( 'matrix', $tail->unshift($l) ); }
private function peg_f56($f, $l) {
if ($l->first() === null ) {
$l->push(new TexArray());
}
$l->first()->unshift(new Literal($f . " ")); return $l;}
private function peg_f57($e, $l) { return $l; }
private function peg_f58($e, $tail) {
if ($tail === null) { return new TexArray( $e ) ; }
return $tail->unshift($e);
}
private function peg_f59() { return $this->text(); }
private function peg_f60($cs) { return TexArray::newCurly(new Literal($cs)); }
private function peg_f61($num) { return TexArray::newCurly(new Literal($num)); }
private function peg_f62($p, $s) { return new TexArray($p,new TexArray(new Literal(" "),$s)); }
private function peg_f63($p) { return new TexArray($p,new TexArray()); }
private function peg_f64($m) { return new Literal($m); }
private function peg_f65($m, $n) { return new ChemWord($m, new Literal($n)); }
private function peg_f66($m) { return $m; }
private function peg_f67($m, $n) { return new ChemWord($m, $n); }
private function peg_f68($m, $n, $o) { return new ChemWord(new ChemWord(new Literal($m), $n), $o); }
private function peg_f69() { return new Literal(""); }
private function peg_f70($m) { return $m;}
private function peg_f71($c) { return new Literal($c); }
private function peg_f72($c) { return TexArray::newCurly($c); }
private function peg_f73($c) { return new Dollar($c); }
private function peg_f74($e) { return TexArray::newCurly(new Literal($e)); }
private function peg_f75($a, $b) { return new ChemWord(new Literal($a), new Literal($b)); }
private function peg_f76($a, $b) { return new ChemWord(new Literal($a), $b); }
private function peg_f77($a, $b) { return new ChemWord(new Literal($a), new Dollar($b)); }
private function peg_f78($name, $l1, $l2) { return new ChemFun2u($name, $l1, $l2); }
private function peg_f79($cs) { return new Literal(join('',$cs)); }
private function peg_f80($name) { return new Literal(join('',$name)); }
private function peg_f81($b) { return $this->tu->box_functions($b); }
private function peg_f82($b, $cs) { return new Box($b, join('', $cs)); }
private function peg_f83($c) { return $c; }
private function peg_f84($f) { return $this->tu->mediawiki_function_names($f); }
private function peg_f85($f, $c) {
if(is_array($f)) { if(is_array($f)) {
// This is an unexpected case, but covers the ambiguity of slice in javascript. // This is an unexpected case, but covers the ambiguity of slice in javascript.
$fProcessed = implode(array_slice($f, 1)); $fProcessed = implode(array_slice($f, 1));
} else { } else {
$fProcessed = substr($f,1); $fProcessed = substr($f,1);
} }
return "\\operatorname {" . $fProcessed . "}" . $c; return new Fun1nb( '\\operatorname', new Literal( $fProcessed ) );
} }
private function peg_f28($b, $r) { return new Big($b, $r); }
private function peg_f29($b) { return new Big($b, "]"); }
private function peg_f30($l, $e, $r) {return new Lr($l, $r, $e); }
private function peg_f31($name, $e, $l) { return new Fun2sq($name, $e->setCurly(), $l); }
private function peg_f32($name, $l) { return new Fun1($name, $l); }
private function peg_f33($name, $l) { return new Fun1nb($name, $l); }
private function peg_f34($name, $l) { return new Mhchem($name, $l); }
private function peg_f35($name, $l1, $l2) { return new Fun2($name, $l1, $l2); }
private function peg_f36($name, $l1, $l2, $l3, $l4) { return new Fun4($name, $l1, $l2, $l3, $l4); }
private function peg_f37($name, $l1, $l2) { return new Fun2nb($name, $l1, $l2); }
private function peg_f38($e) { return $e->setCurly(); }
private function peg_f39($e1, $name, $e2) { return new Infix($name, $e1, $e2); }
private function peg_f40($m) { return $m->setTop( 'matrix' ); }
private function peg_f41($m) { return $m->setTop( 'pmatrix' ); }
private function peg_f42($m) { return $m->setTop( 'bmatrix' ); }
private function peg_f43($m) { return $m->setTop( 'Bmatrix' ); }
private function peg_f44($m) { return $m->setTop( 'vmatrix' ); }
private function peg_f45($m) { return $m->setTop( 'Vmatrix' ); }
private function peg_f46($m) { return $m->setTop( 'array' ); }
private function peg_f47($m) { return $m->setTop( 'aligned' ); }
private function peg_f48($m) { return $m->setTop( 'alignedat' ); }
private function peg_f49($m) { return $m->setTop( 'smallmatrix' ); }
private function peg_f50($m) { return $m->setTop( 'cases' ); }
private function peg_f51() { throw new SyntaxError("Illegal TeX function", [], $this->text(), $this->offset(),
$this->line(), $this->column()); }
private function peg_f52($f) { return !$this->tu->getAllFunctionsAt($f); }
private function peg_f53($f) { throw new SyntaxError("Illegal TeX function", [], $f, $this->offset(), $this->line(), $this->column()); }
private function peg_f54($cs, $m) { return $m->setColumnSpecs( $cs ); }
private function peg_f55($as, $m) { return $m->setColumnSpecs( $as ); }
private function peg_f56($l, $m) { return $m; }
private function peg_f57($l, $tail) { if ($tail === null) { return new Matrix( 'matrix', new TexArray( $l ) ); }
return new Matrix( 'matrix', $tail->unshift($l) ); }
private function peg_f58($f, $l) {
if ($l->first() === null ) {
$l->push(new TexArray());
}
$l->first()->unshift(new Literal($f . " ")); return $l;}
private function peg_f59($e, $l) { return $l; }
private function peg_f60($e, $tail) {
if ($tail === null) { return new TexArray( $e ) ; }
return $tail->unshift($e);
}
private function peg_f61() { return $this->text(); }
private function peg_f62($cs) { return TexArray::newCurly(new Literal($cs)); }
private function peg_f63($num) { return TexArray::newCurly(new Literal($num)); }
private function peg_f64($p, $s) { return new TexArray($p,new TexArray(new Literal(" "),$s)); }
private function peg_f65($p) { return new TexArray($p,new TexArray()); }
private function peg_f66($m) { return new Literal($m); }
private function peg_f67($m, $n) { return new ChemWord($m, new Literal($n)); }
private function peg_f68($m) { return $m; }
private function peg_f69($m, $n) { return new ChemWord($m, $n); }
private function peg_f70($m, $n, $o) { return new ChemWord(new ChemWord(new Literal($m), $n), $o); }
private function peg_f71() { return new Literal(""); }
private function peg_f72($m) { return $m;}
private function peg_f73($c) { return new Literal($c); }
private function peg_f74($c) { return TexArray::newCurly($c); }
private function peg_f75($c) { return new Dollar($c); }
private function peg_f76($e) { return TexArray::newCurly(new Literal($e)); }
private function peg_f77($a, $b) { return new ChemWord(new Literal($a), new Literal($b)); }
private function peg_f78($a, $b) { return new ChemWord(new Literal($a), $b); }
private function peg_f79($a, $b) { return new ChemWord(new Literal($a), new Dollar($b)); }
private function peg_f80($name, $l1, $l2) { return new ChemFun2u($name, $l1, $l2); }
private function peg_f81($cs) { return new Literal(join('',$cs)); }
private function peg_f82($name) { return new Literal(join('',$name)); }
private function peg_f83($b) { return $this->tu->box_functions($b); }
private function peg_f84($b, $cs) { return new Box($b, join('', $cs)); }
private function peg_f85($c) { return $c; }
private function peg_f86($f) { return $this->tu->nullary_macro($f); } private function peg_f86($f) { return $this->tu->nullary_macro($f); }
private function peg_f87($f) { return $f . " "; } private function peg_f87($f) { return $f . " "; }
private function peg_f88($f) { return $this->options['usemathrm'] && $this->tu->nullary_macro_in_mbox($f); } private function peg_f88($f) { return $this->options['usemathrm'] && $this->tu->nullary_macro_in_mbox($f); }
@ -1583,6 +1583,35 @@ class Parser {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
$s0 = $this->peg_FAILED; $s0 = $this->peg_FAILED;
} }
if ($s0 === $this->peg_FAILED) {
$s0 = $this->peg_currPos;
$s1 = $this->peg_parsegeneric_func();
if ($s1 !== $this->peg_FAILED) {
$this->peg_reportedPos = $this->peg_currPos;
$s2 = $this->peg_f26($s1);
if ($s2) {
$s2 = null;
} else {
$s2 = $this->peg_FAILED;
}
if ($s2 !== $this->peg_FAILED) {
$s3 = $this->peg_parse_();
if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0;
$s1 = $this->peg_f27($s1);
$s0 = $s1;
} else {
$this->peg_currPos = $s0;
$s0 = $this->peg_FAILED;
}
} else {
$this->peg_currPos = $s0;
$s0 = $this->peg_FAILED;
}
} else {
$this->peg_currPos = $s0;
$s0 = $this->peg_FAILED;
}
if ($s0 === $this->peg_FAILED) { if ($s0 === $this->peg_FAILED) {
$s0 = $this->peg_currPos; $s0 = $this->peg_currPos;
$s1 = $this->peg_parseDELIMITER(); $s1 = $this->peg_parseDELIMITER();
@ -1598,7 +1627,7 @@ class Parser {
$s2 = $this->peg_parseDELIMITER(); $s2 = $this->peg_parseDELIMITER();
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f26($s1, $s2); $s1 = $this->peg_f28($s1, $s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -1615,7 +1644,7 @@ class Parser {
$s2 = $this->peg_parseSQ_CLOSE(); $s2 = $this->peg_parseSQ_CLOSE();
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f27($s1); $s1 = $this->peg_f29($s1);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -1634,7 +1663,7 @@ class Parser {
$s3 = $this->peg_parseright(); $s3 = $this->peg_parseright();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f28($s1, $s2, $s3); $s1 = $this->peg_f30($s1, $s2, $s3);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -1659,7 +1688,7 @@ class Parser {
$s4 = $this->peg_parselit(); $s4 = $this->peg_parselit();
if ($s4 !== $this->peg_FAILED) { if ($s4 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f29($s1, $s2, $s4); $s1 = $this->peg_f31($s1, $s2, $s4);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -1684,7 +1713,7 @@ class Parser {
$s2 = $this->peg_parselit(); $s2 = $this->peg_parselit();
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f30($s1, $s2); $s1 = $this->peg_f32($s1, $s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -1701,7 +1730,7 @@ class Parser {
$s2 = $this->peg_parselit(); $s2 = $this->peg_parselit();
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f31($s1, $s2); $s1 = $this->peg_f33($s1, $s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -1718,7 +1747,7 @@ class Parser {
$s2 = $this->peg_parsechem_lit(); $s2 = $this->peg_parsechem_lit();
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f32($s1, $s2); $s1 = $this->peg_f34($s1, $s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -1737,7 +1766,7 @@ class Parser {
$s3 = $this->peg_parselit(); $s3 = $this->peg_parselit();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f33($s1, $s2, $s3); $s1 = $this->peg_f35($s1, $s2, $s3);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -1764,7 +1793,7 @@ class Parser {
$s5 = $this->peg_parselit(); $s5 = $this->peg_parselit();
if ($s5 !== $this->peg_FAILED) { if ($s5 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f34($s1, $s2, $s3, $s4, $s5); $s1 = $this->peg_f36($s1, $s2, $s3, $s4, $s5);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -1795,7 +1824,7 @@ class Parser {
$s3 = $this->peg_parselit(); $s3 = $this->peg_parselit();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f35($s1, $s2, $s3); $s1 = $this->peg_f37($s1, $s2, $s3);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -1820,7 +1849,7 @@ class Parser {
$s3 = $this->peg_parseCURLY_CLOSE(); $s3 = $this->peg_parseCURLY_CLOSE();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f36($s2); $s1 = $this->peg_f38($s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -1847,7 +1876,7 @@ class Parser {
$s5 = $this->peg_parseCURLY_CLOSE(); $s5 = $this->peg_parseCURLY_CLOSE();
if ($s5 !== $this->peg_FAILED) { if ($s5 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f37($s2, $s3, $s4); $s1 = $this->peg_f39($s2, $s3, $s4);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -1881,7 +1910,7 @@ class Parser {
$s3 = $this->peg_parseEND_MATRIX(); $s3 = $this->peg_parseEND_MATRIX();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f38($s2); $s1 = $this->peg_f40($s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -1907,7 +1936,7 @@ class Parser {
$s3 = $this->peg_parseEND_PMATRIX(); $s3 = $this->peg_parseEND_PMATRIX();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f39($s2); $s1 = $this->peg_f41($s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -1933,7 +1962,7 @@ class Parser {
$s3 = $this->peg_parseEND_BMATRIX(); $s3 = $this->peg_parseEND_BMATRIX();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f40($s2); $s1 = $this->peg_f42($s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -1959,7 +1988,7 @@ class Parser {
$s3 = $this->peg_parseEND_BBMATRIX(); $s3 = $this->peg_parseEND_BBMATRIX();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f41($s2); $s1 = $this->peg_f43($s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -1985,7 +2014,7 @@ class Parser {
$s3 = $this->peg_parseEND_VMATRIX(); $s3 = $this->peg_parseEND_VMATRIX();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f42($s2); $s1 = $this->peg_f44($s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -2011,7 +2040,7 @@ class Parser {
$s3 = $this->peg_parseEND_VVMATRIX(); $s3 = $this->peg_parseEND_VVMATRIX();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f43($s2); $s1 = $this->peg_f45($s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -2036,7 +2065,7 @@ class Parser {
$s4 = $this->peg_parseEND_ARRAY(); $s4 = $this->peg_parseEND_ARRAY();
if ($s4 !== $this->peg_FAILED) { if ($s4 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f44($s3); $s1 = $this->peg_f46($s3);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -2065,7 +2094,7 @@ class Parser {
$s4 = $this->peg_parseEND_ALIGN(); $s4 = $this->peg_parseEND_ALIGN();
if ($s4 !== $this->peg_FAILED) { if ($s4 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f45($s3); $s1 = $this->peg_f47($s3);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -2094,7 +2123,7 @@ class Parser {
$s4 = $this->peg_parseEND_ALIGNED(); $s4 = $this->peg_parseEND_ALIGNED();
if ($s4 !== $this->peg_FAILED) { if ($s4 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f45($s3); $s1 = $this->peg_f47($s3);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -2121,7 +2150,7 @@ class Parser {
$s3 = $this->peg_parseEND_ALIGNAT(); $s3 = $this->peg_parseEND_ALIGNAT();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f46($s2); $s1 = $this->peg_f48($s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -2144,7 +2173,7 @@ class Parser {
$s3 = $this->peg_parseEND_ALIGNEDAT(); $s3 = $this->peg_parseEND_ALIGNEDAT();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f46($s2); $s1 = $this->peg_f48($s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -2170,7 +2199,7 @@ class Parser {
$s3 = $this->peg_parseEND_SMALLMATRIX(); $s3 = $this->peg_parseEND_SMALLMATRIX();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f47($s2); $s1 = $this->peg_f49($s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -2193,7 +2222,7 @@ class Parser {
$s3 = $this->peg_parseEND_CASES(); $s3 = $this->peg_parseEND_CASES();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f48($s2); $s1 = $this->peg_f50($s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -2241,7 +2270,7 @@ class Parser {
} }
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f49(); $s1 = $this->peg_f51();
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -2260,7 +2289,7 @@ class Parser {
$s1 = $this->peg_parsegeneric_func(); $s1 = $this->peg_parsegeneric_func();
if ($s1 !== $this->peg_FAILED) { if ($s1 !== $this->peg_FAILED) {
$this->peg_reportedPos = $this->peg_currPos; $this->peg_reportedPos = $this->peg_currPos;
$s2 = $this->peg_f50($s1); $s2 = $this->peg_f52($s1);
if ($s2) { if ($s2) {
$s2 = null; $s2 = null;
} else { } else {
@ -2268,7 +2297,7 @@ class Parser {
} }
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f51($s1); $s1 = $this->peg_f53($s1);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -2310,6 +2339,7 @@ class Parser {
} }
} }
} }
}
$this->peg_cache[$key] = array ("nextPos" => $this->peg_currPos, "result" => $s0 ); $this->peg_cache[$key] = array ("nextPos" => $this->peg_currPos, "result" => $s0 );
@ -2332,7 +2362,7 @@ class Parser {
$s2 = $this->peg_parsematrix(); $s2 = $this->peg_parsematrix();
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f52($s1, $s2); $s1 = $this->peg_f54($s1, $s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -2364,7 +2394,7 @@ class Parser {
$s2 = $this->peg_parsematrix(); $s2 = $this->peg_parsematrix();
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f53($s1, $s2); $s1 = $this->peg_f55($s1, $s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -2399,7 +2429,7 @@ class Parser {
$s4 = $this->peg_parsematrix(); $s4 = $this->peg_parsematrix();
if ($s4 !== $this->peg_FAILED) { if ($s4 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s2; $this->peg_reportedPos = $s2;
$s3 = $this->peg_f54($s1, $s4); $s3 = $this->peg_f56($s1, $s4);
$s2 = $s3; $s2 = $s3;
} else { } else {
$this->peg_currPos = $s2; $this->peg_currPos = $s2;
@ -2414,7 +2444,7 @@ class Parser {
} }
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f55($s1, $s2); $s1 = $this->peg_f57($s1, $s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -2446,7 +2476,7 @@ class Parser {
$s2 = $this->peg_parseline_start(); $s2 = $this->peg_parseline_start();
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f56($s1, $s2); $s1 = $this->peg_f58($s1, $s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -2484,7 +2514,7 @@ class Parser {
$s4 = $this->peg_parseline(); $s4 = $this->peg_parseline();
if ($s4 !== $this->peg_FAILED) { if ($s4 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s2; $this->peg_reportedPos = $s2;
$s3 = $this->peg_f57($s1, $s4); $s3 = $this->peg_f59($s1, $s4);
$s2 = $s3; $s2 = $s3;
} else { } else {
$this->peg_currPos = $s2; $this->peg_currPos = $s2;
@ -2499,7 +2529,7 @@ class Parser {
} }
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f58($s1, $s2); $s1 = $this->peg_f60($s1, $s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -2541,14 +2571,14 @@ class Parser {
} }
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s2; $this->peg_reportedPos = $s2;
$s3 = $this->peg_f59(); $s3 = $this->peg_f61();
} }
$s2 = $s3; $s2 = $s3;
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$s3 = $this->peg_parseCURLY_CLOSE(); $s3 = $this->peg_parseCURLY_CLOSE();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f60($s2); $s1 = $this->peg_f62($s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -2903,7 +2933,7 @@ class Parser {
} }
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s2; $this->peg_reportedPos = $s2;
$s3 = $this->peg_f59(); $s3 = $this->peg_f61();
} }
$s2 = $s3; $s2 = $s3;
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
@ -2912,7 +2942,7 @@ class Parser {
$s4 = $this->peg_parseCURLY_CLOSE(); $s4 = $this->peg_parseCURLY_CLOSE();
if ($s4 !== $this->peg_FAILED) { if ($s4 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f61($s2); $s1 = $this->peg_f63($s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -3036,7 +3066,7 @@ class Parser {
$s3 = $this->peg_parseCURLY_CLOSE(); $s3 = $this->peg_parseCURLY_CLOSE();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f36($s2); $s1 = $this->peg_f38($s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -3084,7 +3114,7 @@ class Parser {
$s4 = $this->peg_parsechem_sentence(); $s4 = $this->peg_parsechem_sentence();
if ($s4 !== $this->peg_FAILED) { if ($s4 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f62($s2, $s4); $s1 = $this->peg_f64($s2, $s4);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -3111,7 +3141,7 @@ class Parser {
$s3 = $this->peg_parse_(); $s3 = $this->peg_parse_();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f63($s2); $s1 = $this->peg_f65($s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -3154,7 +3184,7 @@ class Parser {
} }
if ($s1 !== $this->peg_FAILED) { if ($s1 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f64($s1); $s1 = $this->peg_f66($s1);
} }
$s0 = $s1; $s0 = $s1;
if ($s0 === $this->peg_FAILED) { if ($s0 === $this->peg_FAILED) {
@ -3164,7 +3194,7 @@ class Parser {
$s2 = $this->peg_parseCHEM_SINGLE_MACRO(); $s2 = $this->peg_parseCHEM_SINGLE_MACRO();
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f65($s1, $s2); $s1 = $this->peg_f67($s1, $s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -3179,7 +3209,7 @@ class Parser {
$s1 = $this->peg_parsechem_word(); $s1 = $this->peg_parsechem_word();
if ($s1 !== $this->peg_FAILED) { if ($s1 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f66($s1); $s1 = $this->peg_f68($s1);
} }
$s0 = $s1; $s0 = $s1;
if ($s0 === $this->peg_FAILED) { if ($s0 === $this->peg_FAILED) {
@ -3187,7 +3217,7 @@ class Parser {
$s1 = $this->peg_parseCHEM_SINGLE_MACRO(); $s1 = $this->peg_parseCHEM_SINGLE_MACRO();
if ($s1 !== $this->peg_FAILED) { if ($s1 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f64($s1); $s1 = $this->peg_f66($s1);
} }
$s0 = $s1; $s0 = $s1;
if ($s0 === $this->peg_FAILED) { if ($s0 === $this->peg_FAILED) {
@ -3203,7 +3233,7 @@ class Parser {
} }
if ($s1 !== $this->peg_FAILED) { if ($s1 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f64($s1); $s1 = $this->peg_f66($s1);
} }
$s0 = $s1; $s0 = $s1;
} }
@ -3232,7 +3262,7 @@ class Parser {
$s2 = $this->peg_parsechem_word_nt(); $s2 = $this->peg_parsechem_word_nt();
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f67($s1, $s2); $s1 = $this->peg_f69($s1, $s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -3251,7 +3281,7 @@ class Parser {
$s3 = $this->peg_parsechem_word_nt(); $s3 = $this->peg_parsechem_word_nt();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f68($s1, $s2, $s3); $s1 = $this->peg_f70($s1, $s2, $s3);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -3286,7 +3316,7 @@ class Parser {
$s1 = $this->peg_parsechem_word(); $s1 = $this->peg_parsechem_word();
if ($s1 !== $this->peg_FAILED) { if ($s1 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f66($s1); $s1 = $this->peg_f68($s1);
} }
$s0 = $s1; $s0 = $s1;
if ($s0 === $this->peg_FAILED) { if ($s0 === $this->peg_FAILED) {
@ -3294,7 +3324,7 @@ class Parser {
$s1 = $this->peg_c2; $s1 = $this->peg_c2;
if ($s1 !== $this->peg_FAILED) { if ($s1 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f69(); $s1 = $this->peg_f71();
} }
$s0 = $s1; $s0 = $s1;
} }
@ -3318,7 +3348,7 @@ class Parser {
$s1 = $this->peg_parsechem_char_nl(); $s1 = $this->peg_parsechem_char_nl();
if ($s1 !== $this->peg_FAILED) { if ($s1 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f70($s1); $s1 = $this->peg_f72($s1);
} }
$s0 = $s1; $s0 = $s1;
if ($s0 === $this->peg_FAILED) { if ($s0 === $this->peg_FAILED) {
@ -3326,7 +3356,7 @@ class Parser {
$s1 = $this->peg_parseCHEM_LETTER(); $s1 = $this->peg_parseCHEM_LETTER();
if ($s1 !== $this->peg_FAILED) { if ($s1 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f71($s1); $s1 = $this->peg_f73($s1);
} }
$s0 = $s1; $s0 = $s1;
} }
@ -3350,7 +3380,7 @@ class Parser {
$s1 = $this->peg_parsechem_script(); $s1 = $this->peg_parsechem_script();
if ($s1 !== $this->peg_FAILED) { if ($s1 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f70($s1); $s1 = $this->peg_f72($s1);
} }
$s0 = $s1; $s0 = $s1;
if ($s0 === $this->peg_FAILED) { if ($s0 === $this->peg_FAILED) {
@ -3362,7 +3392,7 @@ class Parser {
$s3 = $this->peg_parseCURLY_CLOSE(); $s3 = $this->peg_parseCURLY_CLOSE();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f72($s2); $s1 = $this->peg_f74($s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -3385,7 +3415,7 @@ class Parser {
$s3 = $this->peg_parseEND_MATH(); $s3 = $this->peg_parseEND_MATH();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f73($s2); $s1 = $this->peg_f75($s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -3406,7 +3436,7 @@ class Parser {
$s2 = $this->peg_parsechem_bond(); $s2 = $this->peg_parsechem_bond();
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f30($s1, $s2); $s1 = $this->peg_f32($s1, $s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -3421,7 +3451,7 @@ class Parser {
$s1 = $this->peg_parsechem_macro(); $s1 = $this->peg_parsechem_macro();
if ($s1 !== $this->peg_FAILED) { if ($s1 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f66($s1); $s1 = $this->peg_f68($s1);
} }
$s0 = $s1; $s0 = $s1;
if ($s0 === $this->peg_FAILED) { if ($s0 === $this->peg_FAILED) {
@ -3429,7 +3459,7 @@ class Parser {
$s1 = $this->peg_parseCHEM_NONLETTER(); $s1 = $this->peg_parseCHEM_NONLETTER();
if ($s1 !== $this->peg_FAILED) { if ($s1 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f71($s1); $s1 = $this->peg_f73($s1);
} }
$s0 = $s1; $s0 = $s1;
} }
@ -3461,7 +3491,7 @@ class Parser {
$s3 = $this->peg_parseCURLY_CLOSE(); $s3 = $this->peg_parseCURLY_CLOSE();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f74($s2); $s1 = $this->peg_f76($s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -3497,7 +3527,7 @@ class Parser {
$s2 = $this->peg_parseCHEM_SCRIPT_FOLLOW(); $s2 = $this->peg_parseCHEM_SCRIPT_FOLLOW();
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f75($s1, $s2); $s1 = $this->peg_f77($s1, $s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -3514,7 +3544,7 @@ class Parser {
$s2 = $this->peg_parsechem_lit(); $s2 = $this->peg_parsechem_lit();
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f76($s1, $s2); $s1 = $this->peg_f78($s1, $s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -3535,7 +3565,7 @@ class Parser {
$s4 = $this->peg_parseEND_MATH(); $s4 = $this->peg_parseEND_MATH();
if ($s4 !== $this->peg_FAILED) { if ($s4 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f77($s1, $s3); $s1 = $this->peg_f79($s1, $s3);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -3589,7 +3619,7 @@ class Parser {
$s4 = $this->peg_parsechem_lit(); $s4 = $this->peg_parsechem_lit();
if ($s4 !== $this->peg_FAILED) { if ($s4 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f78($s1, $s2, $s4); $s1 = $this->peg_f80($s1, $s2, $s4);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -3616,7 +3646,7 @@ class Parser {
$s3 = $this->peg_parsechem_lit(); $s3 = $this->peg_parsechem_lit();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f33($s1, $s2, $s3); $s1 = $this->peg_f35($s1, $s2, $s3);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -3639,7 +3669,7 @@ class Parser {
$s3 = $this->peg_parsechem_lit(); $s3 = $this->peg_parsechem_lit();
if ($s3 !== $this->peg_FAILED) { if ($s3 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f33($s1, $s2, $s3); $s1 = $this->peg_f35($s1, $s2, $s3);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -3660,7 +3690,7 @@ class Parser {
$s2 = $this->peg_parsechem_lit(); $s2 = $this->peg_parsechem_lit();
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f30($s1, $s2); $s1 = $this->peg_f32($s1, $s2);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -3702,7 +3732,7 @@ class Parser {
} }
if ($s1 !== $this->peg_FAILED) { if ($s1 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f79($s1); $s1 = $this->peg_f81($s1);
} }
$s0 = $s1; $s0 = $s1;
@ -3760,7 +3790,7 @@ class Parser {
$s6 = $this->peg_parse_(); $s6 = $this->peg_parse_();
if ($s6 !== $this->peg_FAILED) { if ($s6 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f80($s3); $s1 = $this->peg_f82($s3);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -4006,7 +4036,7 @@ class Parser {
$s1 = $this->peg_parsegeneric_func(); $s1 = $this->peg_parsegeneric_func();
if ($s1 !== $this->peg_FAILED) { if ($s1 !== $this->peg_FAILED) {
$this->peg_reportedPos = $this->peg_currPos; $this->peg_reportedPos = $this->peg_currPos;
$s2 = $this->peg_f81($s1); $s2 = $this->peg_f83($s1);
if ($s2) { if ($s2) {
$s2 = null; $s2 = null;
} else { } else {
@ -4049,7 +4079,7 @@ class Parser {
$s7 = $this->peg_parse_(); $s7 = $this->peg_parse_();
if ($s7 !== $this->peg_FAILED) { if ($s7 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f82($s1, $s5); $s1 = $this->peg_f84($s1, $s5);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -4121,7 +4151,7 @@ class Parser {
$s2 = $this->peg_parse_(); $s2 = $this->peg_parse_();
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f83($s1); $s1 = $this->peg_f85($s1);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -4131,86 +4161,6 @@ class Parser {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
$s0 = $this->peg_FAILED; $s0 = $this->peg_FAILED;
} }
if ($s0 === $this->peg_FAILED) {
$s0 = $this->peg_currPos;
$s1 = $this->peg_parsegeneric_func();
if ($s1 !== $this->peg_FAILED) {
$this->peg_reportedPos = $this->peg_currPos;
$s2 = $this->peg_f84($s1);
if ($s2) {
$s2 = null;
} else {
$s2 = $this->peg_FAILED;
}
if ($s2 !== $this->peg_FAILED) {
$s3 = $this->peg_parse_();
if ($s3 !== $this->peg_FAILED) {
if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c3) {
$s4 = $this->peg_c3;
$this->peg_currPos++;
} else {
$s4 = $this->peg_FAILED;
if ($this->peg_silentFails === 0) {
$this->peg_fail($this->peg_c4);
}
}
if ($s4 === $this->peg_FAILED) {
if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c5) {
$s4 = $this->peg_c5;
$this->peg_currPos++;
} else {
$s4 = $this->peg_FAILED;
if ($this->peg_silentFails === 0) {
$this->peg_fail($this->peg_c6);
}
}
if ($s4 === $this->peg_FAILED) {
if ($this->input_substr($this->peg_currPos, 2) === $this->peg_c7) {
$s4 = $this->peg_c7;
$this->peg_currPos += 2;
} else {
$s4 = $this->peg_FAILED;
if ($this->peg_silentFails === 0) {
$this->peg_fail($this->peg_c8);
}
}
if ($s4 === $this->peg_FAILED) {
$s4 = $this->peg_currPos;
$s5 = $this->peg_c2;
if ($s5 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s4;
$s5 = $this->peg_f20($s1);
}
$s4 = $s5;
}
}
}
if ($s4 !== $this->peg_FAILED) {
$s5 = $this->peg_parse_();
if ($s5 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0;
$s1 = $this->peg_f85($s1, $s4);
$s0 = $s1;
} else {
$this->peg_currPos = $s0;
$s0 = $this->peg_FAILED;
}
} else {
$this->peg_currPos = $s0;
$s0 = $this->peg_FAILED;
}
} else {
$this->peg_currPos = $s0;
$s0 = $this->peg_FAILED;
}
} else {
$this->peg_currPos = $s0;
$s0 = $this->peg_FAILED;
}
} else {
$this->peg_currPos = $s0;
$s0 = $this->peg_FAILED;
}
if ($s0 === $this->peg_FAILED) { if ($s0 === $this->peg_FAILED) {
$s0 = $this->peg_currPos; $s0 = $this->peg_currPos;
$s1 = $this->peg_parsegeneric_func(); $s1 = $this->peg_parsegeneric_func();
@ -4537,7 +4487,7 @@ class Parser {
$s2 = $this->peg_parse_(); $s2 = $this->peg_parse_();
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f83($s1); $s1 = $this->peg_f85($s1);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -4581,7 +4531,6 @@ class Parser {
} }
} }
} }
}
$this->peg_cache[$key] = array ("nextPos" => $this->peg_currPos, "result" => $s0 ); $this->peg_cache[$key] = array ("nextPos" => $this->peg_currPos, "result" => $s0 );
@ -4618,7 +4567,7 @@ class Parser {
$s2 = $this->peg_parse_(); $s2 = $this->peg_parse_();
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f83($s1); $s1 = $this->peg_f85($s1);
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -6396,7 +6345,7 @@ class Parser {
} }
if ($s2 !== $this->peg_FAILED) { if ($s2 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f59(); $s1 = $this->peg_f61();
$s0 = $s1; $s0 = $s1;
} else { } else {
$this->peg_currPos = $s0; $this->peg_currPos = $s0;
@ -9252,7 +9201,7 @@ class Parser {
} }
if ($s1 !== $this->peg_FAILED) { if ($s1 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f83($s1); $s1 = $this->peg_f85($s1);
} }
$s0 = $s1; $s0 = $s1;
if ($s0 === $this->peg_FAILED) { if ($s0 === $this->peg_FAILED) {
@ -9268,7 +9217,7 @@ class Parser {
} }
if ($s1 !== $this->peg_FAILED) { if ($s1 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f83($s1); $s1 = $this->peg_f85($s1);
} }
$s0 = $s1; $s0 = $s1;
if ($s0 === $this->peg_FAILED) { if ($s0 === $this->peg_FAILED) {
@ -9284,7 +9233,7 @@ class Parser {
} }
if ($s1 !== $this->peg_FAILED) { if ($s1 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f83($s1); $s1 = $this->peg_f85($s1);
} }
$s0 = $s1; $s0 = $s1;
if ($s0 === $this->peg_FAILED) { if ($s0 === $this->peg_FAILED) {
@ -9300,7 +9249,7 @@ class Parser {
} }
if ($s1 !== $this->peg_FAILED) { if ($s1 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f83($s1); $s1 = $this->peg_f85($s1);
} }
$s0 = $s1; $s0 = $s1;
if ($s0 === $this->peg_FAILED) { if ($s0 === $this->peg_FAILED) {
@ -9308,7 +9257,7 @@ class Parser {
$s1 = $this->peg_parseliteral_mn(); $s1 = $this->peg_parseliteral_mn();
if ($s1 !== $this->peg_FAILED) { if ($s1 !== $this->peg_FAILED) {
$this->peg_reportedPos = $s0; $this->peg_reportedPos = $s0;
$s1 = $this->peg_f83($s1); $s1 = $this->peg_f85($s1);
} }
$s0 = $s1; $s0 = $s1;
if ($s0 === $this->peg_FAILED) { if ($s0 === $this->peg_FAILED) {

View file

@ -137,6 +137,16 @@ lit
$this->line(), $this->column()); $this->line(), $this->column());
} }
} }
/ f:generic_func &{ return $this->tu->mediawiki_function_names($f); } _
{
if(is_array($f)) {
// This is an unexpected case, but covers the ambiguity of slice in javascript.
$fProcessed = implode(array_slice($f, 1));
} else {
$fProcessed = substr($f,1);
}
return new Fun1nb( '\\operatorname', new Literal( $fProcessed ) );
}
/ r:DELIMITER { return new Literal($r); } / r:DELIMITER { return new Literal($r); }
/ b:BIG r:DELIMITER { return new Big($b, $r); } / b:BIG r:DELIMITER { return new Big($b, $r); }
/ b:BIG SQ_CLOSE { return new Big($b, "]"); } / b:BIG SQ_CLOSE { return new Big($b, "]"); }
@ -144,7 +154,7 @@ lit
/ name:FUN_AR1opt e:expr_nosqc SQ_CLOSE l:lit /* must be before FUN_AR1 */ / name:FUN_AR1opt e:expr_nosqc SQ_CLOSE l:lit /* must be before FUN_AR1 */
{ return new Fun2sq($name, $e->setCurly(), $l); } { return new Fun2sq($name, $e->setCurly(), $l); }
/ name:FUN_AR1 l:lit { return new Fun1($name, $l); } / name:FUN_AR1 l:lit { return new Fun1($name, $l); }
/ name:FUN_AR1nb l:lit {return new Fun1nb($name, $l); } / name:FUN_AR1nb l:lit { return new Fun1nb($name, $l); }
/ name:FUN_MHCHEM l:chem_lit { return new Mhchem($name, $l); } / name:FUN_MHCHEM l:chem_lit { return new Mhchem($name, $l); }
/ name:FUN_AR2 l1:lit l2:lit { return new Fun2($name, $l1, $l2); } / name:FUN_AR2 l1:lit l2:lit { return new Fun2($name, $l1, $l2); }
/ name:FUN_AR4_MHCHEM_TEXIFIED l1:lit l2:lit l3:lit l4:lit { return new Fun4($name, $l1, $l2, $l3, $l4); } / name:FUN_AR4_MHCHEM_TEXIFIED l1:lit l2:lit l3:lit l4:lit { return new Fun4($name, $l1, $l2, $l3, $l4); }
@ -317,17 +327,6 @@ BOX
LITERAL LITERAL
= c:( literal_id / literal_mn / literal_uf_lt / "-" / literal_uf_op ) _ = c:( literal_id / literal_mn / literal_uf_lt / "-" / literal_uf_op ) _
{ return $c; } { return $c; }
/ f:generic_func &{ return $this->tu->mediawiki_function_names($f); } _
c:( "(" / "[" / "\\{" / "" { return " ";}) _
{
if(is_array($f)) {
// This is an unexpected case, but covers the ambiguity of slice in javascript.
$fProcessed = implode(array_slice($f, 1));
} else {
$fProcessed = substr($f,1);
}
return "\\operatorname {" . $fProcessed . "}" . $c;
}
/ f:generic_func &{ return $this->tu->nullary_macro($f); } _ // from Texutil.find(...) / f:generic_func &{ return $this->tu->nullary_macro($f); } _ // from Texutil.find(...)
{ return $f . " "; } { return $f . " "; }
/ f:generic_func &{ return $this->options['usemathrm'] && $this->tu->nullary_macro_in_mbox($f); } _ // from Texutil.find(...) / f:generic_func &{ return $this->options['usemathrm'] && $this->tu->nullary_macro_in_mbox($f); } _ // from Texutil.find(...)

View file

@ -69,13 +69,20 @@ class AllTest extends MediaWikiUnitTestCase {
], ],
'MediaWiki functions' => [ 'MediaWiki functions' => [
[ [
'input' => '\\arccot\\arcsec\\arccsc\\sgn\\sen', 'input' => '\\arccot \\arcsec \\arccsc \\sgn \\sen ',
'output' => 'output' =>
'\\operatorname {arccot} \\operatorname {arcsec} ' . '\\operatorname {arccot} \\operatorname {arcsec} ' .
'\\operatorname {arccsc} \\operatorname {sgn} ' . '\\operatorname {arccsc} \\operatorname {sgn} ' .
'\\operatorname {sen} ' '\\operatorname {sen} '
] ]
], ],
'MediaWiki functions args' => [
[
'input' => '\\arccot(x)\\sen(x)\\sen{x}',
'output' =>
'\\operatorname {arccot} (x)\\operatorname {sen} (x)\\operatorname {sen} {x}'
]
],
'Literals (1)' => [ 'Literals (1)' => [
[ [
'input' => 'input' =>