예제 #1
0
 public InvokeParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #2
0
 public RefParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #3
0
 public IfAsAndParser(ExpressionBuilder builder) : base(builder, ExpressionFlags.OmitSendMessageAssign)
 {
 }
예제 #4
0
 public KeywordValueParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #5
0
 public StringParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #6
0
 public DictionaryParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #7
0
 public PostfixOperatorsParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #8
0
 public ClassReferenceParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #9
0
 public ComparisandParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #10
0
 public BindingParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #11
0
 public RangeOperatorParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #12
0
 public TryBlockParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #13
0
 public SymbolObjectParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #14
0
        public override IMatched <Unit> Parse(ParseState state, Token[] tokens, ExpressionBuilder builder)
        {
            var functionName = tokens[2].Text;

            if (functionName == @"\/")
            {
                return(notMatched <Unit>());
            }
            else
            {
                state.Colorize(tokens, Color.Whitespace, Color.Invokable, Color.OpenParenthesis);

                if (getArgumentsPlusLambda(state, builder.Flags).ValueOrCast <Unit>(out var tuple, out var asUnit))
                {
                    var(arguments, possibleLambda) = tuple;

                    if (state.BlockFollows())
                    {
                        state.Scan("^ /':'", Color.Structure);
                        if (state.Advance().ValueOrOriginal(out _, out var unitMatched))
                        {
                            var tempObjectField   = newLabel("object");
                            var outerBuilder      = new ExpressionBuilder(ExpressionFlags.Standard);
                            var setPropertyParser = new SetPropertyParser(builder, tempObjectField, outerBuilder);
                            while (state.More)
                            {
                                if (setPropertyParser.Scan(state).If(out _, out var anyException))
                                {
                                }
                                else if (anyException.If(out var exception))
                                {
                                    return(failedMatch <Unit>(exception));
                                }
                                else
                                {
                                    break;
                                }
                            }

                            state.Regress();

                            if (outerBuilder.ToExpression().If(out var outerExpression, out var outerException))
                            {
                                builder.Add(new NewObjectSymbol(tempObjectField, functionName, outerExpression));
                            }
                            else
                            {
                                return(failedMatch <Unit>(outerException));
                            }
                        }
                        else
                        {
                            return(unitMatched);
                        }
                    }
                    else if (state.Macro(functionName).If(out var function))
                    {
                        builder.Add(new MacroInvokeSymbol(function, arguments));
                    }
                    else
                    {
                        builder.Add(new InvokeSymbol(functionName, arguments, possibleLambda, builder.Flags[ExpressionFlags.Comparisand]));
                    }

                    return(Unit.Matched());
                }
예제 #15
0
 public ThrowParser(ExpressionBuilder builder, ExpressionFlags flags = ExpressionFlags.Standard) : base(builder, flags)
 {
 }
예제 #16
0
 public WhateverParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #17
0
 public CharParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #18
0
 public ArrayParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #19
0
 public BooleanParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #20
0
 public WhereParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #21
0
 public LazyParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #22
0
 public FloatParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #23
0
 public ReductionParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #24
0
 public OctalParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #25
0
        public override IMatched <Unit> Parse(ParseState state, Token[] tokens, ExpressionBuilder builder)
        {
            var prefix  = tokens[2].Text;
            var mutable = prefix == "m";
            var binary  = prefix == "b";
            var symbol  = prefix == "`";

            state.Colorize(tokens, Color.Whitespace, Color.StringPart, Color.String);

            var text    = new StringBuilder();
            var escaped = false;
            var index   = state.Index;
            var length  = 0;
            var hex     = false;
            var hexText = new StringBuilder();

            while (state.More)
            {
                var ch = state.CurrentSource[0];
                switch (ch)
                {
                case '"':
                    if (escaped)
                    {
                        text.Append('"');
                        escaped = false;
                        break;
                    }

                    if (hex)
                    {
                        if (fromHex(hexText.ToString()).If(out var matchedChar, out var anyException))
                        {
                            text.Append(matchedChar);
                        }
                        else if (anyException.If(out var exception))
                        {
                            return(failedMatch <Unit>(exception));
                        }
                        else
                        {
                            return(failedMatch <Unit>(badHex(hexText.ToString())));
                        }
                    }

                    state.Move(1);
                    state.AddToken(index, length + 1, Color.String);
                    if (mutable)
                    {
                        builder.Add(new MutStringSymbol(text.ToString()));
                        return(Unit.Matched());
                    }
                    else if (binary)
                    {
                        builder.Add(new ByteArraySymbol(text.ToString()));
                        return(Unit.Matched());
                    }
                    else if (symbol)
                    {
                        builder.Add(new SymbolSymbol(text.ToString()));
                        return(Unit.Matched());
                    }
                    else
                    {
                        builder.Add(new StringSymbol(text.ToString()));
                        return(Unit.Matched());
                    }

                case '\\':
                    if (escaped)
                    {
                        text.Append('\\');
                        escaped = false;
                        break;
                    }

                    escaped = true;
                    break;

                case 'n':
                    if (escaped)
                    {
                        text.Append('\n');
                        escaped = false;
                        break;
                    }

                    text.Append('n');
                    break;

                case 'r':
                    if (escaped)
                    {
                        text.Append('\r');
                        escaped = false;
                        break;
                    }

                    text.Append('r');
                    break;

                case 't':
                    if (escaped)
                    {
                        text.Append('\t');
                        escaped = false;
                        break;
                    }

                    text.Append('t');
                    break;

                case 'u':
                    if (escaped)
                    {
                        hex = true;
                        hexText.Clear();
                        escaped = false;
                        break;
                    }

                    text.Append('u');
                    break;

                case '{':
                    if (escaped)
                    {
                        hex = true;
                        hexText.Clear();
                        escaped = false;
                        break;
                    }

                    text.Append('{');
                    break;

                default:
                    if (hex)
                    {
                        if (ch.Between('0').And('9') || ch.Between('a').And('f') && hexText.Length < 6)
                        {
                            hexText.Append(ch);
                        }
                        else
                        {
                            hex = false;
                            if (fromHex(hexText.ToString()).ValueOrCast <Unit>(out var matchedChar, out var asUnit))
                            {
                                text.Append(matchedChar);
                            }
                            else if (asUnit.IsFailedMatch)
                            {
                                return(asUnit);
                            }

                            if (ch == 96)
                            {
                                text.Append(ch);
                            }
                        }
                    }
                    else
                    {
                        text.Append(ch);
                    }

                    escaped = false;
                    break;
                }

                length++;
                state.Move(1);
            }

            return(failedMatch <Unit>(openString()));
        }
예제 #26
0
 public ByteParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #27
0
 public ConversionParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #28
0
 public ImplicitSymbolParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #29
0
 public OneParameterLambdaParser(ExpressionBuilder builder) : base(builder)
 {
 }
예제 #30
0
 public WhereItemParser(ExpressionBuilder builder) :
     base(builder, ExpressionFlags.OmitColon | ExpressionFlags.OmitComma | ExpressionFlags.Comparisand)
 {
 }