Search:

Type: Posts; User: Kerr

Page 1 of 4 1 2 3 4

Search: Search took 0.32 seconds.

  1. Replies
    7
    Views
    3,667

    Re: Best way to implement an abstract syntax tree?

    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...
  2. Re: Why I can't return two variables in one method?

    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...
  3. Replies
    7
    Views
    3,667

    Re: Best way to implement an abstract syntax tree?

    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!
  4. Replies
    7
    Views
    3,667

    Re: Best way to implement an abstract syntax tree?

    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....
  5. Replies
    7
    Views
    3,667

    Re: Best way to implement an abstract syntax tree?

    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...
  6. Replies
    7
    Views
    3,667

    Best way to implement an abstract syntax tree?

    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...
  7. Replies
    20
    Views
    2,762

    Re: What is the best way to read from a text file?

    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...
  8. Replies
    20
    Views
    2,762

    Re: What is the best way to read from a text file?

    Since I would have to step through the characters anyway I just figured I might just as well use the read() method.
  9. Replies
    20
    Views
    2,762

    Re: What is the best way to read from a text file?

    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...
  10. Replies
    20
    Views
    2,762

    Re: What is the best way to read from a text file?

    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 :).
  11. Replies
    20
    Views
    2,762

    Re: What is the best way to read from a text file?

    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...
  12. Replies
    20
    Views
    2,762

    Re: What is the best way to read from a text file?

    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...
  13. Replies
    20
    Views
    2,762

    Re: What is the best way to read from a text file?

    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)?
  14. Replies
    20
    Views
    2,762

    Re: What is the best way to read from a text file?

    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...
  15. Replies
    20
    Views
    2,762

    Re: What is the best way to read from a text file?

    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...
  16. Replies
    20
    Views
    2,762

    What is the best way to read from a text file?

    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...
  17. Re: What is the best way to avoid duplicating code?

    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...
  18. Replies
    4
    Views
    350

    Re: Is this a stupid idea?

    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...
  19. Re: What is the best way to avoid duplicating code?

    Are you talking about methods when you say functions? Sorry, sometimes I get stuck on words :P.
  20. Re: What is the best way to avoid duplicating code?

    Yeah, its just that I have no experience with writing modular code.
  21. Replies
    4
    Views
    350

    Re: Is this a stupid idea?

    I have to use an Iterator and the addAll method accepts a Collection.
  22. Replies
    8
    Views
    719

    Re: How Do I: Convert to Java

    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....
  23. Replies
    4
    Views
    350

    Is this a stupid idea?

    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...
  24. Re: recursion for identifying amount of zeroes in minesweeper demo

    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:...
  25. Replies
    1
    Views
    569

    Re: Need help with finding a differnt algorithm

    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...
Results 1 to 25 of 79
Page 1 of 4 1 2 3 4