Search in sources :

Example 16 with IToken

use of dyvilx.tools.parsing.token.IToken in project Dyvil by Dyvil.

the class ParserManager method split.

@Override
public IToken split(IToken token, int length) {
    final String stringValue = token.stringValue();
    if (length == stringValue.length()) {
        // the second part would be empty, so it stays a single token
        return token;
    }
    final int line = token.startLine();
    final int startIndex = token.startColumn();
    final IToken prev = token.prev();
    final IToken token1 = this.toToken(stringValue.substring(0, length), startIndex, line);
    final IToken token2 = this.toToken(stringValue.substring(length), startIndex + length, line);
    final IToken next = token.next();
    // Re-link the tokens
    prev.setNext(token1);
    token1.setPrev(prev);
    token1.setNext(token2);
    token2.setPrev(token1);
    token2.setNext(next);
    next.setPrev(token2);
    return token1;
}
Also used : IToken(dyvilx.tools.parsing.token.IToken)

Example 17 with IToken

use of dyvilx.tools.parsing.token.IToken in project Dyvil by Dyvil.

the class TokenIterator method remove.

@Override
public void remove() {
    IToken prev = this.lastReturned;
    if (prev == null) {
        throw new IllegalStateException();
    }
    IToken next = this.next.next();
    prev.setNext(next);
    next.setPrev(prev);
    this.lastReturned = null;
    this.next = next;
}
Also used : IToken(dyvilx.tools.parsing.token.IToken)

Example 18 with IToken

use of dyvilx.tools.parsing.token.IToken in project Dyvil by Dyvil.

the class TryParserManager method split.

@Override
public IToken split(IToken token, int length) {
    final IToken split = super.split(token, length);
    if (split == token) {
        return token;
    }
    if (this.splitTokens == null) {
        this.splitTokens = new ArrayList<>();
    }
    this.splitTokens.add(token);
    return split;
}
Also used : IToken(dyvilx.tools.parsing.token.IToken)

Aggregations

IToken (dyvilx.tools.parsing.token.IToken)18 AttributeList (dyvilx.tools.compiler.ast.attribute.AttributeList)3 Annotation (dyvilx.tools.compiler.ast.attribute.annotation.Annotation)3 CodeAnnotation (dyvilx.tools.compiler.ast.attribute.annotation.CodeAnnotation)3 AnnotationParser (dyvilx.tools.compiler.parser.annotation.AnnotationParser)3 Name (dyvil.lang.Name)2 LambdaExpr (dyvilx.tools.compiler.ast.expression.LambdaExpr)2 IParameter (dyvilx.tools.compiler.ast.parameter.IParameter)2 ExpressionParser (dyvilx.tools.compiler.parser.expression.ExpressionParser)2 ParameterListParser (dyvilx.tools.compiler.parser.method.ParameterListParser)2 TypeParser (dyvilx.tools.compiler.parser.type.TypeParser)2 MarkerList (dyvilx.tools.parsing.marker.MarkerList)2 Modifiers (dyvil.reflect.Modifiers)1 TextSource (dyvil.source.TextSource)1 Modifier (dyvilx.tools.compiler.ast.attribute.modifiers.Modifier)1 ITypeConsumer (dyvilx.tools.compiler.ast.consumer.ITypeConsumer)1 TupleLikeExpr (dyvilx.tools.compiler.ast.expression.TupleLikeExpr)1 InfixCallChain (dyvilx.tools.compiler.ast.expression.operator.InfixCallChain)1 PostfixCall (dyvilx.tools.compiler.ast.expression.operator.PostfixCall)1 PrefixCall (dyvilx.tools.compiler.ast.expression.operator.PrefixCall)1