Ejemplo n.º 1
0
        public override string CallBase()
        {
            string input = Main.IO.Read();

            ReturnBubble = new Tokens.Token("readline", input, "");
            return("");
        }
Ejemplo n.º 2
0
 private static void SkipToToken(Tokens.Token token)
 {
     while (curTok.token != token)
     {
         GetNextTokenError();
     }
 }
Ejemplo n.º 3
0
 public TokenNode(Tokens.Token token, string subString, int y, int x)
 {
     this.token     = token;
     this.subString = subString;
     this.y         = y + 1;
     this.x         = x + 1;
 }
Ejemplo n.º 4
0
 private static void CheckupClosedToken(Tokens.Token closedToken)
 {
     if (curTok.token != closedToken)
     {
         ConsoleHelper.WriteErrorAST("Expected '" + closedToken.ToString() + "'", curTok.y, curTok.x);
         SkipToToken(Tokens.Token.SEMILICON);
     }
 }
Ejemplo n.º 5
0
        private static TokenNode CreateNodeToken(Tokens.Token token, string subStr)
        {
            TokenNode tokenNode = new TokenNode(token, subStr, lineMemmory, startTokenIndex);

            listTokens.Add(tokenNode);
            tokenTypeMemory    = Tokens.Token.EMPTY;
            tokenBuilderMemory = null;
            return(tokenNode);
        }
Ejemplo n.º 6
0
 public CodePoint(string aFullText, int aTextStart, int aTextEnd, Tokens.Token aToken, object aValue)
 {
     FullText = aFullText;
     //
     TextStart = aTextStart;
     TextEnd   = aTextEnd;
     //
     Token = aToken;
     Value = aValue;
 }
Ejemplo n.º 7
0
        public override string CallBase()
        {
            //find extensions
            var tryStart = Extensions.FirstOrDefault(f => f.Name == "Start") as ExtensionStart;
            var tryPrint = Extensions.FirstOrDefault(f => f.Name == "Print") as ExtensionPrint;
            var tryColor = Extensions.FirstOrDefault(f => f.Name == "Color") as ExtensionColor;
            var tryStop  = Extensions.FirstOrDefault(f => f.Name == "Stop") as ExtensionStop;

            if (tryStart != null)
            {
                _watch = Stopwatch.StartNew();
            }
            if (tryPrint != null)
            {
                if (_watch != null)
                {
                    var elapsedMs = _watch.ElapsedMilliseconds;
                    var color     = ConsoleColor.Gray;
                    if (tryColor != null)
                    {
                        var          colorParam = tryColor.Extend();
                        ConsoleColor newcol     = ConsoleColor.Gray;
                        var          nofail     = Enum.TryParse <ConsoleColor>(colorParam[0].ToString(), out newcol);
                        if (nofail)
                        {
                            color = newcol;
                        }
                    }
                    Main.IO.Print(elapsedMs, color, false);
                }
            }
            if (tryStop != null)
            {
                if (_watch != null)
                {
                    _watch.Stop();
                }
            }
            if (_watch != null)
            {
                long output  = _watch.ElapsedMilliseconds;
                var  trytype = ProvidedArgs.First("type");
                if (trytype != null)
                {
                    if (trytype.ToString() == "ticks")
                    {
                        output = _watch.ElapsedTicks;
                    }
                }

                ReturnBubble = new Tokens.Token("timems", output.ToString(), Caller.Line);
            }
            return("");
        }
Ejemplo n.º 8
0
 private static ASTNode ParseWriteConsoleCommand()
 {
     Tokens.Token tokenCommand = curTok.token;
     GetNextToken();
     if (curTok.token == Tokens.Token.PARENTHESIS_L)
     {
         return(new ConsoleCommandAST(tokenCommand, MemberWriteConsole()));
     }
     else
     {
         ConsoleHelper.WriteErrorAST("Impossible token this area", curTok.y, curTok.x);
         return(null);
     }
 }
Ejemplo n.º 9
0
        public override string CallBase()
        {
            if (Main.AndroidDriver == null)
            {
                Compiler.ExceptionListener.Throw("Cannot check screen without a connected device");
                return(null);
            }
            var path = ProvidedArgs.First("path");

            if (path == null)
            {
                Compiler.ExceptionListener.Throw(new ExceptionHandler(ExceptionType.NullReferenceException, $"Invoke function cannot be null.", LineValue));
                return(null);
            }
            var prop = CheckProperty();

            try
            {
                var ret = Commands.GetImageCoordinates(path.ToString(), prop);
                if (ret == null)
                {
                    ReturnBubble = new Tokens.Token("null", "null", "");
                    return("");
                }
                string[] ouput = new string[] { ret[0].ToString(), ret[1].ToString() };

                ReturnBubble = new TArray("arr", ouput, "");
            }
            catch (Exception e)
            {
                if (e is System.IO.FileNotFoundException)
                {
                    Compiler.ExceptionListener.Throw(new ExceptionHandler(ExceptionType.DriverException,
                                                                          $"File could not be found: {path.ToString()}"));
                    return(null);
                }
                Console.WriteLine(e);
                Compiler.ExceptionListener.Throw(new ExceptionHandler("[73]Unexpected error with CheckScreen()"));
                return(null);
            }
            return("");
        }
