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
-
Constructor Summary
Constructors Constructor Description Lexer(java.lang.String js)
Create a new JavaScript lexer with the given source code
-
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)
-
-
-
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
-
-