Beispiel #1
0
 public override void Visit(VersionSpecification vs)
 {
     if (_checkForMatchinSpecConditions(vs))
     {
         l.AddVersionCondition(vs);
     }
 }
Beispiel #2
0
 public override void Visit(VersionSpecification s)
 {
     if (CheckCondition(s.Attributes) >= 0)
     {
         conditionStack.Peek().AddVersionCondition(s);
     }
 }
 public override void Visit(VersionSpecification s)
 {
     if (s.SpecifiedId == DTokens.IncompleteId)
     {
         prv  = new VersionSpecificationCompletionProvider(cdgen);
         halt = true;
     }
 }
Beispiel #4
0
 public void AddVersionCondition(VersionSpecification vs)
 {
     if (vs.SpecifiedId == null)
     {
         AddVersionCondition(vs.SpecifiedNumber);
     }
     else
     {
         AddVersionCondition(vs.SpecifiedId);
     }
 }
 public void CantParseMajorBugfix()
 {
     try
     {
         VersionSpecification.Create("10..1");
         Assert.Fail("Exception expected");
     }
     catch (ArgumentException e)
     {
         // ok
         Console.WriteLine(@"Expected exception: {0}", e.Message);
     }
 }
        public void CanDetermineGreaterThanMajorMinorBugfix()
        {
            VersionSpecification versionSpecification = VersionSpecification.Create("10.2.1");

            Assert.IsFalse(versionSpecification.IsGreaterThan(11, 1, 0));
            Assert.IsFalse(versionSpecification.IsGreaterThan(10, 3, 0));
            Assert.IsFalse(versionSpecification.IsGreaterThan(10, 2, 2));

            Assert.IsFalse(versionSpecification.IsGreaterThan(10, 2, 1));

            Assert.IsTrue(versionSpecification.IsGreaterThan(10, 2, 0));
            Assert.IsTrue(versionSpecification.IsGreaterThan(10, 1, 2));
            Assert.IsTrue(versionSpecification.IsGreaterThan(9, 3, 2));
        }
        public void CanDetermineLowerThanMajor()
        {
            VersionSpecification versionSpecification = VersionSpecification.Create("10");

            Assert.IsTrue(versionSpecification.IsLowerThan(11, 1, 0));

            Assert.IsFalse(versionSpecification.IsLowerThan(10, 3, 0));
            Assert.IsFalse(versionSpecification.IsLowerThan(10, 2, 2));
            Assert.IsFalse(versionSpecification.IsLowerThan(10, 2, 1));
            Assert.IsFalse(versionSpecification.IsLowerThan(10, 2, 0));
            Assert.IsFalse(versionSpecification.IsLowerThan(10, 1, 2));

            Assert.IsFalse(versionSpecification.IsLowerThan(9, 3, 2));
        }
			public override void Visit(VersionSpecification vs)
			{
				if (_checkForMatchinSpecConditions(vs))
					l.AddVersionCondition (vs);
			}
