Package org.jparsec
Class Indentation
- java.lang.Object
-
- org.jparsec.Indentation
-
public final class Indentation extends java.lang.Object
Processes indentation based lexical structure according to the Off-side rule.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
Indentation.Punctuation
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Object
indent
(package private) static CharPredicate
INLINE_WHITESPACE
ACharPredicate
that returns true only if the character isn't line feed andCharacter.isWhitespace(char)
returns true.(package private) static Pattern
INLINE_WHITESPACES
APattern
object that matches one or more whitespace characters or line continuations, where the line feed character ('\n'
) is escaped by the backslash character ('\'
).(package private) static Pattern
LINE_CONTINUATION
APattern
object that matches a line continuation.private java.lang.Object
outdent
static Parser<java.lang.Void>
WHITESPACES
AParser
that recognizes 1 or more whitespace characters on the same line.
-
Constructor Summary
Constructors Constructor Description Indentation()
Creates aIndentation
object that generates default indent and outdent tokens.Indentation(java.lang.Object indent, java.lang.Object outdent)
Creates anIndentation
object that usesindent
andoutdent
as the token values for indentation and outdentation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) java.util.List<Token>
analyzeIndentations(java.util.List<Token> tokens, java.lang.Object lf)
Analyzes indentation by looking at the first token after eachlf
and insertingindent
andoutdent
tokens properly.Parser<Token>
indent()
AParser
that recognizes the generatedindent
token.Parser<java.util.List<Token>>
lexer(Parser<?> tokenizer, Parser<?> delim)
AParser
that greedily runstokenizer
, and translates line feed characters ('\n'
) toindent
andoutdent
tokens.private void
newLine(Token token, java.util.Stack<java.lang.Integer> indentations, int indentation, java.util.List<Token> result)
Parser<Token>
outdent()
AParser
that recognizes the generatedoutdent
token.private static Token
pseudoToken(int index, java.lang.Object value)
private static Parser<Token>
token(java.lang.Object value)
-
-
-
Field Detail
-
INLINE_WHITESPACE
static final CharPredicate INLINE_WHITESPACE
ACharPredicate
that returns true only if the character isn't line feed andCharacter.isWhitespace(char)
returns true.
-
LINE_CONTINUATION
static final Pattern LINE_CONTINUATION
APattern
object that matches a line continuation. i.e. a backslash character ('\'
) followed by some whitespaces and ended by a line feed character ('\n'
). Is useful if the line feed character plays a role in the syntax (as in indentation-sensitive languages) and line continuation is supported.
-
INLINE_WHITESPACES
static final Pattern INLINE_WHITESPACES
APattern
object that matches one or more whitespace characters or line continuations, where the line feed character ('\n'
) is escaped by the backslash character ('\'
).
-
WHITESPACES
public static final Parser<java.lang.Void> WHITESPACES
AParser
that recognizes 1 or more whitespace characters on the same line. Line continutation (escaped by a backslash character'\'
) is considered the same line.
-
indent
private final java.lang.Object indent
-
outdent
private final java.lang.Object outdent
-
-
Constructor Detail
-
Indentation
public Indentation(java.lang.Object indent, java.lang.Object outdent)
Creates anIndentation
object that usesindent
andoutdent
as the token values for indentation and outdentation.
-
Indentation
public Indentation()
Creates aIndentation
object that generates default indent and outdent tokens.
-
-
Method Detail
-
analyzeIndentations
java.util.List<Token> analyzeIndentations(java.util.List<Token> tokens, java.lang.Object lf)
Analyzes indentation by looking at the first token after eachlf
and insertingindent
andoutdent
tokens properly.
-
newLine
private void newLine(Token token, java.util.Stack<java.lang.Integer> indentations, int indentation, java.util.List<Token> result)
-
pseudoToken
private static Token pseudoToken(int index, java.lang.Object value)
-
-