Hey there! I’m Josh Vasquez, and I’m thrilled to share the Lexer-Parser-Interpreter Project with you. It’s all about making sense of SIMPLE code from a .txt file, and it does this through a few neat steps to ensure everything checks out perfectly.
First up, we have Lexer.java. This little guy scans the text file and breaks it down into something called tokens. These tokens are pretty straightforward: IDTOKENs for strings that start with a letter, INTTOKENs for number strings, ASSNMTTOKENs for "=" showing assignments, PLUSTOKENs for "+" indicating addition, and EOFTOKENs—a dash "-" that tells us we've reached the end. Every file ends with an EOFTOKEN, just to keep things tidy.
Next, Parser.java jumps into the mix. It takes these tokens and decides if the SIMPLE code is playing by the rules. If everything’s good, it proudly declares "Valid Program." But if something's off, it'll tell you exactly what went wrong, where it happened, and calls it an "Invalid Program." It’s all about making sure we’re set for the next part without any hiccups.
The final piece of the puzzle is ByteCodeInterpreter.java. Let’s say our file "plain.txt" has the line
"x = 5 y = x + 6."
Parser turns that into a cool string of numbers, our bytecode, which looks like:
"1, 5, 2, 0, 0, 0, 1, 6, 2, 1."
ByteCodeInterpreter takes this, runs with it, and updates our memory spots to show the results of our operations—ending up with "5, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0." We start with a memory size of 10, but hey, adjust it as you need!
Through this blend of lexical analysis, parsing, and interpretation, this project really digs into the nitty-gritty of the SIMPLE programming language, making sure each program is not only correct syntactically but also runs just right.
If you’re curious to see how it all works or want to get your hands on the code, don’t hesitate to swing by my GitHub or shoot me a message via email or LinkedIn. Can’t wait to hear what you think!