Beispiel #9
0
        public void DeclDef(DBlockNode module)
        {
            if (IsAttributeSpecifier) {
                do
                    AttributeSpecifier (module);
                while(IsAttributeSpecifier);

                var tkind = t.Kind;
                if(tkind == Semicolon || tkind == CloseCurlyBrace || tkind == Colon)
                    return;
            }

            if (laKind == Semicolon)
            {
                Step();
                return;
            }

            switch (laKind)
            {
                case Import:
                    module.Add(ImportDeclaration(module));
                    break;
                case This:
                    module.Add(Constructor(module, module is DClassLike && ((DClassLike)module).ClassType == DTokens.Struct));
                    break;
                case Tilde:
                    if (Lexer.CurrentPeekToken.Kind != This)
                        goto default;
                    module.Add(Destructor());
                    break;
                case Invariant:
                    module.Add(_Invariant());
                    break;
                case Unittest:
                    Step();
                    var dbs = new DMethod(DMethod.MethodType.Unittest);
                    ApplyAttributes(dbs);
                    dbs.Location = t.Location;
                    FunctionBody(dbs);
                    dbs.EndLocation = t.EndLocation;
                    module.Add(dbs);
                    break;
                /*
                 * VersionSpecification:
                 *		version = Identifier ;
                 *		version = IntegerLiteral ;
                 *
                 * DebugSpecification:
                 *		debug = Identifier ;
                 *		debug = IntegerLiteral ;
                 */
                case Version:
                case Debug:
                    if (Peek(1).Kind == Assign)
                    {
                        DebugSpecification ds = null;
                        VersionSpecification vs = null;

                        if (laKind == Version)
                            vs = new VersionSpecification {
                                Location = la.Location,
                                Attributes = GetCurrentAttributeSet_Array()
                            };
                        else
                            ds = new DebugSpecification {
                                Location = la.Location,
                                Attributes = GetCurrentAttributeSet_Array()
                            };

                        Step();
                        Step();

                        if (laKind == Literal)
                        {
                            Step();
                            if (t.LiteralFormat != LiteralFormat.Scalar)
                                SynErr(t.Kind, "Integer literal expected!");
                            try
                            {
                                if (vs != null)
                                    vs.SpecifiedNumber = Convert.ToInt32(t.LiteralValue);
                                else
                                    ds.SpecifiedDebugLevel = Convert.ToInt32(t.LiteralValue);
                            }
                            catch
                            {
                            }
                        }
                        else if (laKind == Identifier)
                        {
                            Step();
                            if (vs != null)
                                vs.SpecifiedId = t.Value;
                            else
                                ds.SpecifiedId = t.Value;
                        }
                        else if (ds == null)
                            Expect(Identifier);

                        Expect(Semicolon);

                        ((AbstractStatement)ds ?? vs).EndLocation = t.EndLocation;

                        module.Add(vs as StaticStatement ?? ds);
                    }
                    else
                        DeclarationCondition(module);
                    break;
                case Static:
                    if (Lexer.CurrentPeekToken.Kind == If)
                        goto case Version;
                    goto default;
                case Assert:
                    Step();
                    CheckForStorageClasses(module);
                    if (!Modifier.ContainsAttribute(DeclarationAttributes, Static))
                        SynErr(Static, "Static assert statements must be explicitly marked as static");

                    var ass = new StaticAssertStatement {
                        Attributes = GetCurrentAttributeSet_Array(),
                        Location = t.Location
                    };

                    if (Expect(OpenParenthesis))
                    {
                        ass.AssertedExpression = AssignExpression();
                        if (laKind == (Comma))
                        {
                            Step();
                            ass.Message = AssignExpression();
                        }
                        if (Expect(CloseParenthesis))
                            Expect(Semicolon);
                    }

                    ass.EndLocation = t.EndLocation;

                    module.Add(ass);
                    break;
                case Mixin:
                    if (Peek(1).Kind == Template)
                        module.Add(TemplateDeclaration(module));

                    //TemplateMixin
                    else if (Lexer.CurrentPeekToken.Kind == Identifier)
                    {
                        var tmx = TemplateMixin(module);
                        if (tmx.MixinId == null)
                            module.Add(tmx);
                        else
                            module.Add(new NamedTemplateMixinNode(tmx));
                    }

                    //MixinDeclaration
                    else if (Lexer.CurrentPeekToken.Kind == OpenParenthesis)
                        module.Add(MixinDeclaration(module, null));
                    else
                    {
                        Step();
                        SynErr(Identifier);
                    }
                    break;
                case OpenCurlyBrace:
                    AttributeBlock(module);
                    break;
                // Class Allocators
                // Note: Although occuring in global scope, parse it anyway but declare it as semantic nonsense;)
                case New:
                    Step();

                    var dm = new DMethod(DMethod.MethodType.Allocator) { Location = t.Location };
                    ApplyAttributes(dm);

                    dm.Parameters = Parameters(dm);
                    FunctionBody(dm);
                    dm.EndLocation = t.EndLocation;
                    module.Add(dm);
                    break;
                case Delete:
                    Step();

                    var ddm = new DMethod(DMethod.MethodType.Deallocator) { Location = t.Location };
                    ddm.Name = "delete";
                    ApplyAttributes(ddm);

                    ddm.Parameters = Parameters(ddm);
                    FunctionBody(ddm);
                    ddm.EndLocation = t.EndLocation;
                    module.Add(ddm);
                    break;
                default:
                    var decls = Declaration(module);
                    if(module != null && decls!=null)
                        module.AddRange(decls);
                    break;
            }
        }
