Package com.igormaznitsa.prologparser
Class DefaultParserContext
- java.lang.Object
-
- com.igormaznitsa.prologparser.DefaultParserContext
-
- All Implemented Interfaces:
ParserContext
public class DefaultParserContext extends java.lang.Object implements ParserContext
Default implementation of parser context. It is not thread safe one!
-
-
Field Summary
Fields Modifier and Type Field Description protected static Op[]EMPTYprotected java.util.Map<java.lang.String,OpContainer>opContainersprotected java.util.Set<java.lang.String>opPrefixesprotected intparserContextFlags-
Fields inherited from interface com.igormaznitsa.prologparser.ParserContext
FLAG_BLOCK_COMMENTS, FLAG_CURLY_BRACKETS, FLAG_DOT2_AS_LIST, FLAG_NONE, FLAG_VAR_AS_FUNCTOR, FLAG_ZERO_QUOTATION_ALLOWS_WHITESPACE_CHAR, FLAG_ZERO_QUOTATION_CHARCODE, FLAG_ZERO_STRUCT
-
-
Constructor Summary
Constructors Constructor Description DefaultParserContext(int parserContextFlags)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DefaultParserContextaddOps(Op... operators)DefaultParserContextaddOps(java.util.List<Op>... operators)protected voidfillPrefixes(java.lang.String name)java.util.Map<java.lang.String,OpContainer>findAllOperators()OpContainerfindOpForName(PrologParser source, java.lang.String operatorName)Find operators for their name.intgetFlags()get parser flags for the parser context.booleanhasOpStartsWith(PrologParser source, java.lang.String operatorNameStartSubstring)Check that the context contains an operator starts with some stringstatic ParserContextof(int parserContextFlags)static ParserContextof(int parserContextFlags, Op... operators)static ParserContextof(int parserContextFlags, java.util.List<Op>... operators)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.igormaznitsa.prologparser.ParserContext
getMaxTokenizerBufferLength
-
-
-
-
Field Detail
-
EMPTY
protected static final Op[] EMPTY
-
opPrefixes
protected final java.util.Set<java.lang.String> opPrefixes
-
opContainers
protected final java.util.Map<java.lang.String,OpContainer> opContainers
-
parserContextFlags
protected final int parserContextFlags
-
-
Method Detail
-
of
public static ParserContext of(int parserContextFlags)
-
of
public static ParserContext of(int parserContextFlags, Op... operators)
-
of
@SafeVarargs public static ParserContext of(int parserContextFlags, java.util.List<Op>... operators)
-
findAllOperators
public java.util.Map<java.lang.String,OpContainer> findAllOperators()
-
getFlags
public int getFlags()
Description copied from interface:ParserContextget parser flags for the parser context.- Specified by:
getFlagsin interfaceParserContext- Returns:
- flags as bit field
- See Also:
ParserContext.FLAG_NONE,ParserContext.FLAG_VAR_AS_FUNCTOR,ParserContext.FLAG_BLOCK_COMMENTS,ParserContext.FLAG_CURLY_BRACKETS,ParserContext.FLAG_ZERO_QUOTATION_CHARCODE,ParserContext.FLAG_ZERO_STRUCT
-
fillPrefixes
protected void fillPrefixes(java.lang.String name)
-
addOps
@SafeVarargs public final DefaultParserContext addOps(java.util.List<Op>... operators)
-
addOps
public DefaultParserContext addOps(Op... operators)
-
hasOpStartsWith
public boolean hasOpStartsWith(PrologParser source, java.lang.String operatorNameStartSubstring)
Description copied from interface:ParserContextCheck that the context contains an operator starts with some string- Specified by:
hasOpStartsWithin interfaceParserContext- Parameters:
source- source prolog parser making request, must not be nulloperatorNameStartSubstring- string to be used to look for operator starts with it, must not be null- Returns:
- true if there is such operator, false otherwise
-
findOpForName
public OpContainer findOpForName(PrologParser source, java.lang.String operatorName)
Description copied from interface:ParserContextFind operators for their name.- Specified by:
findOpForNamein interfaceParserContext- Parameters:
source- source prolog parser making request, must not be nulloperatorName- name of operators, must not be null- Returns:
- operator container if such one is found, null otherwise
-
-