Example #1
0
        public string TranslateArray(TreeWalker walker, ArrayReferenceNode arrayReference)
        {
            StringBuilder tempBuilder = new StringBuilder();

            tempBuilder.Append($"{MangleArrayName(arrayReference.arrayName)}");
            foreach (Node bracketedExpression in arrayReference.nodes)
            {
                tempBuilder.Append($"[{walker.TranslateExpression(bracketedExpression)}]");
            }

            return tempBuilder.ToString();
        }
Example #2
0
        public override void HandleFunctionNode(TreeWalker walker, FunctionNode function)
        {
            List<Node> arguments = function.GetArguments(1);
            ArrayReferenceNode arrayReference = VerifyType<ArrayReferenceNode>(arguments[0]);
            //walker.scriptBuilder.EmitPython($"{walker.TranslateArray(arrayReference) }");

            StringBuilder tempBuilder = new StringBuilder();

            tempBuilder.Append($"{TreeWalker.MangleArrayName(arrayReference.arrayName)} = Dim(");

            tempBuilder.Append($"{walker.TranslateExpression(arrayReference.nodes[0])}");
            
            for(int i = 1; i < arrayReference.nodes.Count; i++)
            {
                tempBuilder.Append($", {walker.TranslateExpression(arrayReference.nodes[i])}");
            }

            tempBuilder.Append(")");

            walker.scriptBuilder.EmitPython(tempBuilder.ToString());
        }
Example #3
0
        public Node HandleArray()
        {
            //First two lexemes must be question mark, then array name
            ArrayReferenceNode array = new ArrayReferenceNode(
                PopMessage(LexemeType.ARRAY_REFERENCE, "Missing Array ?"),
                PopMessage(LexemeType.WORD, "Missing Array Name")
                );

            //Arrays must have at least 1 left bracket
            if (Peek().type != LexemeType.L_SQUARE_BRACKET)
            {
                throw GetParsingException("Got Array reference without array brackets");
            }

            while (HasCurrent() && Peek().type == LexemeType.L_SQUARE_BRACKET)
            {
                //Handle a  '[' EXPRESSION ']'
                Pop(LexemeType.L_SQUARE_BRACKET);
                array.AddBracketedExpression(HandleExpression());
                Pop(LexemeType.R_SQUARE_BRACKET);
            }

            return(array);
        }
Example #4
0
        public void DefineArray(ArrayReferenceNode node)
        {

        }