示例#1
0
 public TokenValidateEventArgs(AleToken token, List<AleToken> tokens, int pos)
 {
     _Token = token;
     _Position = pos;
     _TokensList = tokens;
 }
示例#2
0
        protected virtual AleToken CreateToken(AleTokenType tokenType, int start, int length, string value = "", List<AleToken> container = null)
        {
            AleToken Token = new AleToken(tokenType, start, length, this);
            Token.Container = container;

            switch (tokenType)
            {
                case AleTokenType.UnknownText:
                case AleTokenType.DecimalNumber:
                case AleTokenType.FloatNumber:
                case AleTokenType.HexNumber:
                case AleTokenType.TextAtom:
                case AleTokenType.DateToken:
                case AleTokenType.Operation:
                case AleTokenType.Operator:
                case AleTokenType.Variable:
                    Token.Value = _Text.Substring(start, length);
                    break;
                case AleTokenType.TextConstant:
                    Token.Value = value;
                    break;
                case AleTokenType.Parentheses:
                case AleTokenType.Brackets:
                    Token.Value = _Text.Substring(start, 1);
                    break;
                case AleTokenType.ListToken:
                case AleTokenType.ListElement:
                    Token.Value = _ListSep;
                    break;
                case AleTokenType.KeyValue:
                    Token.Value = _KeyValueSep;
                    break;
                case AleTokenType.Pair:
                    Token.Value = _PairSep;
                    break;
                default:
                    Token.Value = value;
                    break;
            }

            return Token;
        }
示例#3
0
        protected virtual bool UserValidate(AleToken t, List<AleToken> tokens, int pos = -1)
        {
            if (pos < 0) pos = tokens.Count - 1;
            TokenValidateEventArgs e = new TokenValidateEventArgs(t, tokens, pos);
            EventHandler<TokenValidateEventArgs> handler = TokenValidate;
            if (handler != null)
            {
                handler(this, e);
                if (_Error != ERROR_OK) return false;
            }

            return true;
        }