public virtual void RegisterFunctionParserTokens() { // Base class registration RegisterBalancerTokens(); // These are the important tokens relating to function arguments SymToken bracketTokenOpening = new SymToken("(", SymToken.TClass.EClassSymbol, SymToken.TType.ETypeUnidentified); SymToken bracketTokenClosing = new SymToken(")", SymToken.TClass.EClassSymbol, SymToken.TType.ETypeUnidentified); SymToken squareBracketTokenOpening = new SymToken("[", SymToken.TClass.EClassSymbol, SymToken.TType.ETypeUnidentified); SymToken squareBracketTokenClosing = new SymToken("]", SymToken.TClass.EClassSymbol, SymToken.TType.ETypeUnidentified); SymToken templateBracketTokenOpening = new SymToken("<", SymToken.TClass.EClassSymbol, SymToken.TType.ETypeUnidentified); SymToken templateBracketTokenClosing = new SymToken(">", SymToken.TClass.EClassSymbol, SymToken.TType.ETypeUnidentified); // We want to track levels for square brackets and template arguments in order to ensure we balance correctly. // We don't want to remove any redundancy here as these may have special meaning. RegisterOpeningToken(squareBracketTokenOpening, squareBracketTokenClosing, true, true, TLevelExpectations.ELevelExpectationsAboveLevelNumber, 0, TAssociatedBehaviour.EBehaviourNone); RegisterClosingToken(squareBracketTokenClosing, squareBracketTokenOpening, true, true, TLevelExpectations.ELevelExpectationsAboveLevelNumber, 0, TAssociatedBehaviour.EBehaviourNone); RegisterOpeningToken(templateBracketTokenOpening, templateBracketTokenClosing, true, true, TLevelExpectations.ELevelExpectationsAboveLevelNumber, 0, TAssociatedBehaviour.EBehaviourNone); RegisterClosingToken(templateBracketTokenClosing, templateBracketTokenOpening, true, true, TLevelExpectations.ELevelExpectationsAboveLevelNumber, 0, TAssociatedBehaviour.EBehaviourNone); // Define our argument separation token(s). TAssociatedBehaviour flags = TAssociatedBehaviour.EBehaviourNone; flags |= TAssociatedBehaviour.EBehaviourCreateSubTree; flags |= TAssociatedBehaviour.EBehaviourRemoveReduntantBracketing; // SymToken commaDelimiterToken = new SymToken(",", SymToken.TClass.EClassSymbol, SymToken.TType.ETypeUnidentified); RegisterArgumentSeparatorToken(commaDelimiterToken, new SymTokenBalancerMatchCriteria(SymToken.NullToken(), false, true, TLevelExpectations.ELevelExpectationsAtLevel, 1, flags)); RegisterArgumentSeparatorToken(commaDelimiterToken, new SymTokenBalancerMatchCriteria(SymToken.NullToken(), true, true, TLevelExpectations.ELevelExpectationsAboveLevelNumber, 1, TAssociatedBehaviour.EBehaviourNone)); }
public SymTokenBalancerMatchCriteria(SymToken aDiametricToken, bool aEmit, bool aChangesLevel, TLevelExpectations aLevelExpectations, int aAssociatedLevel, TAssociatedBehaviour aAssociatedBehaviour) { iDiametricToken = aDiametricToken; iEmit = aEmit; iChangesLevel = aChangesLevel; iLevelExpectations = aLevelExpectations; iAssociatedLevel = aAssociatedLevel; iAssociatedBehaviour = aAssociatedBehaviour; }
public void RegisterClosingToken(SymToken aToken, SymToken aDiametricToken, bool aEmit, bool aStartsNewLevel, TLevelExpectations aLevelExpectations, int aAssociatedLevel, TAssociatedBehaviour aBehaviour) { SymTokenBalancerMatchCriteria criteria = new SymTokenBalancerMatchCriteria(aDiametricToken, aEmit, aStartsNewLevel, aLevelExpectations, aAssociatedLevel, aBehaviour); RegisterClosingToken(aToken, criteria); }