Skip to content
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

ModelBuilderSemantics Subclassing #70

Closed
Victorious3 opened this issue Jul 12, 2018 · 4 comments
Closed

ModelBuilderSemantics Subclassing #70

Victorious3 opened this issue Jul 12, 2018 · 4 comments

Comments

@Victorious3
Copy link
Collaborator

start = expression $;

expression =
    | addition
    | subtraction
    | number;

addition::BinaryOp::Op = left:expression op:'+' ~ right:number;
subtraction::BinaryOp::Op = left:expression op:'-' ~ right:number;

number = /\d+/;

This triggers an exception: https://pastebin.com/raw/qMUUXEKb
It works when you remove left:expression in addition and subtraction

I'm not sure how this feature is supposed to work in the first place, how does it decide what to put on the base class and what on the inherited one? I suppose the workaround would be to create the base class manually and pass it to the ModelBuilderSemantics instance.

In either case, this should be documented better.

@apalala
Copy link
Collaborator

apalala commented Aug 5, 2018

Python 3.7 is recent, and the semantics of metaclasses may have changed to better support typing. This case should be added as a unit test.

@Victorious3
Copy link
Collaborator Author

Victorious3 commented Aug 29, 2018

This isn't just broken in 3.7. While the above compiles on 3.5, BinaryOp doesn't end up being a subclass of Op either. I'll see if I can come up with a fix.
Edit: As I found out, you are supposed to generate the object model as well and then use that as an instance. It's quite dubious, and not documented.

@Victorious3
Copy link
Collaborator Author

Victorious3 commented Aug 30, 2018

@apalala What's supposed to happen if there are multiple base classes?

rule2::A::B::C = a:();

Is B a subclass of C now, and A a subclass of B?
Or does A inherit from B and C, and B is unrelated to C?

@apalala
Copy link
Collaborator

apalala commented Oct 26, 2018

@apalala What's supposed to happen if there are multiple base classes?

rule2::A::B::C = a:();

Is B a subclass of C now, and A a subclass of B?
Or does A inherit from B and C, and B is unrelated to C?

TasSu currently doesn't check that the inheritance tree makes sense. I guess the Python compiler will err if the generated Python is no good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants