コード例 #1
0
        public void TestUsingExpressionWithoutEndStatement()
        {
            var inputString     = new InputString(@"using System;
using Compiler.Parser.Nada
using jamones;");
            var tokenGenerators = Resources.getTokenGenerators();
            var lexer           = new Lexer(inputString, tokenGenerators);
            var parser          = new Compiler.Parser(lexer);

            Assert.Throws <SyntaxTokenExpectedException>(() => parser.parse());
        }
コード例 #2
0
        private void declaringLocaleVariablesTest()
        {
            printHeader("declaringLocaleVariablesTest");
            var inputString     = new InputFile(@"..\..\..\testFiles\localVariablesTests.txt");
            var tokenGenerators = Resources.getTokenGenerators();

            var lexer  = new Lexer(inputString, tokenGenerators);
            var parser = new Compiler.Parser(lexer);

            parser.parse();
            Console.Out.WriteLine("Parsed Successfully -> local Variables");
        }
コード例 #3
0
        public void interfaceDeclarationStmtTest()
        {
            printHeader("interfaceDeclarationStmtTest");
            var inputString     = new InputFile(@"..\..\..\testFiles\interfaceDeclarationTests.txt");
            var tokenGenerators = Resources.getTokenGenerators();

            var lexer  = new Lexer(inputString, tokenGenerators);
            var parser = new Compiler.Parser(lexer);

            parser.parse();
            Console.Out.WriteLine("Parsed Successfully -> enum");
        }
コード例 #4
0
        public void usingStmtTest()
        {
            printHeader("usingStmtTest");
            var inputString     = new InputFile(@"..\..\..\testFiles\usingTests.txt");
            var tokenGenerators = Resources.getTokenGenerators();

            var lexer  = new Lexer(inputString, tokenGenerators);
            var parser = new Compiler.Parser(lexer);

            parser.parse();
            Console.Out.WriteLine("Parsed Successfully -> usings");
        }
コード例 #5
0
        public void TestInterfaceExpressionWrongInheritanceExpression()
        {
            var inputString     = new InputString(@"using System;
using Compiler.Parser.Nada;
using jamones;
interface DIASDELASEMANA : Padre,, Tia{
    void metodo(int argument, float argument);
};");
            var tokenGenerators = Resources.getTokenGenerators();
            var lexer           = new Lexer(inputString, tokenGenerators);
            var parser          = new Compiler.Parser(lexer);

            Assert.Throws <SyntaxTokenExpectedException>(() => parser.parse());
        }
コード例 #6
0
        public void TestVariousAssignOperatorsInEnumExpression()
        {
            var inputString     = new InputString(@"using System;
using Compiler.Parser.Nada;
using jamones;
public enum DIASDELASEMANA{
    LUNES=1,MARTES=2,MIERCOLES==3,JUEVES=4,VIERNES=5,
}");
            var tokenGenerators = Resources.getTokenGenerators();
            var lexer           = new Lexer(inputString, tokenGenerators);
            var parser          = new Compiler.Parser(lexer);

            Assert.Throws <SyntaxTokenExpectedException>(() => parser.parse());
        }
コード例 #7
0
        public void TestBadArgumentsListInInterfaceMethodExpression()
        {
            var inputString     = new InputString(@"using System;
using Compiler.Parser.Nada;
using jamones;
public interface DIASDELASEMANA{
    void metodo(int argument, float argument argument);
}");
            var tokenGenerators = Resources.getTokenGenerators();
            var lexer           = new Lexer(inputString, tokenGenerators);
            var parser          = new Compiler.Parser(lexer);

            Assert.Throws <SyntaxTokenExpectedException>(() => parser.parse());
        }
コード例 #8
0
        public void TestClassCantHaveAbstractConstructor()
        {
            var inputString     = new InputString(@"using System;
using Compiler.Parser.Nada;
using jamones;
public class kevin : Nexer, Javier{
    public abstract  kevin(){}
}
");
            var tokenGenerators = Resources.getTokenGenerators();
            var lexer           = new Lexer(inputString, tokenGenerators);
            var parser          = new Compiler.Parser(lexer);

            Assert.Throws <SyntaxTokenExpectedException>(() => parser.parse());
        }
コード例 #9
0
        public void TestClassWithWrongInheritanceExpression()
        {
            var inputString     = new InputString(@"using System;
using Compiler.Parser.Nada;
using jamones;
public class kevin : Nexer, Javier,{
    public kevin();
}
");
            var tokenGenerators = Resources.getTokenGenerators();
            var lexer           = new Lexer(inputString, tokenGenerators);
            var parser          = new Compiler.Parser(lexer);

            Assert.Throws <SyntaxTokenExpectedException>(() => parser.parse());
        }
コード例 #10
0
        public void TestWrongIsExpression()
        {
            var inputString = new InputString(@"public class kevin : Javier
{
    int x = is persona carlos;
}");

            printHeader("TestWrongIsExpression");
            var tokenGenerators = Resources.getTokenGenerators();

            var lexer  = new Lexer(inputString, tokenGenerators);
            var parser = new Compiler.Parser(lexer);

            Assert.Throws <SyntaxTokenExpectedException>(() => parser.parse());
            Console.Out.WriteLine("Parsed Successfully -> TestWrongIsExpression");
        }
コード例 #11
0
        public void TestClassWrongNullCoalescingOperatorsInExpression()
        {
            var inputString = new InputString(@"public class kevin : Javier
{
    int LUNES = x ?? ( y ?? (t??5) );
    bool boleano = j ?? );
}");

            printHeader("TestClassWrongNullCoalescingOperatorsInExpression");
            var tokenGenerators = Resources.getTokenGenerators();

            var lexer  = new Lexer(inputString, tokenGenerators);
            var parser = new Compiler.Parser(lexer);

            Assert.Throws <SyntaxTokenExpectedException>(() => parser.parse());
            Console.Out.WriteLine("Parsed Successfully -> TestClassWrongNullCoalescingOperatorsInExpression");
        }
コード例 #12
0
        public void TestClassWWrongTernaryOperatorsInExpression()
        {
            var inputString = new InputString(@"public class kevin : Javier
{
    int LUNES = x==0? y=(5+3):z/2;
    bool boleano = y>5? k--: (k>4? y++k++);
}");

            printHeader("TestClassWWrongTernaryOperatorsInExpression");
            var tokenGenerators = Resources.getTokenGenerators();

            var lexer  = new Lexer(inputString, tokenGenerators);
            var parser = new Compiler.Parser(lexer);

            Assert.Throws <SyntaxTokenExpectedException>(() => parser.parse());
            Console.Out.WriteLine("Parsed Successfully -> TestClassWWrongTernaryOperatorsInExpression");
        }
コード例 #13
0
        public void TestWrongLogicalExpression()
        {
            var inputString = new InputString(@"public class kevin : Javier
{
    int LUNES = (!(isVisible && isHere) ||);
    bool boleano = isNull ?? true;
}");

            printHeader("TestWrongLogicalExpression");
            var tokenGenerators = Resources.getTokenGenerators();

            var lexer  = new Lexer(inputString, tokenGenerators);
            var parser = new Compiler.Parser(lexer);

            Assert.Throws <SyntaxTokenExpectedException>(() => parser.parse());
            Console.Out.WriteLine("Parsed Successfully -> TestWrongLogicalExpression");
        }
コード例 #14
0
        public void TestClassWrongMultiplicativeOperatorsInExpression()
        {
            var inputString = new InputString(@"public class kevin : Javier
{
    int LUNES =  (1 * 5);
    bool boleano = (x/5);
    int otro = 10 * (otro%mama) /; 
    float f = (mama / (0*5));
}");

            printHeader("expreTestClassWrongMultiplicativeOperatorsInExpressionssionsTest");
            var tokenGenerators = Resources.getTokenGenerators();

            var lexer  = new Lexer(inputString, tokenGenerators);
            var parser = new Compiler.Parser(lexer);

            Assert.Throws <SyntaxTokenExpectedException>(() => parser.parse());
            Console.Out.WriteLine("Parsed Successfully -> TestClassWrongMultiplicativeOperatorsInExpression");
        }
コード例 #15
0
        public void TestUsingAfterANamespaceExpression()
        {
            var inputString     = new InputString(@"using System;
using Otro;
using jamones;
namespace A{
    using prueba;
    namespace B
    {
        using prueba2.prueba3.prueba4;
    }
    using system;
}");
            var tokenGenerators = Resources.getTokenGenerators();
            var lexer           = new Lexer(inputString, tokenGenerators);
            var parser          = new Compiler.Parser(lexer);

            Assert.Throws <SyntaxTokenExpectedException>(() => parser.parse());
        }
コード例 #16
0
        public void TestClassWrongBinaryOperatorsInExpression()
        {
            var inputString = new InputString(@"public class kevin : Javier
{
    int LUNES =  1 << 5;
    bool boleano = 5;
    int otro = 10; 
    float f = (1 | (0 &) (100^100));
}");

            printHeader("TestClassWrongBinaryOperatorsInExpression");
            var tokenGenerators = Resources.getTokenGenerators();

            var lexer  = new Lexer(inputString, tokenGenerators);
            var parser = new Compiler.Parser(lexer);

            Assert.Throws <SyntaxTokenExpectedException>(() => parser.parse());
            Console.Out.WriteLine("Parsed Successfully -> TestClassWrongBinaryOperatorsInExpression");
        }
コード例 #17
0
        public void TestClassWrongAccesMemoryOperatorsInExpression()
        {
            var inputString = new InputString(@"public class kevin : Javier
{
    float mana = (float)(n.atributo);
    public int funcion = persona.methodo(x=3).metodo;
    float f = persona.tryParse(x);
    Persona persona = this.atributo;
    Persona persona = this.method(x,y,r,,nada);
}");

            printHeader("TestClassWrongAccesMemoryOperatorsInExpression");
            var tokenGenerators = Resources.getTokenGenerators();

            var lexer  = new Lexer(inputString, tokenGenerators);
            var parser = new Compiler.Parser(lexer);

            Assert.Throws <SyntaxTokenExpectedException>(() => parser.parse());
            Console.Out.WriteLine("Parsed Successfully -> TestClassWrongAccesMemoryOperatorsInExpression");
        }
コード例 #18
0
        public void TestWrongInlineExpression()
        {
            var inputString = new InputString(@"public class kevin : Javier
{
    int prueba = (!(isVisible && iden) || noEsta);
    int LUNES = ((5 + 3) + (4  3));
    int MARTES = ((5 * 9 / 3) - 7 + (2 * 7 + 4) / ( (128 >> 5 * 5) - (1 << 7 * 46) / 3 )) + 15;
    int MIERCOLES = 0;
    int x = y = z = w = MARTES / 2;
    Kevin kevin = new persona();
}");

            printHeader("TestWrongInlineExpression");
            var tokenGenerators = Resources.getTokenGenerators();

            var lexer  = new Lexer(inputString, tokenGenerators);
            var parser = new Compiler.Parser(lexer);

            Assert.Throws <SyntaxTokenExpectedException>(() => parser.parse());
            Console.Out.WriteLine("Parsed Successfully -> TestWrongInlineExpression");
        }
コード例 #19
0
        public void TestClassWrongArraysInExpression()
        {
            var inputString = new InputString(@"public class kevin : Javier
{
    float mana = new int[2][][][];
    private int arreglo =  new float[]{ 5,3,5}; 
    int arreglo = new int[,,];
    int arreglo = new int[2][]{ new int[5],new int[8]};
    int arreglo = { new int[5], new int[4], array };
    int value = new Persona(x,y,w).array[2];
    int[,,,] x = new int[5,5,3,4];
}");

            printHeader("TestClassWrongArraysInExpression");
            var tokenGenerators = Resources.getTokenGenerators();

            var lexer  = new Lexer(inputString, tokenGenerators);
            var parser = new Compiler.Parser(lexer);

            Assert.Throws <SyntaxTokenExpectedException>(() => parser.parse());
            Console.Out.WriteLine("Parsed Successfully -> TestClassWrongArraysInExpression");
        }
コード例 #20
0
        public void TestClassWrongUnaryOperatorsInExpression()
        {
            var inputString = new InputString(@"public class kevin : Javier
{
    int LUNES = (x += 5);
    bool boleano = (y >>= 5);
    int otro = ((x++));
    int nuevo = + ++y;
    float f = (~nada!);
    bool c = (~(nada && isVisible) || !isVisible);
    int t = (int)nada;
    float mana = (float)(n.atributo);
}");

            printHeader("TestClassWrongUnaryOperatorsInExpression");
            var tokenGenerators = Resources.getTokenGenerators();

            var lexer  = new Lexer(inputString, tokenGenerators);
            var parser = new Compiler.Parser(lexer);

            Assert.Throws <SyntaxTokenExpectedException>(() => parser.parse());
            Console.Out.WriteLine("Parsed Successfully -> exprTestClassWrongUnaryOperatorsInExpressionessions");
        }