Beispiel #10
0
        void DeclDef(DBlockNode module)
        {
            //AttributeSpecifier
            while (IsAttributeSpecifier())
            {
                AttributeSpecifier(module);

                if (t.Kind == Colon || laKind == CloseCurlyBrace || IsEOF)
                    return;
            }

            if (laKind == Semicolon)
            {
                LastParsedObject = null;
                Step();
                return;
            }

            //ImportDeclaration
            if (laKind == Import)
                module.Add(ImportDeclaration(module));

            //Constructor
            else if (laKind == (This))
                module.Add(Constructor(module, module is DClassLike ? ((DClassLike)module).ClassType == DTokens.Struct : false));

            //Destructor
            else if (laKind == (Tilde) && Lexer.CurrentPeekToken.Kind == (This))
                module.Add(Destructor());

            //Invariant
            else if (laKind == (Invariant))
                module.Add(_Invariant());

            //UnitTest
            else if (laKind == (Unittest))
            {
                Step();
                var dbs = new DMethod(DMethod.MethodType.Unittest);
                ApplyAttributes(dbs);
                LastParsedObject = dbs;
                dbs.Location = t.Location;
                FunctionBody(dbs);
                dbs.EndLocation = t.EndLocation;
                module.Add(dbs);
            }

            /*
             * VersionSpecification:
             *		version = Identifier ;
             *		version = IntegerLiteral ;
             *
             * DebugSpecification:
             *		debug = Identifier ;
             *		debug = IntegerLiteral ;
             */
            else if ((laKind == Version || laKind == Debug) && Peek(1).Kind == Assign)
            {
                DebugSpecification ds = null;
                VersionSpecification vs = null;

                if (laKind == Version)
                    LastParsedObject = vs = new VersionSpecification { Location = la.Location, Attributes = GetCurrentAttributeSet_Array() };
                else
                    LastParsedObject = ds = new DebugSpecification { Location = la.Location, Attributes = GetCurrentAttributeSet_Array() };

                Step();
                Step();

                if (laKind == Literal)
                {
                    Step();
                    if (t.LiteralFormat != LiteralFormat.Scalar)
                        SynErr(t.Kind, "Integer literal expected!");
                    try
                    {
                        if (vs != null)
                            vs.SpecifiedNumber = Convert.ToInt32(t.LiteralValue);
                        else
                            ds.SpecifiedDebugLevel = Convert.ToInt32(t.LiteralValue);
                    }
                    catch { }
                }
                else if (laKind == Identifier)
                {
                    Step();
                    if (vs != null)
                        vs.SpecifiedId = t.Value;
                    else
                        ds.SpecifiedId = t.Value;
                }
                else if (ds == null)
                    Expect(Identifier);

                Expect(Semicolon);

                if (vs == null)
                    ds.EndLocation = t.EndLocation;
                else
                    vs.EndLocation = t.EndLocation;

                module.Add(vs as StaticStatement ?? ds);
            }

            else if (laKind == Version || laKind == Debug || (laKind == Static && Lexer.CurrentPeekToken.Kind == If))
                DeclarationCondition(module);

            //StaticAssert
            else if (laKind == (Assert))
            {
                Step();

                if (!Modifier.ContainsAttribute(DeclarationAttributes, Static))
                    SynErr(Static, "Static assert statements must be explicitly marked as static");

                var ass = new StaticAssertStatement { Attributes = GetCurrentAttributeSet_Array(), Location = t.Location };

                if (Expect(OpenParenthesis))
                {
                    ass.AssertedExpression = AssignExpression();
                    if (laKind == (Comma))
                    {
                        Step();
                        ass.Message = AssignExpression();
                    }
                    if(Expect(CloseParenthesis))
                        Expect(Semicolon);
                }

                ass.EndLocation = t.EndLocation;

                module.Add(ass);
            }

            //TemplateMixinDeclaration
            else if (laKind == Mixin)
            {
                if (Peek(1).Kind == Template)
                    module.Add(TemplateDeclaration(module));

                //TemplateMixin
                else if (Lexer.CurrentPeekToken.Kind == Identifier)
                {
                    var tmx = TemplateMixin(module);
                    if(tmx.MixinId==null)
                        module.Add(tmx);
                    else
                        module.Add(new NamedTemplateMixinNode(tmx));
                }

                //MixinDeclaration
                else if (Lexer.CurrentPeekToken.Kind == OpenParenthesis)
                    module.Add(MixinDeclaration(module,null));
                else
                {
                    Step();
                    SynErr(Identifier);
                }
            }

            // {
            else if (laKind == (OpenCurlyBrace))
                AttributeBlock(module);

            // Class Allocators
            // Note: Although occuring in global scope, parse it anyway but declare it as semantic nonsense;)
            else if (laKind == (New))
            {
                Step();

                var dm = new DMethod(DMethod.MethodType.Allocator) { Location = t.Location };
                ApplyAttributes(dm);

                dm.Parameters = Parameters(dm);
                FunctionBody(dm);
                dm.EndLocation = t.EndLocation;
                module.Add(dm);
            }

            // Class Deallocators
            else if (laKind == Delete)
            {
                Step();

                var dm = new DMethod(DMethod.MethodType.Deallocator) { Location = t.Location };
                dm.Name = "delete";
                ApplyAttributes(dm);

                dm.Parameters = Parameters(dm);
                FunctionBody(dm);
                dm.EndLocation = t.EndLocation;
                module.Add(dm);
            }

            // else:
            else
            {
                var decls = Declaration(module);
                if(module != null && decls!=null)
                    module.AddRange(decls);
            }
        }
