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

Can i define lexer in the form of classes? #85

Closed
ishankhare07 opened this issue Nov 18, 2015 · 2 comments
Closed

Can i define lexer in the form of classes? #85

ishankhare07 opened this issue Nov 18, 2015 · 2 comments

Comments

@ishankhare07
Copy link

instead of defining regex rules in individual functions with names like t_<some_name>
can't we use python classes to define these functions in, and then pass a class instance to lex.lex()?

I'm new to writing lexers/parsers as part of my course on compilers, so I might as well ask :-
Can this be done in the current implementation?
and if not, is it even fruitful and beneficial in some way?

@refi64
Copy link

refi64 commented Nov 18, 2015

What about something like this?

@ishankhare07
Copy link
Author

@kirbyfan64 thanks,
that's exactly what i was looking for!

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