Package jpicedt.format.input.util
Class EnclosingExpression
- java.lang.Object
-
- jpicedt.format.input.util.AbstractRegularExpression
-
- jpicedt.format.input.util.EnclosingExpression
-
- All Implemented Interfaces:
ExpressionConstants
public class EnclosingExpression extends AbstractRegularExpression
An expression that can encompass a sub-expression it encloses with markers, e.g. "{" + sub-expression + "}"
The interpret() methods work as follows :
- look up an endMarker matching beginMarker in Context.getRemainingSubstring (that is, skip enclosed blocks with the same markers type)
- set this endMarker as the new Context's endMarker
- save enclosed expression as "value", and interpret it
- restore old Context's endMarker
- Since:
- jpicedt 1.3
- Version:
- $Id: EnclosingExpression.java,v 1.4.2.1 2007/09/02 11:56:13 reynal Exp $
- Author:
- Sylvain Reynal
-
-
Field Summary
-
Fields inherited from interface jpicedt.format.input.util.ExpressionConstants
ANY_CHAR, ANY_CHAR_EOL, ANY_SIGN, AT_LEAST, AT_MOST, DEBUG, DOUBLE, EOL, EXACTLY, INTEGER, NEGATIVE, NON_NULL, POSITIVE, STRICTLY_NEGATIVE, STRICTLY_POSITIVE, WHITE_SPACES, WHITE_SPACES_OR_EOL
-
-
Constructor Summary
Constructors Constructor Description EnclosingExpression(java.lang.String openingDelimiter, AbstractRegularExpression child, java.lang.String closingDelimiter)EnclosingExpression(java.lang.String openingDelimiter, AbstractRegularExpression child, java.lang.String closingDelimiter, boolean noLineFeed)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetEnclosedString()booleaninterpret(Context context)Call action() with value=enclosed stringvoidsetChild(AbstractRegularExpression child)Change the Expression that must be parsed inside the delimiters to the given expression (can be null)java.lang.StringtoString()-
Methods inherited from class jpicedt.format.input.util.AbstractRegularExpression
action
-
-
-
-
Constructor Detail
-
EnclosingExpression
public EnclosingExpression(java.lang.String openingDelimiter, AbstractRegularExpression child, java.lang.String closingDelimiter, boolean noLineFeed)- Parameters:
openingDelimiter- the opening delimiterchild- the Expression that must be parsed inside the delimiters (can be null)closingDelimiter- the closing delimiternoLineFeed- if true, closingDelimiter must be on the same line as openingDelimiter A typical use would be : EnclosingExpression("{", new WildChar(ANY_CHAR),"}",false)
-
EnclosingExpression
public EnclosingExpression(java.lang.String openingDelimiter, AbstractRegularExpression child, java.lang.String closingDelimiter)- Parameters:
openingDelimiter- the opening delimiterchild- the Expression that must be parse inside the delimiter (can be null)closingDelimiter- the closing delimiter Linefeeds are allowed.
-
-
Method Detail
-
setChild
public void setChild(AbstractRegularExpression child)
Change the Expression that must be parsed inside the delimiters to the given expression (can be null)
-
interpret
public boolean interpret(Context context) throws REParserException
Call action() with value=enclosed string- Specified by:
interpretin classAbstractRegularExpression- Returns:
- TRUE if delimiters as well as inward expr have been found,
- Throws:
REParserException- if an error occur during parsing
-
getEnclosedString
public java.lang.String getEnclosedString()
- Returns:
- the enclosed string (= block content as returned by Context)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-