Toy weekend project: make a parser-parser!
This takes in a grammar given in Bakus-Naur Form (BNF),
and a program that was written in the provided grammar,
and produces an image of Syntax Tree using graphviz
.
References:
#!/usr/bin/env python | |
from math import atan2, pi, sqrt | |
''' | |
Our goal is to figure out an analytic formulation of the area the goat can reach. | |
*Note:* We'll take advantage of symmetry to only solve the top half of the area. | |
We have two circles which intersect: |
#!/usr/bin/env python | |
import numpy as np | |
from collections import OrderedDict | |
from scipy.optimize import LinearConstraint, minimize, BFGS | |
def normlen(v): | |
''' length of norm of a vector ''' | |
return np.sqrt(np.sum(np.square(v))) |