Top Description Inners Fields Constructors Methods
org.jparsec

public final Class Indentation

extends Object
Class Inheritance
Imports
java.util.List, .Stack, org.jparsec.internal.annotations.Private, org.jparsec.internal.util.Lists, .Objects, org.jparsec.pattern.CharPredicate, .Pattern, .Patterns

Processes indentation based lexical structure according to the Off-side rule.
Author
Ben Yu

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static enum

Field Summary

Modifier and TypeField and Description
private final Object
pack-priv static final CharPredicate
INLINE_WHITESPACE

A CharPredicate that returns true only if the character isn't line feed and Character#isWhitespace(char) returns true.

pack-priv static final Pattern
INLINE_WHITESPACES

A Pattern object that matches one or more whitespace characters or line continuations, where the line feed character ('\n') is escaped by the backslash character ('\').

pack-priv static final Pattern
LINE_CONTINUATION

A Pattern object that matches a line continuation.

private final Object
public static final Parser<Void>
WHITESPACES

A Parser that recognizes 1 or more whitespace characters on the same line.

Constructor Summary

AccessConstructor and Description
public
Indentation(Object indent, Object outdent)

Creates an Indentation object that uses indent and outdent as the token values for indentation and outdentation.

public
Indentation()

Creates a Indentation object that generates default indent and outdent tokens.

Method Summary

Modifier and TypeMethod and Description
pack-priv List<Token>
analyzeIndentations(List<Token> tokens, Object lf)

Analyzes indentation by looking at the first token after each lf and inserting indent and outdent tokens properly.

public Parser<Token>
indent()

A Parser that recognizes the generated indent token.

public Parser<List<Token>>
lexer(Parser<?> tokenizer, Parser<?> delim)

A Parser that greedily runs tokenizer, and translates line feed characters ('\n') to indent and outdent tokens.

private void
newLine(Token token, Stack<Integer> indentations, int indentation, List<Token> result)

public Parser<Token>
outdent()

A Parser that recognizes the generated outdent token.

private static Token
pseudoToken(int index, Object value)

private static Parser<Token>
token(Object value)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

indentback to summary
private final Object indent
INLINE_WHITESPACEback to summary
pack-priv static final CharPredicate INLINE_WHITESPACE

A CharPredicate that returns true only if the character isn't line feed and Character#isWhitespace(char) returns true.

INLINE_WHITESPACESback to summary
pack-priv static final Pattern INLINE_WHITESPACES

A Pattern object that matches one or more whitespace characters or line continuations, where the line feed character ('\n') is escaped by the backslash character ('\').

LINE_CONTINUATIONback to summary
pack-priv static final Pattern LINE_CONTINUATION

A Pattern 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.

outdentback to summary
private final Object outdent
WHITESPACESback to summary
public static final Parser<Void> WHITESPACES

A Parser that recognizes 1 or more whitespace characters on the same line. Line continutation (escaped by a backslash character '\') is considered the same line.

Constructor Detail

Indentationback to summary
public Indentation(Object indent, Object outdent)

Creates an Indentation object that uses indent and outdent as the token values for indentation and outdentation.

Indentationback to summary
public Indentation()

Creates a Indentation object that generates default indent and outdent tokens.

Method Detail

analyzeIndentationsback to summary
pack-priv List<Token> analyzeIndentations(List<Token> tokens, Object lf)

Analyzes indentation by looking at the first token after each lf and inserting indent and outdent tokens properly.

indentback to summary
public Parser<Token> indent()

A Parser that recognizes the generated indent token.

lexerback to summary
public Parser<List<Token>> lexer(Parser<?> tokenizer, Parser<?> delim)

A Parser that greedily runs tokenizer, and translates line feed characters ('\n') to indent and outdent tokens. Return values are wrapped in Token objects and collected in a List. Patterns recognized by delim are ignored.

newLineback to summary
private void newLine(Token token, Stack<Integer> indentations, int indentation, List<Token> result)
outdentback to summary
public Parser<Token> outdent()

A Parser that recognizes the generated outdent token.

pseudoTokenback to summary
private static Token pseudoToken(int index, Object value)
tokenback to summary
private static Parser<Token> token(Object value)
org.jparsec back to summary

pack-priv final Enum Indentation.Punctuation

extends Enum<Indentation.Punctuation>
Class Inheritance
Annotations
@Private

Field Summary

Modifier and TypeField and Description
public static final Indentation.Punctuation
public static final Indentation.Punctuation
public static final Indentation.Punctuation

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Indentation.Punctuation
public static Indentation.Punctuation[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

INDENTback to summary
public static final Indentation.Punctuation INDENT
LFback to summary
public static final Indentation.Punctuation LF
OUTDENTback to summary
public static final Indentation.Punctuation OUTDENT

Constructor Detail

Punctuationback to summary
private Punctuation()

Method Detail

valueOfback to summary
public static Indentation.Punctuation valueOf(String name)
valuesback to summary
public static Indentation.Punctuation[] values()