Ejemplo n.º 10
0
        private string DeterminateType(Tokens.Token typeValue)
        {
            switch (typeValue)
            {
            case Tokens.Token.INT_VALUE:
                return("int");

            case Tokens.Token.DOUBLE_VALUE:
                return("double");

            case Tokens.Token.X16_VALUE:
                return("16x");

            case Tokens.Token.X8_VALUE:
                return("8x");

            case Tokens.Token.X2_VALUE:
                return("2x");

            default:
                return("");
            }
        }
Ejemplo n.º 11
0
 public ConsoleCommandAST(Tokens.Token command, ASTNode storage = null)
 {
     this.command = command;
     this.storage = storage;
 }
Ejemplo n.º 12
0
 public NumAST(Tokens.Token typeValue, string value)
 {
     this.typeValue = DeterminateType(typeValue);
     this.value     = value;
 }
Ejemplo n.º 13
0
 public void agregarToken(Tokens.Token tipo)
 {
     Salida.Add(new Tokens(tipo, Lexema, Renglon, numeroToken));
     Lexema = "";
     estado = 0;
 }
Ejemplo n.º 14
0
 internal InstructionVariableIdentifier(Tokens.Token token) : base(token)
 {
     Variable = new ExpressionVariableIdentifier(token);
 }
Ejemplo n.º 15
0
        public static TokenNode GetTokenError()
        {
            StringBuilder tokenBuilder = new StringBuilder();
            bool          isFindString = false;
            bool          isFindChar   = false;

            startTokenIndex = indexMemmory;
            // обработка слов
            for (; lineMemmory < stringWithoutComm.Length;)
            {
                for (; indexMemmory < line.Length; indexMemmory++)
                {
                    if (line[indexMemmory] == ' ' && !isFindString)
                    {
                        if (tokenBuilderMemory != null)
                        {
                            indexMemmory++;
                            return(CreateNodeToken(tokenTypeMemory, tokenBuilderMemory));
                        }
                        else
                        {
                            continue;
                        }
                    }
                    tokenBuilder.Append(line[indexMemmory]);
                    if (isFindString && line[indexMemmory] == '"')
                    {
                        isFindString = !isFindString;
                    }
                    else if (isFindString || line[indexMemmory] == '"')
                    {
                        isFindString = true;
                        continue;
                    }

                    if (isFindChar && line[indexMemmory] == '\'')
                    {
                        isFindChar = !isFindChar;
                    }
                    else if (isFindChar || line[indexMemmory] == '\'')
                    {
                        isFindChar = true;
                        continue;
                    }

                    // определения вида токена
                    Tokens.Token tokenType = FindToken(tokenBuilder.ToString());
                    if (Tokens.IsErrorToken(ref tokenType, tokenTypeMemory, tokenBuilder.Length) && indexMemmory != line.Length - 1)
                    {
                        tokenTypeMemory    = tokenType;
                        tokenBuilderMemory = tokenBuilder.ToString();
                        continue;
                    }

                    if (indexMemmory == line.Length - 1 && tokenType != Tokens.Token.FAILED)
                    {
                        tokenBuilderMemory = tokenBuilder.ToString();
                        tokenTypeMemory    = tokenType;
                        indexMemmory++;
                    }
                    return(CreateNodeToken(tokenTypeMemory, tokenBuilderMemory));
                }
                lineMemmory++;
                if (lineMemmory < stringWithoutComm.Length)
                {
                    indexMemmory = 0;
                    line         = stringWithoutComm[lineMemmory];
                    ConsoleHelper.WriteError(line);
                }
                else
                {
                    return(null);
                }
            }
            return(null);
        }
 internal ExpressionVariableIdentifier(Tokens.Token token) : base(token)
 {
     Name                = token.Content;
     IndexExpressions    = new ExpressionsCollection();
     IndexExpressionsRPN = new ExpressionsCollection();
 }
Ejemplo n.º 17
0
 public void Revert(Tokens.Token token)
 {
     stack.Push(token);
 }