Search in sources :

Example 1 with Position

use of priv.bajdcc.util.Position in project jMiniLang by bajdcc.

the class ManageScopeSymbol method getEntryToken.

@Override
public Token getEntryToken() {
    Token token = new Token();
    token.kToken = TokenType.ID;
    token.object = getEntryName();
    token.position = new Position();
    return token;
}
Also used : Position(priv.bajdcc.util.Position) Token(priv.bajdcc.util.lexer.token.Token)

Example 2 with Position

use of priv.bajdcc.util.Position in project jMiniLang by bajdcc.

the class RegexStringIterator method snapshot.

@Override
public void snapshot() {
    stkIndex.push(data.iIndex);
    stkPosition.push(new Position(position.iColumn, position.iLine));
}
Also used : Position(priv.bajdcc.util.Position)

Example 3 with Position

use of priv.bajdcc.util.Position in project jMiniLang by bajdcc.

the class RegexStringIterator method cover.

@Override
public void cover() {
    stkIndex.set(stkIndex.size() - 1, data.iIndex);
    stkPosition.set(stkPosition.size() - 1, new Position(position));
}
Also used : Position(priv.bajdcc.util.Position)

Example 4 with Position

use of priv.bajdcc.util.Position in project jMiniLang by bajdcc.

the class RegexStringIterator method restore.

@Override
public void restore() {
    data.iIndex = stkIndex.pop();
    position = new Position(stkPosition.pop());
}
Also used : Position(priv.bajdcc.util.Position)

Example 5 with Position

use of priv.bajdcc.util.Position in project jMiniLang by bajdcc.

the class TokenAlgorithm method accept.

@Override
public boolean accept(IRegexStringIterator iterator, Token token) {
    if (!iterator.available()) {
        token.kToken = TokenType.EOF;
        return true;
    }
    token.position = new Position(iterator.position());
    iterator.snapshot();
    if (regex.match(iterator, this)) {
        // 匹配成功
        if (getToken(strMatch, token, iterator) != null) {
            // 自动转换单词
            iterator.discard();
            return true;
        }
    }
    iterator.restore();
    return false;
}
Also used : Position(priv.bajdcc.util.Position)

Aggregations

Position (priv.bajdcc.util.Position)6 Token (priv.bajdcc.util.lexer.token.Token)1