Esempio n. 1
0
        public void nextToken()
        {
            if (indiceToken == lexBuf.Count - 1)
            {
                if (codeToParse == string.Empty)
                {

                }
                lexCode();
            }

            indiceToken++;

            if (indiceToken >= lexBuf.Count)
            {
                throw new Exception();
            }

            currentToken = lexBuf.ElementAt(indiceToken);
        }
Esempio n. 2
0
 public void nextTokenIfEquals(Token.TokenValue value)
 {
     if (currentTokenEquals(value))
     {
         nextToken();
     }
     else
     {
         throw new SyntaxError(lineNumber, colNumber, value);
     }
 }
Esempio n. 3
0
        private static byte tokenPriority(Token.TokenValue tok)
        {
            switch (tok)
            {

                case Token.TokenValue.AND:
                    return 9;
                case Token.TokenValue.OR:
                    return 8;

                case Token.TokenValue.GT:
                case Token.TokenValue.LT:
                case Token.TokenValue.GEQ:
                case Token.TokenValue.LEQ:
                case Token.TokenValue.EQBOOL:
                    return 7;

                case Token.TokenValue.NEG:
                    return 6;

                case Token.TokenValue.PLUS:
                case Token.TokenValue.MINUS:
                    return 4;

                case Token.TokenValue.TIMES:
                case Token.TokenValue.DIV:
                    return 3;

                default:
                    return 0;
            }
        }
Esempio n. 4
0
        public void previousToken()
        {
            indiceToken--;

            if (indiceToken < 0)
            {
                throw new Exception();
            }

            currentToken = lexBuf.ElementAt(indiceToken);
        }
Esempio n. 5
0
        public bool isAnAssignOperator(Token.TokenValue op)
        {
            switch (op)
            {
                case Token.TokenValue.EQ:

                case Token.TokenValue.PLUSEQ:
                case Token.TokenValue.MINUSEQ:
                case Token.TokenValue.TIMESEQ:
                case Token.TokenValue.DIVEQ:

                case Token.TokenValue.PLUSPLUS:
                case Token.TokenValue.MINUSMINUS:
                case Token.TokenValue.TIMESTIMES:
                    return true;

                default:
                    return false;
            }
        }
Esempio n. 6
0
        private BinaryOperatorExpression balanceBinaryExpression(SimpleExpression exp, Token.TokenValue op, BinaryOperatorExpression binExp)
        {
            if (tokenPriority(op) >= tokenPriority(binExp.op))
            {
                return new BinaryOperatorExpression(op, exp, binExp);
            }

            if (binExp.e1 is BinaryOperatorExpression)
            {
                return new BinaryOperatorExpression(binExp.op, balanceBinaryExpression(exp, op, (BinaryOperatorExpression)binExp.e1), binExp.e2);
            }

            return new BinaryOperatorExpression(binExp.op, new BinaryOperatorExpression(op, exp, binExp.e1), binExp.e2);
        }
Esempio n. 7
0
 public UnaryOperatorExpression(Token.TokenValue operatorToken, SimpleExpression expr)
 {
     op = operatorToken;
     exp = expr;
 }
Esempio n. 8
0
 public VariableUpdate(PathExpression varPath, Token.TokenValue opUpdate)
 {
     this.variable = varPath;
     this.op = opUpdate;
 }
Esempio n. 9
0
        public bool startParse()
        {
            /*if (lexBuf.Count == 0)
            {
                return true;
            }*/

            if (codeToParse == string.Empty)
            {
                return true;
            }

            lexCode();

            currentToken = lexBuf.ElementAt(indiceToken);

            try
            {
                while (!currentTokenEquals(Token.TokenValue.EOF))
                {
                    switch (currentToken.type)
                    {

                        case Token.TokenValue.NPC:
                            script.addNpc(parseNpc());
                            break;

                        default:
                            return false;

                    }
                }
            }
            catch (BaseException e)
            {
                //Print.Printer.printError("[Exception]");
                //IrisPrinter.Printer.printError(e.ExceptionToString());
                System.Windows.MessageBox.Show(e.ExceptionToString());
                return false;
            }

            return true;
        }
Esempio n. 10
0
 public BinaryOperatorExpression(Token.TokenValue opValue, SimpleExpression left, SimpleExpression right)
 {
     this.op = opValue;
     this.e1 = left;
     this.e2 = right;
 }
Esempio n. 11
0
        /*public bool nextTokenEquals(Token.TokenValue value)
        {
            if (indiceToken + 1 >= lexBuf.Count)
            {
                //erreur
                return false;
                //throw new Exception();
            }

            return (lexBuf.ElementAt(indiceToken + 1).type == value);
        }*/

        public bool currentTokenEquals(Token.TokenValue value)
        {
            /*if (indiceToken >= lexBuf.Count)
            {
                //erreur
                return false;
            }*/

            return (currentToken.type == value);
        }
Esempio n. 12
0
        public bool startParse()
        {
            if (codeToParse == string.Empty || codeToParse == null)
            {
                return true;
            }

            lexCode();

            currentToken = lexBuf.ElementAt(indiceToken);

            try
            {
                while (!currentTokenEquals(Token.TokenValue.EOF))
                {
                    switch (currentToken.type)
                    {

                        case Token.TokenValue.CHARACTER:
                            script.addCharacter(parseCharacter());
                            break;

                        case Token.TokenValue.IMAGE:
                            script.addImage(parseImage());
                            break;

                        case Token.TokenValue.SOUND:
                            script.addSound(parseSound());
                            break;

                        case Token.TokenValue.BACKGROUND:
                            script.addBackground(parseBackground());
                            break;

                        default:
                            return false;

                    }
                }
            }
            catch (BaseException e)
            {
                System.Windows.MessageBox.Show(e.ExceptionToString());
                return false;
            }

            fileStream.Close();

            return true;
        }
Esempio n. 13
0
 public LiteralExpression(Token val)
 {
     this.value = val;
 }
Esempio n. 14
0
 public bool currentTokenEquals(Token.TokenValue value)
 {
     return (currentToken.type == value);
 }
Esempio n. 15
0
        public void nextToken()
        {
            if (indiceToken == lexBuf.Count - 1)
            {
                lexCode();
            }

            indiceToken++;

            if (indiceToken >= lexBuf.Count)
            {
                //erreur
                //return;
                throw new Exception();
            }

            currentToken = lexBuf.ElementAt(indiceToken);
        }
Esempio n. 16
0
        public bool startParse()
        {
            if (codeToParse == string.Empty || codeToParse == null)
            {
                return true;
            }

            lexCode();

            currentToken = lexBuf.ElementAt(indiceToken);

            try
            {
                while (!currentTokenEquals(Token.TokenValue.EOF))
                {
                    switch (currentToken.type)
                    {
                        case Token.TokenValue.NPC:
                            script.addNpc(parseNpc());
                            break;

                        default:
                            return false;
                    }
                }
            }
            catch (BaseException e)
            {
                System.Windows.MessageBox.Show(e.ExceptionToString());
                return false;
            }

            fileStream.Close();

            return true;
        }
Esempio n. 17
0
File: Token.cs Progetto: rokuan/iris
 public static string tokenstring(Token tok)
 {
     return tokenstring(tok);
 }