Package cruise.umple.parser.rules
Class ParsingCouple
java.lang.Object
cruise.umple.parser.rules.ParsingCouple
public class ParsingCouple
extends java.lang.Object
ParsingCouples are used by balanced rules to quickly find the corresponding brace. They are initialized at the begining of each file parsed
and are stored in the ParserDataPackage. They contain the character positions of each open brace and each close brace(when braces are the key)
so {{}} would have positionFrom = {1,2} and positionTo = {4,3}
-
Field Summary
Fields Modifier and Type Field Description static int
ignoreLevel
-
Constructor Summary
Constructors Constructor Description ParsingCouple(java.lang.String aOpen, java.lang.String aClose)
-
Method Summary
Modifier and Type Method Description boolean
addPositionFrom(java.lang.Integer aPositionFrom)
boolean
addPositionTo(java.lang.Integer aPositionTo)
void
delete()
java.lang.String
getClose()
The close key, a close brace or quote for examplejava.lang.String
getOpen()
The open key, a close brace or quote for examplejava.lang.Integer[]
getPositionFrom()
java.lang.Integer
getPositionFrom(int index)
java.lang.Integer[]
getPositionTo()
java.lang.Integer
getPositionTo(int index)
int
hashCode()
boolean
hasPositionFrom()
boolean
hasPositionTo()
int
indexOfPositionFrom(java.lang.Integer aPositionFrom)
int
indexOfPositionTo(java.lang.Integer aPositionTo)
ParsingCouple
init(java.lang.String input)
Searches the input string for the key this couple protects.int
numberOfPositionFrom()
int
numberOfPositionTo()
boolean
removePositionFrom(java.lang.Integer aPositionFrom)
boolean
removePositionTo(java.lang.Integer aPositionTo)
boolean
setClose(java.lang.String aClose)
boolean
setOpen(java.lang.String aOpen)
java.lang.String
toString()
-
Field Details
-
ignoreLevel
public static int ignoreLevel
-
-
Constructor Details
-
ParsingCouple
public ParsingCouple(java.lang.String aOpen, java.lang.String aClose)
-
-
Method Details
-
setOpen
public boolean setOpen(java.lang.String aOpen) -
setClose
public boolean setClose(java.lang.String aClose) -
addPositionFrom
public boolean addPositionFrom(java.lang.Integer aPositionFrom) -
removePositionFrom
public boolean removePositionFrom(java.lang.Integer aPositionFrom) -
addPositionTo
public boolean addPositionTo(java.lang.Integer aPositionTo) -
removePositionTo
public boolean removePositionTo(java.lang.Integer aPositionTo) -
getOpen
public java.lang.String getOpen()The open key, a close brace or quote for example -
getClose
public java.lang.String getClose()The close key, a close brace or quote for example -
getPositionFrom
public java.lang.Integer getPositionFrom(int index) -
getPositionFrom
public java.lang.Integer[] getPositionFrom() -
numberOfPositionFrom
public int numberOfPositionFrom() -
hasPositionFrom
public boolean hasPositionFrom() -
indexOfPositionFrom
public int indexOfPositionFrom(java.lang.Integer aPositionFrom) -
getPositionTo
public java.lang.Integer getPositionTo(int index) -
getPositionTo
public java.lang.Integer[] getPositionTo() -
numberOfPositionTo
public int numberOfPositionTo() -
hasPositionTo
public boolean hasPositionTo() -
indexOfPositionTo
public int indexOfPositionTo(java.lang.Integer aPositionTo) -
delete
public void delete() -
init
Searches the input string for the key this couple protects. If a key is found with a \ before it, it is not considered if a key is found between // and \n it is not considered if a key is found within " and " it is not considered if a key is found between ' and ' it is not considered if ever there is a need for say "\{" to happen, i.e. that \ is terminal followed by { code } or something like that then this function will need to be revised so that there can be conditional escaping(it would probably just be an attribute of the couple) future plans also include refactoring this function so that all the couples are found on one pass through the input instead of having to re-initialize on every new input The ignore level comes into play for instance if you have /*lvl0 /*lvl1 and you only want to hide lvl1 you would put the ignore level as 1 -
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-