This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from subprocess import run | |
import sympy as sp | |
def print_to_file(fname, expr): | |
# See https://tex.stackexchange.com/questions/34054/tex-to-image-over-command-line/34058#34058 | |
t_start = r"""\documentclass[border=2pt]{standalone} | |
\usepackage{amsmath} | |
\usepackage{varwidth} | |
\begin{document} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grammar CFunction; | |
function : retType name args ; | |
args : '(' arg (',' arg)* ')' ; | |
arg | |
: 'double' name # SCALAR_ARG | |
| 'double' '*' name # ARRAY_ARG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grammar Expr; | |
// Need to call recursive rule expr from non-recursive rule | |
r : expr+ ; | |
// ANTLR4 : Left recursion! | |
// Operator precedence matches order of definition | |
expr : '-' expr // Unary minus | |
| expr ('*' | '/' ) expr | |
| expr ('+' | '-' ) expr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// define a grammar called Hello | |
grammar Hello; | |
r : 'hello' ID; | |
ID : [a-z]+ ; | |
WS : [ \t\r\n]+ -> skip ; |
OlderNewer