#Help with Translating Pseudocode to Code

6 messages · Page 1 of 1 (latest)

frosty socket
#

I need help making this pseudocode into code but there seem to be some errors. Main thing is that some stuff is hard to match. Anyone willing to help?

import java.util.ArrayList;
import java.util.List;

public class Lexer {
    private TextManager text;

    String CurrentWord;

    public Lexer(String CurrentWord) {
        text = new TextManager(CurrentWord);
    }

    public isLetter() {

    }


    public lex() {
        List<Token> tokens = new ArrayList<Token>();
        CurrentWord = "";
        while (!text.isAtEnd()) {
            if (position == text.length()) {
                char C = getCharacter(CurrentWord);
                if (C.isLetter() == false) {
                    if (CurrentWord != "") {
                        Token token = new Token(CurrentWord);
                        tokens.add(token);
                    }
                    CurrentWord = "";
                }
            }
            else {
                return CurrentWord += C;
            }
        }
    }
}
public class TextManager {
    private String text;
    private int position;

    public TextManager(String word) {
        text = word;
        position = 0;
    }

    public char getCharacter() {
        char m = text.charAt(position++);
        return m;
    }

    public Boolean isAtEnd() {
        if (position >= text.length()) {
            return true;
        }
        else {
            return false;
        }
    }
}
public class Token {
    private String value;

    public Token (String result) {
        value = result;
    }

    public String getValue() {
        return value;
    }
}
vale pewterBOT
#

This post has been reserved for your question.

Hey @frosty socket! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

frosty socket
#

ok so

#

i realize that certain shit doesnt carry over to the other classes?

#

specifically in lexer.java