# operators syntax: macros instead of abstract syntax trees

Published 2020-05-09T16:01:00.004Z by Physics Derivation Graph

Currently the JSON file has a set of named operators with the attributes "argument count", "latex", "scope". The "argument count" is a non-negative integer and the "scope" is a list with elements like real, complex, vector, matrix. integer.

What's missing is the AST structure that defines where the arguments go with respect to the operator. For example,
x + y
is valid while
x y +
is not.

Similarly,
cos x
is valid while
x cos
is not.

While I can state these concepts I don't know how to formalize the notation.
For example, a definite integral takes 4 arguments in a specific location:
int_x^y f(z) dz

I could express operators using a latex macro

\documentclass[12pt]{article}
\usepackage{amsmath,amssymb,amsfonts}
\newcommand\subtraction[2]{ #1 - #2}
\newcommand\divisionSameLine[2]{ #1 / #2 }
\newcommand\divisionFrac[2]{ \frac{ #1}{ #2} }
\newcommand\integralDefinite[4]{ \int_{ #1}^{ #2} #3 #4}
\newcommand\addXtobothsides[3]{Add $#1$ to both sides of Eq.~\ref{eq:#2}; yields Eq.~\ref{eq:#3}.}
\title{Lorentz transformation}
\date{\today}
\setlength{\topmargin}{-.5in}
\setlength{\textheight}{9in}
\setlength{\oddsidemargin}{0in}
\setlength{\textwidth}{6.5in}
\begin{document}
\maketitle
\begin{abstract}
This is the abstract
\end{abstract}

$$\addition{a}{b}$$

$$\divisionFrac{a}{b}$$

$$\integralDefinite{a}{b}{f(x)}{dx}$$

\end{document}


Compile to PDF using

latex runthis.tex
latex runthis.tex
dvipdfmx runme.dvi