Example #1
0
    ///

    private static NeuKeyword NextKeyword(
        this Tokenizer <NeuToken> tokenizer,
        String s,
        NeuKeywordType keywordType)
    {
        var start = tokenizer.Scanner.GetLocation();

        ///

        var next = tokenizer.Scanner.Next(s.Length);

        if (next != s)
        {
            throw new Exception();
        }

        ///

        tokenizer.Scanner.NextWhitespace();

        ///

        return(new NeuKeyword(
                   source: next,
                   start: start,
                   end: tokenizer.Scanner.GetLocation(),
                   keywordType: keywordType));
    }
    public static NeuVar?HoistVar(
        this Interpreter <NeuFrame, NeuOperation> interpreter,
        NeuKeywordType keywordType,
        String name,
        NeuOperation value)
    {
        var v = new NeuVar(name, value);

        ///

        interpreter.Hoist(keywordType, name, v);

        ///

        return(v);
    }
    public static NeuHoistedFrame Hoist(
        this Interpreter <NeuFrame, NeuOperation> interpreter,
        NeuKeywordType keywordType,
        String name,
        NeuOperation operation)
    {
        var hoist = new NeuHoist(keywordType, name);

        ///

        var hoistedFrame = new NeuHoistedFrame(hoist, operation);

        ///

        interpreter.Stack.Push(hoistedFrame);

        ///

        return(hoistedFrame);
    }