Skip to content

Instantly share code, notes, and snippets.

@cwgreene
Created April 23, 2016 17:08
Show Gist options
  • Save cwgreene/cb29468bc7243c5ed5a1e43d01dfff59 to your computer and use it in GitHub Desktop.
Save cwgreene/cb29468bc7243c5ed5a1e43d01dfff59 to your computer and use it in GitHub Desktop.
import sys
array = []
class Token():
def __init__(self, input):
if input[0].isdigit:
self.type = "INT"
self.value = int(input)
else:
self.type = "STRING"
self.value = input
def main():
afile = open(sys.argv[1]).read()
res = afile.split()
for token in res:
if token:
array.append(Token(token))
for a in array:
print a.type, a.value
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment