I'm reading about AST (abstract syntax trees) but all the samples I see use expressions such as:
a + b * c
Which could be represented in a lispy like syntax as:
(+ a (* b c) )
Which will be the equivalent to:
+
/
a *
/
b c
My question is How an AST for a class in a OOPL would look like?
My naive attempt is for this Java code:
class Person {
String name;
int age;
public String toString() {
return "name";
}
}
Is:
;Hand written
(classDeclaration Person
(varDeclaration String name)
(varDeclaration int age )
(funcDeclaration String toString
(return "name")
)
)
But I'm not quite sure how close or far am I to a real AST representation.
Does it depends on the language I choose. How much detail is needed? Are those "xyzDeclaraction" needed or could be as:
(Person (String name) (int age))
Where can I see a "real" representation of an actual programming language to learn more.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…