Skip to content

Push different types to the deque #6

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

RedmanPlus
Copy link

I've added several checks for the interpreter so it now can differenciate between ints, floats and strings in a language. To push the string to the deque you simply need to wrap the value into '' brackets, and add a dot somewhere in a number to push a float.

@@ -152,15 +156,44 @@ def pop_data():
elif word == 'print':
print(pop_data())
ip += 1
elif word == 'printType':

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more versatile to have an instruction that pushes the type as a string to the stack, which would also let you print it with the print instruction.

@@ -0,0 +1,3 @@
0! '0'!
!'I have a crush on you' !printType
0.1! 0.2! +! print!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatever code editor you're using messed up the formatting—this file should have a trailing newline.

Comment on lines +168 to +169
word = word[1:]
word = word[:-1]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

word[1:-1]

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.

2 participants