Kevin Luludis

Ranch Hand
+ Follow
since Feb 13, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kevin Luludis

Thanks alot Jim. I'll try this and see what happens. And as for the formatting, I have had trouble with that forever. Cutting and pasting from the IDE to the web never seems to work out right for me. I'll also try your advice on that too. Thanks again, and I'll let you know how I make out with StringTokenizer. Best Regards.
Kevin
18 years ago
Im not sure if this was too much of an advanced request, but no one is answering in the other forum, so Ill try my luck here.
http://www.javaranch.com/ubb/Forum38/HTML/000313.html
Anyway, I keep trugging along slowly but surely. Here is my next question.
How would you use replace the lexer in the code below using StringTokenizer so I can parse words and numbers. The way it is now, it is only capable of parsing 1 letter and 1 digit expressions with no spaces in between. I am trying to make it grow and more flexible, but i keep "breaking" the software. Right now it will do this just fine:
C:\jdk1.3\bin>java compiler
Please enter your expression --> a=p*3+b/c- The postfix form is a p 3 * b c / + o - =
The next step is to have it do this
C:\jdk1.3\bin>java compiler
The postfix form is apple pear 354 * banana 879 / + orange - =
The file read in will contain the text:
apple = pear * 354 + banana / 879 - orange
Please help, Thanks in advance.
The compiler.java file is located at: http://members.nbci.com/acidmaxx/Compiler/compiler.java.html

Thanks again, and Happy Easter.
18 years ago
Hey all, I dont know if anyone remembers, but I have been working on this project since the beginning of the year. It is a "BABY" compiler. So far I have this :

This does a nice post fix parse of any expression you enter on the command line such as this.

java parser a=b+c*d-e/f

And will postfix parse it to a b c d * + e f / - =
This is great because later on i will be pushing and popping from the stack the individual tokens in this manner. I would like to implement either StringTokenizer or StreamTokenizer in order to be able to handle Identifiers, Digits, and Operators. So far all this handles is 1 variable at a time a, b, c, etc, each separated by an operator with NO whitespace. Please let me know what you would do here at this point. Whitespace is not an issue, as I would like to ignore it, but not necessarily use it as a delimiter. Either way I welcome any and all suggestions. Thanks again!
18 years ago
I too have had questions about these Tokenizers. You can check these out. Hope they help
http://www.javaranch.com/ubb/Forum33/HTML/001815.html
http://www.javaranch.com/ubb/Forum34/HTML/000704.html
18 years ago
Anyone know where to find a Jlex/Cup or ANTLR tutorial for dummies page? Maybe in my case the extreme dummy version? Thanks
I'm not very good with Java, (just a beginner). So, now you see why I asked you guys
18 years ago
Can anyone translate this "pascal like" pseudocode into Java source code?


[This message has been edited by Kevin Luludis (edited March 22, 2001).]
18 years ago
I had tried that, not giving me any real good results. Any suggestions for optimizing this?

So far all i got it to do was tell me whether the token was a word or a number, and then give me its corresponding value. It did ignore the whitespace which was good, but I would love to get the results that the StringTokenizer gave above.
18 years ago
This is exactly what I had in mind, but If i was to read in some data that accidentally was missing a space the Tokens would be then joined together. Not exactly what I wanted but supper close!! What would I have to change in order for it to not only handle tabs, new lines, and returns, but also spaces?
18 years ago
Thanks again. You have been a tremendous help. Does StringTokenizer automatically ignore whitespace? It recognized EOL fine. But trouble with the whitespace. Im just asking because I know there is StremTokenizer, but it looks like StringTokenizer handles this much better!
18 years ago
I agree with Rita. I don't know very much about java, its packages or programming in general. I am basically a newbie struggling to learn it all. I prefer the text environment of the IDE's because of the color schemes and matching of the brackets. It's those simple things that helps me out alot when trying to figure out what I am doing wrong.
18 years ago
I see how this is done by declaring what I want output as the String s. But how would I do this using File I/O?
18 years ago
WOW! Stephanie that was great! Thank you very much. I just wanted to tell you that before I went to lunch. I have some more questions maybe you could help me with on this matter. Thanks again!
18 years ago
What would be the best way to read in any text based file. And then be able to pass through the file as an array, and splitting up the text into tokens.

I want to be able to take whatever the 'Token' is and then check it to see exactly what the token is specifically. Is it an Id, expression, term, factor, etc.
Thanks a lot
18 years ago
I am working on a school project on building a simple compiler. I have the I/O pretty much worked out as to reading in the file and then printing it back out to the screen and another file etc. Okay, now where I am running into a bit of a problem is Taking these tokens that I am reading in and then checking them to see if they meet a certain criteria (according to the grammar provided by the professor). So far what I have done is this:

This compiles and also works. I was wondering if there was a better way to optimize how I can get the tokens out to check them against my grammar requirements. Plus, im not sure on how to handle tokenizing of the * + = / symbols which will be part of the expression grammar. I basically tested this with a file I called a.txt which was basically written like this:

I had to throw the ; in there to let it know to make a new line. Please let me know what you think, and any suggestions on how to improve such a thing. The rest of the work that I have done, including the grammar and the output assembly language about my project can be found at http://members.nbci.com/acidmaxx/Compiler/compiler_project.html
Thanks alot. Looking forward to hear your ideas
[This message has been edited by Kevin Luludis (edited March 01, 2001).]
18 years ago