An update. Have taken a look at ANTLR, and how it does things. So I have decided that I will implement the tree with this class:
public class Node implements Iterable<Node> {
private Node...
Type: Posts; User: Kerr
An update. Have taken a look at ANTLR, and how it does things. So I have decided that I will implement the tree with this class:
public class Node implements Iterable<Node> {
private Node...
From what I have heard, usually when you want to return more then one variable it is a hint that you need to rethink how you are doing things. I dont know if that is true or not personally, since I...
Thanks. I want to write my own parser, but as you suggested I can take a look at how they did it. Quite frankly I think that is a great idea!
I guess I can just try and keep it simple. Make a base node and then have other nodes for more specific behaviour. Thing is, I want to avoid too many casts and all that when I use the tree later on....
I know how a tree structure works. It is the case of a abstract syntax tree I am unsure of. For example, if I want to implement a function that generates fibonacci numbers, I would maybe do something...
Hi all.
I am making a small scripting language for fun. Have managed to get the tokenizer working, but now I have another problem. Basically, I am dividing the source code into a series of tokens...
Ok, I have maybe finished the tokenizer class now. Dont think its perfect, far from it. So I thought I would post it here and if anyone has any input feel free to give it :). It is meant to be a part...
Since I would have to step through the characters anyway I just figured I might just as well use the read() method.
Think I missunderstood your post, lol. Thought you mean that I should read an entire line (the "readLine" method) and then go through it rather then just go through it (the "read" method):P.
May...
Dont think I have to read the file per-line tbh. BufferedReader has a rather large internal buffer (8192 characters) that it appear to fill, so that should be more then enough :).
I know, which is one of the reasons I hesitate to do that. Dont think it is too much of a problem, since this is not a serious thing, but I prefer to do it in a good way. Atm I am using a...
I am not sure, hence the question. Quite new to this, and my way of learning tend to be to jump into it head first and see what works and not. So you can say that this is just one giant training...
I suppose I could just read the entire file into a string and then move through it. Would it be better then using a BufferedReader (like I am now)?
The second one I guess. Let me take an example. If the first character the tokenizer finds is a letter it will create a string containing that letter and all letters that follows. When it encounters...
To clarify, though, I didnt mean that I am new to IO but to parsing text files. Really not sure how to do it (and I am of course talking about the IO part of parsing a text file). But looking at that...
Hi all.
I have been playing around with parsing text files. Basically what I want to do is to create a tokenizer (Lexical analysis - Wikipedia, the free encyclopedia), but I am unsure what the...
Ok :). I use methods, of course. Trying to use them whenever a peace of code is used in more then one place. It is just hard to figure out how to do it (organizing the code and all, like should this...
No, the program is just me fooling around building a very basic scripting language (quite useless, actually, since it can only do about 4 things, but its good training). Basically I am using an...
Are you talking about methods when you say functions? Sorry, sometimes I get stuck on words :P.
Yeah, its just that I have no experience with writing modular code.
I have to use an Iterator and the addAll method accepts a Collection.
C++ templates are far more flexible and can do things like what you want to do because it will generate specialized classes. Java, on the other hand, will not generate any specialized classes....
Hi all.
Had to refactor the program I am working on after deciding that a feature was missing. Anyway, I realized that a private method was useful elsewhere and moved it out. Then I refactored...
Not yet, but an advice. Place your code in between a [ highlight="java" ] tag and a [ /highlight ] tag. Minus the spaces, of course. Makes your code look much prettier and easier to read, like this:...
Anyone know? Will try and explain myself again, lol.
What I want, now that I think of it, is a algorithm that works this, but in an iterative manner (the one I have does it recursively).
First...