Skip to content

Commit fc0e8a5

Browse files
committed
distinguish meaning of ! in prefix and postfix position
1 parent 4584aca commit fc0e8a5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/LaTeXML/Package/pgfmath.code.tex.ltxml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ sub pgfmath_checkuserfunction {
558558

559559
BEGIN {
560560
$PGFMathFunctions = {
561+
'!pref' => sub { int(!$_[0]); },
561562
not => sub { int(!$_[0]) },
562563
'==' => sub { int($_[0] == $_[1]) },
563564
equal => sub { int($_[0] == $_[1]) },
@@ -589,7 +590,7 @@ BEGIN {
589590
'/' => sub { $_[0] / pgfmath_divisor($_[1]); },
590591
divide => sub { $_[0] / pgfmath_divisor($_[1]); },
591592
div => sub { int($_[0] / pgfmath_divisor($_[1])); },
592-
'!' => sub { pgfmathfactorial($_[0]); },
593+
'!post' => sub { pgfmathfactorial($_[0]); },
593594
'r' => sub { rad2deg($_[0]); },
594595
e => sub { $E; },
595596
pi => sub { $PI; },
@@ -769,8 +770,13 @@ SIZER : /(?:depth|height|width)/
769770
QTEX : '"' /[^"]*/ '"' { $item[2]; }
770771
CMP : /==|>=?|<=?|!=/
771772
BOOLOP : /&&|\|\|/
772-
PREFIX : /-|!|\+/
773-
POSTFIX : /!|r/
773+
774+
# the meaning of ! depends on its position
775+
# pgfmathparser has a hardcoded notion of 'double character' operator
776+
# '!' could be part of '!=', so we forbid that sequence
777+
PREFIX : /-|\+/ | '!' ...!'=' { '!pref'; }
778+
POSTFIX : 'r' | '!' ...!'=' { '!post'; }
779+
774780
ADDOP : /\+|=|-/
775781
MULOP : /\*|\//
776782

0 commit comments

Comments
 (0)