-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loyc.Syntax - how are classes (etc) represented? #4
Comments
Loyc.Syntax implements Loyc trees, which only define literals, identifiers, calls and attributes. EC# is defined in terms of these concepts. For example Using the Loyc.Ecs package you can construct one of these call nodes from text using ParseSingle, e.g.
There are methods in LNode name, baseList, body;
Symbol kind = EcsValidators.SpaceDefinitionKind(node, out name, out bases, out body);
if (kind == CodeSymbols.Class)
Console.WriteLine("class {0} has these base types: {1}", name.Name, bases);
else
Console.WriteLine("it wasn't a class"); It's called If you're using LeMP/EC# it is easier to construct and detect these syntax trees using the LNode node = quote {
public class Derived: Base {}
};
matchCode(node) {
case { class $name: $(..baseList) { $(.._); } }:
Console.WriteLine("class {0} has these base types: {1}",
name.Name, String.Join(" ", baseList));
default:
Console.WriteLine("it wasn't a class");
} Tips:
|
It should be understood that Loyc trees themselves do not understand classes, functions, events, properties or anything else. Loyc trees are like XML: XML doesn't understand that |
does a class node for example exists in loyc.syntax? its unusual to make an ast only for commands. i cant map properties events classes and so on?
The text was updated successfully, but these errors were encountered: