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

16h OOP: Tokens #43

Merged
merged 9 commits into from
May 4, 2022
Merged

16h OOP: Tokens #43

merged 9 commits into from
May 4, 2022

Conversation

ngjunsiang
Copy link
Contributor

Finally, let's objectify tokens, making a Token class. Our code works fine as it is ... but why work with dicts if an object makes things clearer?

@ngjunsiang
Copy link
Contributor Author

ngjunsiang commented May 4, 2022

Start with a Token class:
https://github.com/nyjc-computing/pseudo/blob/31f3928df82253d70042e85cfc5d0f674ad97c0b/lang.py#L1-L14

Replace all our makeToken() calls with Token instantiations: [1c31405], [f40c1c7]

And update all uses of token to convert keys to attributes: [9d0c9da]

Cleanup

Now we can remove unnecessary imports, breaking the cursed dependency of our parser on the scanner: [42e10dc]

And eliminate the Return Stmt, which should have been done a few chapters ago: [0562ab9]

And fix a typo: [b670260]

@ngjunsiang
Copy link
Contributor Author

And we have Token objects!

@ngjunsiang ngjunsiang merged commit e9fe155 into main May 4, 2022
@ngjunsiang ngjunsiang deleted the oop branch May 4, 2022 07:27
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

Successfully merging this pull request may close these issues.

None yet

1 participant