3 ms·
> What else would you use to represent a syntax tree? Different syntax for different concepts, easier for the eye, quicker the understanding, troubleshooting.
by bmacho 3y ago
> What else would you use to represent a syntax tree?
Different syntax for different concepts, easier for the eye, quicker the understanding, troubleshooting.
- kragen 3y agomyself i'm partial to rose trees rather than (set (aref a i) (+ i j)) you have set(aref(a i) +(i j)) and no difference between i and i(), and only one type of node, with a tag and zero or more kids, instead of separate node types for having kids and having tags the rose tree model feels like a slightly closer fit to the needs of abstract syntax trees, and although it isn't simpler than sexps, it isn't more complicated either another possibility is the ml approach where juxtaposition denotes function application but the functions are curried so they only ever take a single argument, which usually looks exactly the same as sexps but conceptually associates the other way set (aref a i) (+ i j) the only difference is that this is equivalent, which i think is worse in this context: set ((aref a) i) ((+ i) j) (note that ml only uses this approach for expressions to evaluate. for data, such as asts, it uses the rose tree approach) regardless, the semantics are a lot more important than the syntax