This is the pyparsing-based parser for math expressions. It actually parses full strings *containing* math expressions, in that raw text may also appear outside of pairs of ``$``. The grammar is based directly on that in TeX, though it cuts a few corners.
| 2200 | return empty |
| 2201 | |
| 2202 | class Parser(object): |
| 2203 | """ |
| 2204 | This is the pyparsing-based parser for math expressions. It |
| 2205 | actually parses full strings *containing* math expressions, in |
| 2206 | that raw text may also appear outside of pairs of ``$``. |
| 2207 | |
| 2208 | The grammar is based directly on that in TeX, though it cuts a few |
| 2209 | corners. |
| 2210 | """ |
| 2211 | |
| 2212 | _math_style_dict = dict(displaystyle=0, textstyle=1, |
| 2213 | scriptstyle=2, scriptscriptstyle=3) |
| 2214 | |
| 2215 | _binary_operators = set(''' |
| 2216 | + * - |
| 2217 | \\pm \\sqcap \\rhd |
| 2218 | \\mp \\sqcup \\unlhd |
| 2219 | \\times \\vee \\unrhd |
| 2220 | \\div \\wedge \\oplus |
| 2221 | \\ast \\setminus \\ominus |
| 2222 | \\star \\wr \\otimes |
| 2223 | \\circ \\diamond \\oslash |
| 2224 | \\bullet \\bigtriangleup \\odot |
| 2225 | \\cdot \\bigtriangledown \\bigcirc |
| 2226 | \\cap \\triangleleft \\dagger |
| 2227 | \\cup \\triangleright \\ddagger |
| 2228 | \\uplus \\lhd \\amalg'''.split()) |
| 2229 | |
| 2230 | _relation_symbols = set(''' |
| 2231 | = < > : |
| 2232 | \\leq \\geq \\equiv \\models |
| 2233 | \\prec \\succ \\sim \\perp |
| 2234 | \\preceq \\succeq \\simeq \\mid |
| 2235 | \\ll \\gg \\asymp \\parallel |
| 2236 | \\subset \\supset \\approx \\bowtie |
| 2237 | \\subseteq \\supseteq \\cong \\Join |
| 2238 | \\sqsubset \\sqsupset \\neq \\smile |
| 2239 | \\sqsubseteq \\sqsupseteq \\doteq \\frown |
| 2240 | \\in \\ni \\propto \\vdash |
| 2241 | \\dashv \\dots \\dotplus \\doteqdot'''.split()) |
| 2242 | |
| 2243 | _arrow_symbols = set(''' |
| 2244 | \\leftarrow \\longleftarrow \\uparrow |
| 2245 | \\Leftarrow \\Longleftarrow \\Uparrow |
| 2246 | \\rightarrow \\longrightarrow \\downarrow |
| 2247 | \\Rightarrow \\Longrightarrow \\Downarrow |
| 2248 | \\leftrightarrow \\longleftrightarrow \\updownarrow |
| 2249 | \\Leftrightarrow \\Longleftrightarrow \\Updownarrow |
| 2250 | \\mapsto \\longmapsto \\nearrow |
| 2251 | \\hookleftarrow \\hookrightarrow \\searrow |
| 2252 | \\leftharpoonup \\rightharpoonup \\swarrow |
| 2253 | \\leftharpoondown \\rightharpoondown \\nwarrow |
| 2254 | \\rightleftharpoons \\leadsto'''.split()) |
| 2255 | |
| 2256 | _spaced_symbols = _binary_operators | _relation_symbols | _arrow_symbols |
| 2257 | |
| 2258 | _punctuation_symbols = set(r', ; . ! \ldotp \cdotp'.split()) |
| 2259 |
no test coverage detected