This week, I buckled down and wrote a recursive descent parsing class for my language. I am in the process of testing it right now, so I'm not sure exactly what it's weaknesses are yet, if there are any (probably so). I wrote each function individually and then pieced them all together, so I'm unsure if everything is perfectly matched up. The structure mirrors jim's parser, presented on the home page. I still need to add doctests to the file as well, once I figure out what makes the most sense to test...small cases that capture every possible pitfall will take a bit to write for each case, but should be simple in and of themselves.
Output currently when running tweetex.py:
hypatia@Yours-MacBook-Air:https://cs.marlboro.college/cours/fall2019/jims_tutorials/MEGA/plan work/programming_languages$ python3 tweetex.py basictweetex.twx
Token('None', 'STORY', 'None')
Token('None', 'PREAMBLE', 'None')
Token('None', 'PREAMBLE', 'None')
Token('None', 'MACRO', 'None')
Token('title', 'COMMAND', '\title')
Token('None', 'ARGUMENT', 'None')
Token('My Story', 'CHARACTER', 'My Story')
Something isn't right. Seems preamble is getting called more than once and I'm not sure the list of tokens is actually being exhausted (there should be more here...) but I haven't given it a close look.
last modified | size | ||
basictweetex.twx | Sun Dec 22 2024 01:59 pm | 300B | |
lexer.py | Sun Dec 22 2024 01:59 pm | 3.8K | |
parser.py | Sun Dec 22 2024 01:59 pm | 6.4K | |
tweetex.py | Sun Dec 22 2024 01:59 pm | 1.1K |