Exemplo n.º 1
0
        public static Function LineToFunction(string s, FunctionTable ftable)
        {
            char[]   delimiter = { ' ' };
            string[] parts     = s.Trim().Split(delimiter);
            if (parts.Length != 2)
            {
                throw new Exception("Line does not respect syntax");
            }

            int   index  = 0;
            ulong idnum  = GetIdNatural(parts[0], ref index);
            char  idchar = GetIdLetter(parts[0], ref index);

            if (index != parts[0].Length)
            {
                throw new Exception("Wrong line format !");
            }
            Function f = new Function(idnum, idchar, parts[1], ftable);

            return(f);
        }
Exemplo n.º 2
0
        private void ParseCommands(string commands, FunctionTable ftable)
        // Given the command string and the ftable, parses commands by creating
        // a lambda expression and adding it to the list every time.
        {
            int index = 0;

            while (index < commands.Length)
            {
                Action act;
                switch (LexerParser.CommandLexer(commands, index++))
                {
                case LexerParser.CommandToken.TOKEN_INCREMENT:
                {
                    throw new NotImplementedException("Do it");
                }

                case LexerParser.CommandToken.TOKEN_DECREMENT:
                {
                    throw new NotImplementedException("Do it");
                }

                case LexerParser.CommandToken.TOKEN_OUTPUT:
                {
                    throw new NotImplementedException("Do it");
                }

                case LexerParser.CommandToken.TOKEN_INPUT:
                {
                    throw new NotImplementedException("Do it");
                }

                case LexerParser.CommandToken.TOKEN_MOVE_IN:
                {
                    throw new NotImplementedException("Do it");
                }

                case LexerParser.CommandToken.TOKEN_MOVE_OUT:
                {
                    throw new NotImplementedException("Do it");
                }

                case LexerParser.CommandToken.TOKEN_CALL:
                {
                    // calling a function simply consists in executing it...
                    throw new NotImplementedException("Do it");
                }

                case LexerParser.CommandToken.TOKEN_CALL_ACC:
                {
                    throw new NotImplementedException("Do it");
                }

                default:
                {
                    throw new Exception("Unexpected token in parsing");
                }
                }

                execution.Add(act);
            }
        }