![JAR search and dependency download from the Maven repository](/logo.png)
cz.vutbr.web.csskit.antlr4.CSSTokenFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jstyleparser Show documentation
Show all versions of jstyleparser Show documentation
jStyleParser is a CSS parser written in Java. It has its own application interface that is designed to allow an efficient CSS processing in Java and mapping the values to the Java data types. It parses CSS 2.1 style sheets into structures that can be efficiently assigned to DOM elements. It is intended be the primary CSS parser for the CSSBox library. While handling errors, it is user agent conforming according to the CSS specification.
The newest version!
package cz.vutbr.web.csskit.antlr4;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.TokenSource;
import org.antlr.v4.runtime.misc.Pair;
import cz.vutbr.web.csskit.antlr4.CSSToken.TypeMapper;
public class CSSTokenFactory {
private final Pair input;
private final Lexer lexer;
private final CSSLexerState ls;
private final TypeMapper typeMapper;
public CSSTokenFactory(Pair input, Lexer lexer, CSSLexerState ls, Class extends Lexer> lexerClass) {
this.input = input;
this.lexer = lexer;
this.ls = ls;
this.typeMapper = CSSToken.createDefaultTypeMapper(lexerClass);
}
public CSSToken make() {
CSSToken t = new CSSToken(input, lexer._type, lexer._channel, lexer._tokenStartCharIndex, input.b.index() - 1, typeMapper);
t.setLine(lexer._tokenStartLine);
t.setText(lexer._text);
t.setCharPositionInLine(lexer._tokenStartCharPositionInLine);
t.setBase(((CSSInputStream) input.b).getBase());
// clone lexer state
t.setLexerState(new CSSLexerState(ls));
return t;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy