Class Lexer
- java.lang.Object
-
- org.schabi.newpipe.extractor.utils.jsextractor.Lexer
-
public class Lexer extends java.lang.Object
JavaScript lexer that is able to parse JavaScript code and return its tokens.The algorithm for distinguishing between division operators and regex literals was taken from the RESS lexer.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Lexer.ParsedToken
Parsed token, containing the token and its position in the input string
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Lexer.ParsedToken
getNextToken()
Continue parsing and return the next tokenboolean
isBalanced()
Check if the parser is balanced (equal amount of open and closed parentheses and braces)
-
-
-
Constructor Detail
-
Lexer
public Lexer(java.lang.String js, int languageVersion)
Create a new JavaScript lexer with the given source code- Parameters:
js
- JavaScript codelanguageVersion
- JavaScript version (from Rhino)
-
Lexer
public Lexer(java.lang.String js)
Create a new JavaScript lexer with the given source code- Parameters:
js
- JavaScript code
-
-
Method Detail
-
getNextToken
public Lexer.ParsedToken getNextToken() throws ParsingException
Continue parsing and return the next token- Returns:
- next token
- Throws:
ParsingException
-
isBalanced
public boolean isBalanced()
Check if the parser is balanced (equal amount of open and closed parentheses and braces)- Returns:
- true if balanced
-
-