Beispiel #11
0
 public void Visit(VersionSpecification versionSpecification)
 {
 }
        public void CanParseMajorOnly()
        {
            VersionSpecification versionSpecification = VersionSpecification.Create("10");

            Assert.AreEqual("10.*.*", versionSpecification.VersionString);
        }
        public void CanParseMajorMinorBugfix()
        {
            VersionSpecification versionSpecification = VersionSpecification.Create("10.2.1");

            Assert.AreEqual("10.2.1", versionSpecification.VersionString);
        }
Beispiel #14
0
		public void DeclDef(DBlockNode module)
		{
			if (IsAttributeSpecifier) {
				do
					AttributeSpecifier (module);
				while(IsAttributeSpecifier);

				var tkind = t.Kind;
				if(tkind == Semicolon || tkind == CloseCurlyBrace || tkind == Colon)
					return;
			}

			if (laKind == Semicolon)
			{
				Step();
				return;
			}

			switch (laKind)
			{
				case DTokens.Module:
					var mod = module as DModule;

					var ddoc = GetComments ();
					var ms = ModuleDeclaration ();
					ms.ParentNode = module;
					ddoc += CheckForPostSemicolonComment ();

					if (mod != null) {
						if (mod.StaticStatements.Count != 0 ||
						    mod.Children.Count != 0)
							SynErr (DTokens.Module, "Module declaration must stand at a module's beginning.");
							
						mod.OptionalModuleStatement = ms;
						mod.Description = ddoc;

						if (ms.ModuleName!=null)
							mod.ModuleName = ms.ModuleName.ToString();
					} else
						SynErr (DTokens.Module, "Module statements only allowed in module scope.");

					module.Add (ms);
					break;
				case Import:
					module.Add(ImportDeclaration(module));
					break;
				case This:
					module.Add(Constructor(module, module is DClassLike && ((DClassLike)module).ClassType == DTokens.Struct));
					break;
				case Tilde:
					if (Lexer.CurrentPeekToken.Kind != This)
						goto default;
					module.Add(Destructor());
					break;
				case Invariant:
					module.Add(_Invariant());
					break;
				case Unittest:
					Step();
					var dbs = new DMethod(DMethod.MethodType.Unittest);
					ApplyAttributes(dbs);
					dbs.Location = t.Location;
					FunctionBody(dbs);
					module.Add(dbs);
					break;
				/*
				 * VersionSpecification: 
				 *		version = Identifier ; 
				 *		version = IntegerLiteral ;
				 * 
				 * DebugSpecification: 
				 *		debug = Identifier ; 
				 *		debug = IntegerLiteral ;
				 */
				case Version:
				case Debug:
					if (Peek(1).Kind == Assign)
					{
						DebugSpecification ds = null;
						VersionSpecification vs = null;

						if (laKind == Version)
							vs = new VersionSpecification {
								Location = la.Location,
								Attributes = GetCurrentAttributeSet_Array()
							};
						else
							ds = new DebugSpecification {
								Location = la.Location,
								Attributes = GetCurrentAttributeSet_Array()
							};

						Step();
						Step();

						if (laKind == Literal) {
							Step ();
							if (t.LiteralFormat != LiteralFormat.Scalar)
								SynErr (t.Kind, "Integer literal expected!");
							try {
								if (vs != null)
									vs.SpecifiedNumber = Convert.ToUInt64 (t.LiteralValue);
								else
									ds.SpecifiedDebugLevel = Convert.ToUInt64 (t.LiteralValue);
							} catch {
							}
						} else if (laKind == Identifier) {
							Step ();
							if (vs != null)
								vs.SpecifiedId = t.Value;
							else
								ds.SpecifiedId = t.Value;
						} else if (IsEOF) {
							if (vs != null)
								vs.SpecifiedId = DTokens.IncompleteId;
							else
								ds.SpecifiedId = DTokens.IncompleteId;
						}
						else if (ds == null)
							Expect(Identifier);

						Expect(Semicolon);

						((AbstractStatement)ds ?? vs).EndLocation = t.EndLocation;

						module.Add(vs as StaticStatement ?? ds);
					}
					else
						DeclarationCondition(module);
					break;
				case Static:
					if (Lexer.CurrentPeekToken.Kind == If)
						goto case Version;
					goto default;
				case Assert:
					Step();
					CheckForStorageClasses(module);
					if (!Modifier.ContainsAttribute(DeclarationAttributes, Static))
						SynErr(Static, "Static assert statements must be explicitly marked as static");

					module.Add(ParseStaticAssertStatement(module));
					Expect(Semicolon);
					break;
				case Mixin:
					switch(Peek(1).Kind)
					{
						case Template:
							module.Add (TemplateDeclaration (module));
							break;
						
						case DTokens.__vector:
						case DTokens.Typeof:
						case Dot:
						case Identifier://TemplateMixin
							var tmx = TemplateMixin (module);
							if (tmx.MixinId == null)
								module.Add (tmx);
							else
								module.Add (new NamedTemplateMixinNode (tmx));
							break;

						case OpenParenthesis:
							module.Add (MixinDeclaration (module, null));
							break;
						default:
							Step ();
							SynErr (Identifier);
							break;
					}
					break;
				case OpenCurlyBrace:
					AttributeBlock(module);
					break;
				// Class Allocators
				// Note: Although occuring in global scope, parse it anyway but declare it as semantic nonsense;)
				case New:
					Step();

					var dm = new DMethod(DMethod.MethodType.Allocator) { Location = t.Location };
					ApplyAttributes(dm);

					Parameters(dm);
					FunctionBody(dm);
					module.Add(dm);
					break;
				case Delete:
					Step();

					var ddm = new DMethod(DMethod.MethodType.Deallocator) { Location = t.Location };
					ddm.Name = "delete";
					ApplyAttributes(ddm);

					Parameters(ddm);
					FunctionBody(ddm);
					module.Add(ddm);
					break;
				default:
					var decls = Declaration(module);
					if(module != null && decls!=null)
						module.AddRange(decls);
					break;
			}
		}
Beispiel #15
0
 public void Visit(VersionSpecification versionSpecification)
 {
 }
		public override void Visit (VersionSpecification s)
		{
			if (s.SpecifiedId == DTokens.IncompleteId) {
				prv = new VersionSpecificationCompletionProvider(cdgen);
				halt = true;
			}
		}