Exemple #1
0
        public static TypeMemberCollection Lift(Block block)
        {
            var members = new TypeMemberCollection();

            LiftBlockInto(members, block);
            return(members);
        }
Exemple #2
0
        public static TypeMemberCollection FromArray(params Boo.Lang.Compiler.Ast.TypeMember[] items)
        {
            TypeMemberCollection collection = new TypeMemberCollection();

            collection.Extend(items);
            return(collection);
        }
Exemple #3
0
		public static TypeMemberCollection FromArray(params object[] items)
		{
			var result = new TypeMemberCollection();
			foreach (var item in items)
			{
				var typeMember = item as TypeMember;
				if (typeMember != null)
					result.Add(typeMember);
				else
					result.AddRange((IEnumerable<TypeMember>)item);
			}
			return result;
		}
Exemple #4
0
 private static void LiftBlockInto(TypeMemberCollection collection, Block block)
 {
     foreach (var stmt in block.Statements)
     {
         var childBlock = stmt as Block;
         if (childBlock != null)
         {
             LiftBlockInto(collection, childBlock);
         }
         else
         {
             collection.Add(TypeMember.Lift(stmt));
         }
     }
 }
        public static TypeMemberCollection FromArray(params object[] items)
        {
            var result = new TypeMemberCollection();

            foreach (var item in items)
            {
                var typeMember = item as TypeMember;
                if (typeMember != null)
                {
                    result.Add(typeMember);
                }
                else
                {
                    result.Extend((IEnumerable <TypeMember>)item);
                }
            }
            return(result);
        }
Exemple #6
0
 public Boo.Lang.Compiler.Ast.TypeMemberCollection PopRange(int begin)
 {
     Boo.Lang.Compiler.Ast.TypeMemberCollection range = new Boo.Lang.Compiler.Ast.TypeMemberCollection(_parent);
     range.InnerList.Extend(InternalPopRange(begin));
     return(range);
 }
Exemple #7
0
	protected void interface_property(
		TypeMemberCollection container
	) //throws RecognitionException, TokenStreamException
{
		
		IToken  id1 = null;
		IToken  s = null;
		
				IToken id = null;
		Property p = null;
		TypeReference tr = null;
		ParameterDeclarationCollection parameters = null;
		
		
		try {      // for error handling
			{
				switch ( LA(1) )
				{
				case ID:
				{
					id1 = LT(1);
					match(ID);
					if (0==inputState.guessing)
					{
						id=id1;
					}
					break;
				}
				case SELF:
				{
					s = LT(1);
					match(SELF);
					if (0==inputState.guessing)
					{
						id=s;
					}
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			if (0==inputState.guessing)
			{
				
				p = new Property(ToLexicalInfo(id));
				p.Name = id.getText();
				AddAttributes(p.Attributes);
				container.Add(p);
				parameters = p.Parameters;
				
			}
			{
				switch ( LA(1) )
				{
				case LPAREN:
				case LBRACK:
				{
					{
						switch ( LA(1) )
						{
						case LBRACK:
						{
							match(LBRACK);
							break;
						}
						case LPAREN:
						{
							match(LPAREN);
							break;
						}
						default:
						{
							throw new NoViableAltException(LT(1), getFilename());
						}
						 }
					}
					parameter_declaration_list(parameters);
					{
						switch ( LA(1) )
						{
						case RBRACK:
						{
							match(RBRACK);
							break;
						}
						case RPAREN:
						{
							match(RPAREN);
							break;
						}
						default:
						{
							throw new NoViableAltException(LT(1), getFilename());
						}
						 }
					}
					break;
				}
				case AS:
				case COLON:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			{
				switch ( LA(1) )
				{
				case AS:
				{
					match(AS);
					tr=type_reference();
					break;
				}
				case COLON:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			if (0==inputState.guessing)
			{
				
				p.Type = tr;
				
			}
			begin_with_doc(p);
			{ // ( ... )+
				int _cnt114=0;
				for (;;)
				{
					if ((LA(1)==GET||LA(1)==SET||LA(1)==LBRACK))
					{
						interface_property_accessor(p);
					}
					else
					{
						if (_cnt114 >= 1) { goto _loop114_breakloop; } else { throw new NoViableAltException(LT(1), getFilename());; }
					}
					
					_cnt114++;
				}
_loop114_breakloop:				;
			}    // ( ... )+
			end(p);
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "interface_property");
				recover(ex,tokenSet_58_);
			}
			else
			{
				throw ex;
			}
		}
	}
Exemple #8
0
	protected void type_member(
		TypeMemberCollection container
	) //throws RecognitionException, TokenStreamException
{
		
		
		try {      // for error handling
			attributes();
			modifiers();
			{
				switch ( LA(1) )
				{
				case CALLABLE:
				case CLASS:
				case ENUM:
				case INTERFACE:
				case STRUCT:
				{
					type_definition(container);
					break;
				}
				case CONSTRUCTOR:
				case DEF:
				case DESTRUCTOR:
				{
					method(container);
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "type_member");
				recover(ex,tokenSet_16_);
			}
			else
			{
				throw ex;
			}
		}
	}
Exemple #9
0
	public void splice_type_definition_body(
		TypeMemberCollection container
	) //throws RecognitionException, TokenStreamException
{
		
		IToken  begin = null;
		
			Expression e = null;
		
		
		try {      // for error handling
			begin = LT(1);
			match(SPLICE_BEGIN);
			e=atom();
			eos();
			if (0==inputState.guessing)
			{
				
						container.Add(new SpliceTypeDefinitionBody(e));
					
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "splice_type_definition_body");
				recover(ex,tokenSet_49_);
			}
			else
			{
				throw ex;
			}
		}
	}
Exemple #10
0
	protected void field_or_property(
		TypeMemberCollection container
	) //throws RecognitionException, TokenStreamException
{
		
		IToken  id1 = null;
		IToken  begin1 = null;
		IToken  s = null;
		IToken  lparen = null;
		IToken  id2 = null;
		IToken  begin2 = null;
		
			IToken id = null;
			TypeMember tm = null;
			TypeReference tr = null;
			Property p = null;
			Field field = null;
			ExplicitMemberInfo emi = null;
			Expression initializer = null;
			ParameterDeclarationCollection parameters = null;
			Expression nameSplice = null;
		
		
		try {      // for error handling
			{
				bool synPredMatched156 = false;
				if (((LA(1)==SELF||LA(1)==ID||LA(1)==SPLICE_BEGIN) && (tokenSet_34_.member(LA(2)))))
				{
					int _m156 = mark();
					synPredMatched156 = true;
					inputState.guessing++;
					try {
						{
							property_header();
						}
					}
					catch (RecognitionException)
					{
						synPredMatched156 = false;
					}
					rewind(_m156);
					inputState.guessing--;
				}
				if ( synPredMatched156 )
				{
					{
						{
							if ((LA(1)==ID) && (LA(2)==DOT))
							{
								emi=explicit_member_info();
							}
							else if ((LA(1)==SELF||LA(1)==ID||LA(1)==SPLICE_BEGIN) && (tokenSet_34_.member(LA(2)))) {
							}
							else
							{
								throw new NoViableAltException(LT(1), getFilename());
							}
							
						}
						{
							switch ( LA(1) )
							{
							case ID:
							{
								id1 = LT(1);
								match(ID);
								if (0==inputState.guessing)
								{
									id=id1;
								}
								break;
							}
							case SPLICE_BEGIN:
							{
								begin1 = LT(1);
								match(SPLICE_BEGIN);
								nameSplice=atom();
								if (0==inputState.guessing)
								{
									id=begin1;
								}
								break;
							}
							case SELF:
							{
								s = LT(1);
								match(SELF);
								if (0==inputState.guessing)
								{
									id=s;
								}
								break;
							}
							default:
							{
								throw new NoViableAltException(LT(1), getFilename());
							}
							 }
						}
						{
							if (0==inputState.guessing)
							{
								
												if (emi != null)
													p = new Property(emi.LexicalInfo);
												else
													p = new Property(ToLexicalInfo(id));
												p.Name = id.getText();
												p.ExplicitInfo = emi;
												AddAttributes(p.Attributes);
												parameters = p.Parameters;
												tm = p;
											
							}
							{
								switch ( LA(1) )
								{
								case LPAREN:
								{
									{
										lparen = LT(1);
										match(LPAREN);
										parameter_declaration_list(parameters);
										match(RPAREN);
										if (0==inputState.guessing)
										{
											EmitIndexedPropertyDeprecationWarning(p);
										}
									}
									break;
								}
								case LBRACK:
								{
									{
										match(LBRACK);
										parameter_declaration_list(parameters);
										match(RBRACK);
									}
									break;
								}
								case AS:
								case COLON:
								{
									break;
								}
								default:
								{
									throw new NoViableAltException(LT(1), getFilename());
								}
								 }
							}
							{
								switch ( LA(1) )
								{
								case AS:
								{
									match(AS);
									tr=type_reference();
									break;
								}
								case COLON:
								{
									break;
								}
								default:
								{
									throw new NoViableAltException(LT(1), getFilename());
								}
								 }
							}
							if (0==inputState.guessing)
							{
															
												p.Type = tr;
												p.Modifiers = _modifiers;
											
							}
							begin_with_doc(p);
							{ // ( ... )+
								int _cnt166=0;
								for (;;)
								{
									if ((tokenSet_56_.member(LA(1))))
									{
										property_accessor(p);
									}
									else
									{
										if (_cnt166 >= 1) { goto _loop166_breakloop; } else { throw new NoViableAltException(LT(1), getFilename());; }
									}
									
									_cnt166++;
								}
_loop166_breakloop:								;
							}    // ( ... )+
							end(p);
						}
					}
				}
				else {
					bool synPredMatched169 = false;
					if (((LA(1)==THEN||LA(1)==ID) && (tokenSet_4_.member(LA(2)))))
					{
						int _m169 = mark();
						synPredMatched169 = true;
						inputState.guessing++;
						try {
							{
								macro_name();
								expression_list(null);
								{
									switch ( LA(1) )
									{
									case EOL:
									case EOS:
									{
										eos();
										break;
									}
									case COLON:
									{
										begin_with_doc(null);
										break;
									}
									default:
									{
										throw new NoViableAltException(LT(1), getFilename());
									}
									 }
								}
							}
						}
						catch (RecognitionException)
						{
							synPredMatched169 = false;
						}
						rewind(_m169);
						inputState.guessing--;
					}
					if ( synPredMatched169 )
					{
						tm=member_macro();
					}
					else if ((LA(1)==ID||LA(1)==SPLICE_BEGIN) && (tokenSet_57_.member(LA(2)))) {
						{
							{
								switch ( LA(1) )
								{
								case ID:
								{
									id2 = LT(1);
									match(ID);
									break;
								}
								case SPLICE_BEGIN:
								{
									begin2 = LT(1);
									match(SPLICE_BEGIN);
									nameSplice=atom();
									break;
								}
								default:
								{
									throw new NoViableAltException(LT(1), getFilename());
								}
								 }
							}
							if (0==inputState.guessing)
							{
								
											IToken token = id2 ?? begin2;
											field = new Field(ToLexicalInfo(token));
											field.Name = token.getText();
											field.Modifiers = _modifiers;
											AddAttributes(field.Attributes);
											tm = field;
										
							}
							{
								{
									switch ( LA(1) )
									{
									case AS:
									{
										match(AS);
										tr=type_reference();
										if (0==inputState.guessing)
										{
											field.Type = tr;
										}
										break;
									}
									case EOL:
									case EOS:
									case ASSIGN:
									{
										break;
									}
									default:
									{
										throw new NoViableAltException(LT(1), getFilename());
									}
									 }
								}
								{
									switch ( LA(1) )
									{
									case ASSIGN:
									{
										{
											match(ASSIGN);
											initializer=declaration_initializer();
											if (0==inputState.guessing)
											{
												field.Initializer = initializer;	
											}
										}
										break;
									}
									case EOL:
									case EOS:
									{
										eos();
										break;
									}
									default:
									{
										throw new NoViableAltException(LT(1), getFilename());
									}
									 }
								}
								docstring(field);
							}
						}
					}
					else
					{
						throw new NoViableAltException(LT(1), getFilename());
					}
					}
				}
				if (0==inputState.guessing)
				{
					
						if (null != nameSplice) {
							tm = new SpliceTypeMember(tm, nameSplice);
						}
						container.Add(tm);
					
				}
			}
			catch (RecognitionException ex)
			{
				if (0 == inputState.guessing)
				{
					reportError(ex, "field_or_property");
					recover(ex,tokenSet_55_);
				}
				else
				{
					throw ex;
				}
			}
		}
Exemple #11
0
	protected void interface_definition(
		TypeMemberCollection container
	) //throws RecognitionException, TokenStreamException
{
		
		IToken  id = null;
		IToken  begin = null;
		
				InterfaceDefinition itf = null;
				TypeMemberCollection members = null;
				GenericParameterDeclarationCollection genericParameters = null;
				Expression nameSplice = null;
			
		
		try {      // for error handling
			match(INTERFACE);
			{
				switch ( LA(1) )
				{
				case ID:
				{
					id = LT(1);
					match(ID);
					break;
				}
				case SPLICE_BEGIN:
				{
					{
						begin = LT(1);
						match(SPLICE_BEGIN);
						nameSplice=atom();
					}
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			if (0==inputState.guessing)
			{
				
						IToken token = id ?? begin;
						itf = new InterfaceDefinition(ToLexicalInfo(token));
						itf.Name = token.getText();
						itf.Modifiers = _modifiers;
						AddAttributes(itf.Attributes);
						if (id != null) {
							container.Add(itf);
						} else {
							container.Add(new SpliceTypeMember(itf, nameSplice));
						}
						members = itf.Members;
						genericParameters = itf.GenericParameters;
					
			}
			{
				switch ( LA(1) )
				{
				case LBRACK:
				{
					match(LBRACK);
					{
						switch ( LA(1) )
						{
						case OF:
						{
							match(OF);
							break;
						}
						case ID:
						{
							break;
						}
						default:
						{
							throw new NoViableAltException(LT(1), getFilename());
						}
						 }
					}
					generic_parameter_declaration_list(genericParameters);
					match(RBRACK);
					break;
				}
				case LPAREN:
				case COLON:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			{
				switch ( LA(1) )
				{
				case LPAREN:
				{
					base_types(itf.BaseTypes);
					break;
				}
				case COLON:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			begin_with_doc(itf);
			{
				switch ( LA(1) )
				{
				case PASS:
				{
					{
						match(PASS);
						eos();
					}
					break;
				}
				case DEF:
				case EVENT:
				case SELF:
				case ID:
				case LBRACK:
				{
					{ // ( ... )+
						int _cnt90=0;
						for (;;)
						{
							if ((tokenSet_40_.member(LA(1))))
							{
								attributes();
								{
									switch ( LA(1) )
									{
									case DEF:
									{
										interface_method(members);
										break;
									}
									case EVENT:
									{
										event_declaration(members);
										break;
									}
									case SELF:
									case ID:
									{
										interface_property(members);
										break;
									}
									default:
									{
										throw new NoViableAltException(LT(1), getFilename());
									}
									 }
								}
							}
							else
							{
								if (_cnt90 >= 1) { goto _loop90_breakloop; } else { throw new NoViableAltException(LT(1), getFilename());; }
							}
							
							_cnt90++;
						}
_loop90_breakloop:						;
					}    // ( ... )+
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			end(itf);
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "interface_definition");
				recover(ex,tokenSet_22_);
			}
			else
			{
				throw ex;
			}
		}
	}
Exemple #12
0
	protected void callable_definition(
		TypeMemberCollection container
	) //throws RecognitionException, TokenStreamException
{
		
		IToken  id = null;
		
				CallableDefinition cd = null;
				TypeReference returnType = null;
				GenericParameterDeclarationCollection genericParameters = null;
			
		
		try {      // for error handling
			match(CALLABLE);
			id = LT(1);
			match(ID);
			if (0==inputState.guessing)
			{
				
						cd = new CallableDefinition(ToLexicalInfo(id));
						cd.Name = id.getText();
						cd.Modifiers = _modifiers;
						AddAttributes(cd.Attributes);
						container.Add(cd);
						genericParameters = cd.GenericParameters;
					
			}
			{
				switch ( LA(1) )
				{
				case LBRACK:
				{
					match(LBRACK);
					{
						switch ( LA(1) )
						{
						case OF:
						{
							match(OF);
							break;
						}
						case ID:
						{
							break;
						}
						default:
						{
							throw new NoViableAltException(LT(1), getFilename());
						}
						 }
					}
					generic_parameter_declaration_list(genericParameters);
					match(RBRACK);
					break;
				}
				case LPAREN:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			match(LPAREN);
			parameter_declaration_list(cd.Parameters);
			match(RPAREN);
			{
				switch ( LA(1) )
				{
				case AS:
				{
					match(AS);
					returnType=type_reference();
					if (0==inputState.guessing)
					{
						cd.ReturnType=returnType;
					}
					break;
				}
				case EOL:
				case EOS:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			eos();
			docstring(cd);
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "callable_definition");
				recover(ex,tokenSet_22_);
			}
			else
			{
				throw ex;
			}
		}
	}
Exemple #13
0
        //throws RecognitionException, TokenStreamException
        protected void enum_member(
            TypeMemberCollection container
            )
        {
            IToken  id = null;

                EnumMember em = null;
                IntegerLiteralExpression initializer = null;
                bool negative = false;

            try {      // for error handling
            attributes();
            id = LT(1);
            match(ID);
            {
                switch ( LA(1) )
                {
                case ASSIGN:
                {
                    match(ASSIGN);
                    {
                        if ((LA(1)==SUBTRACT) && (LA(2)==SUBTRACT||LA(2)==LONG||LA(2)==INT))
                        {
                            match(SUBTRACT);
                            if (0==inputState.guessing)
                            {
                                negative = true;
                            }
                        }
                        else if ((LA(1)==SUBTRACT||LA(1)==LONG||LA(1)==INT) && (tokenSet_42_.member(LA(2)))) {
                        }
                        else
                        {
                            throw new NoViableAltException(LT(1), getFilename());
                        }

                    }
                    initializer=integer_literal();
                    break;
                }
                case EOF:
                case EOS:
                case NEWLINE:
                {
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            if (0==inputState.guessing)
            {

                        em = new EnumMember(SourceLocationFactory.ToLexicalInfo(id));
                        em.Name = id.getText();
                        em.Initializer = initializer;
                        if (negative && null != initializer)
                        {
                            initializer.Value *= -1;
                        }
                        AddAttributes(em.Attributes);
                        container.Add(em);

            }
            eos();
            docstring(em);
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_43_);
            }
            else
            {
                throw ex;
            }
            }
        }
Exemple #14
0
        //throws RecognitionException, TokenStreamException
        protected void field_or_property(
            TypeMemberCollection container
            )
        {
            IToken  id1 = null;
            IToken  s = null;
            IToken  id2 = null;

                IToken id = null;
                TypeMember tm = null;
                TypeReference tr = null;
                Property p = null;
                Field field = null;
                ExplicitMemberInfo emi = null;
                Expression initializer = null;
                ParameterDeclarationCollection parameters = null;

            try {      // for error handling
            bool synPredMatched132 = false;
            if (((LA(1)==SELF||LA(1)==ID) && (tokenSet_50_.member(LA(2)))))
            {
                int _m132 = mark();
                synPredMatched132 = true;
                inputState.guessing++;
                try {
                    {
                        property_header();
                    }
                }
                catch (RecognitionException)
                {
                    synPredMatched132 = false;
                }
                rewind(_m132);
                inputState.guessing--;
            }
            if ( synPredMatched132 )
            {
                {
                    {
                        if ((LA(1)==ID) && (LA(2)==DOT))
                        {
                            emi=explicit_member_info();
                        }
                        else if ((LA(1)==SELF||LA(1)==ID) && (tokenSet_51_.member(LA(2)))) {
                        }
                        else
                        {
                            throw new NoViableAltException(LT(1), getFilename());
                        }

                    }
                    {
                        switch ( LA(1) )
                        {
                        case ID:
                        {
                            id1 = LT(1);
                            match(ID);
                            if (0==inputState.guessing)
                            {
                                id=id1;
                            }
                            break;
                        }
                        case SELF:
                        {
                            s = LT(1);
                            match(SELF);
                            if (0==inputState.guessing)
                            {
                                id=s;
                            }
                            break;
                        }
                        default:
                        {
                            throw new NoViableAltException(LT(1), getFilename());
                        }
                         }
                    }
                    {
                        if (0==inputState.guessing)
                        {

                                            if (emi != null)
                                                p = new Property(emi.LexicalInfo);
                                            else
                                                p = new Property(SourceLocationFactory.ToLexicalInfo(id));
                                            p.Name = id.getText();
                                            p.ExplicitInfo = emi;
                                            AddAttributes(p.Attributes);
                                            parameters = p.Parameters;

                        }
                        {
                            switch ( LA(1) )
                            {
                            case LPAREN:
                            case LBRACK:
                            {
                                {
                                    switch ( LA(1) )
                                    {
                                    case LBRACK:
                                    {
                                        match(LBRACK);
                                        break;
                                    }
                                    case LPAREN:
                                    {
                                        match(LPAREN);
                                        break;
                                    }
                                    default:
                                    {
                                        throw new NoViableAltException(LT(1), getFilename());
                                    }
                                     }
                                }
                                parameter_declaration_list(parameters);
                                {
                                    switch ( LA(1) )
                                    {
                                    case RBRACK:
                                    {
                                        match(RBRACK);
                                        break;
                                    }
                                    case RPAREN:
                                    {
                                        match(RPAREN);
                                        break;
                                    }
                                    default:
                                    {
                                        throw new NoViableAltException(LT(1), getFilename());
                                    }
                                     }
                                }
                                break;
                            }
                            case AS:
                            case COLON:
                            {
                                break;
                            }
                            default:
                            {
                                throw new NoViableAltException(LT(1), getFilename());
                            }
                             }
                        }
                        {
                            switch ( LA(1) )
                            {
                            case AS:
                            {
                                match(AS);
                                tr=type_reference();
                                break;
                            }
                            case COLON:
                            {
                                break;
                            }
                            default:
                            {
                                throw new NoViableAltException(LT(1), getFilename());
                            }
                             }
                        }
                        if (0==inputState.guessing)
                        {

                                            p.Type = tr;
                                            tm = p;
                                            tm.Modifiers = _modifiers;

                        }
                        begin_with_doc(p);
                        { // ( ... )+
                            int _cnt142=0;
                            for (;;)
                            {
                                if ((tokenSet_52_.member(LA(1))))
                                {
                                    property_accessor(p);
                                }
                                else
                                {
                                    if (_cnt142 >= 1) { goto _loop142_breakloop; } else { throw new NoViableAltException(LT(1), getFilename());; }
                                }

                                _cnt142++;
                            }
            _loop142_breakloop:							;
                        }    // ( ... )+
                        end(p);
                    }
                }
                if (0==inputState.guessing)
                {
                    container.Add(tm);
                }
            }
            else if ((LA(1)==ID) && (tokenSet_53_.member(LA(2)))) {
                {
                    id2 = LT(1);
                    match(ID);
                    if (0==inputState.guessing)
                    {

                                    tm = field = new Field(SourceLocationFactory.ToLexicalInfo(id2));
                                    field.Name = id2.getText();
                                    field.Modifiers = _modifiers;
                                    AddAttributes(field.Attributes);

                    }
                    {
                        {
                            switch ( LA(1) )
                            {
                            case AS:
                            {
                                match(AS);
                                tr=type_reference();
                                if (0==inputState.guessing)
                                {
                                    field.Type = tr;
                                }
                                break;
                            }
                            case EOF:
                            case EOS:
                            case NEWLINE:
                            case ASSIGN:
                            {
                                break;
                            }
                            default:
                            {
                                throw new NoViableAltException(LT(1), getFilename());
                            }
                             }
                        }
                        {
                            switch ( LA(1) )
                            {
                            case ASSIGN:
                            {
                                {
                                    match(ASSIGN);
                                    initializer=declaration_initializer();
                                    if (0==inputState.guessing)
                                    {
                                        field.Initializer = initializer;
                                    }
                                }
                                break;
                            }
                            case EOF:
                            case EOS:
                            case NEWLINE:
                            {
                                eos();
                                break;
                            }
                            default:
                            {
                                throw new NoViableAltException(LT(1), getFilename());
                            }
                             }
                        }
                        docstring(field);
                    }
                }
                if (0==inputState.guessing)
                {
                    container.Add(tm);
                }
            }
            else
            {
                throw new NoViableAltException(LT(1), getFilename());
            }

            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_49_);
            }
            else
            {
                throw ex;
            }
            }
        }
Exemple #15
0
        //throws RecognitionException, TokenStreamException
        protected void type_member_stmt(
            StatementCollection container
            )
        {
            TypeMemberCollection members = new TypeMemberCollection();

            try {      // for error handling
            type_member(members);
            if (0==inputState.guessing)
            {

                        container.Add(new TypeMemberStatement(members[0]));

            }
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_86_);
            }
            else
            {
                throw ex;
            }
            }
        }
Exemple #16
0
        //throws RecognitionException, TokenStreamException
        protected void class_definition(
            TypeMemberCollection container
            )
        {
            IToken  id = null;

                TypeDefinition td = null;
                TypeReferenceCollection baseTypes = null;
                TypeMemberCollection members = null;
                GenericParameterDeclarationCollection genericParameters = null;

            try {      // for error handling
            {
                switch ( LA(1) )
                {
                case CLASS:
                {
                    match(CLASS);
                    if (0==inputState.guessing)
                    {
                        td = new ClassDefinition();
                    }
                    break;
                }
                case STRUCT:
                {
                    match(STRUCT);
                    if (0==inputState.guessing)
                    {
                        td = new StructDefinition();
                    }
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            id = LT(1);
            match(ID);
            if (0==inputState.guessing)
            {

                        td.LexicalInfo = SourceLocationFactory.ToLexicalInfo(id);
                        td.Name = id.getText();
                        td.Modifiers = _modifiers;
                        AddAttributes(td.Attributes);
                        container.Add(td);
                        baseTypes = td.BaseTypes;
                        members = td.Members;
                        genericParameters = td.GenericParameters;

            }
            {
                switch ( LA(1) )
                {
                case LBRACK:
                {
                    match(LBRACK);
                    {
                        switch ( LA(1) )
                        {
                        case OF:
                        {
                            match(OF);
                            break;
                        }
                        case ID:
                        {
                            break;
                        }
                        default:
                        {
                            throw new NoViableAltException(LT(1), getFilename());
                        }
                         }
                    }
                    generic_parameter_declaration_list(genericParameters);
                    match(RBRACK);
                    break;
                }
                case LPAREN:
                case COLON:
                {
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            {
                switch ( LA(1) )
                {
                case LPAREN:
                {
                    base_types(baseTypes);
                    break;
                }
                case COLON:
                {
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            begin_with_doc(td);
            {    // ( ... )*
                for (;;)
                {
                    switch ( LA(1) )
                    {
                    case SPLICE_BEGIN:
                    {
                        splice_type_definition_body(members);
                        break;
                    }
                    case ABSTRACT:
                    case CALLABLE:
                    case CLASS:
                    case DEF:
                    case ENUM:
                    case EVENT:
                    case FINAL:
                    case INTERFACE:
                    case INTERNAL:
                    case NEW:
                    case OVERRIDE:
                    case PUBLIC:
                    case PROTECTED:
                    case PRIVATE:
                    case SELF:
                    case STATIC:
                    case STRUCT:
                    case TRANSIENT:
                    case VIRTUAL:
                    case PARTIAL:
                    case ID:
                    case LBRACK:
                    {
                        type_definition_member(members);
                        break;
                    }
                    default:
                    {
                        goto _loop67_breakloop;
                    }
                     }
                }
            _loop67_breakloop:				;
            }    // ( ... )*
            end(td);
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_32_);
            }
            else
            {
                throw ex;
            }
            }
        }
Exemple #17
0
        //throws RecognitionException, TokenStreamException
        protected void enum_definition(
            TypeMemberCollection container
            )
        {
            IToken  id = null;

                EnumDefinition ed = null;

            try {      // for error handling
            match(ENUM);
            id = LT(1);
            match(ID);
            if (0==inputState.guessing)
            {
                ed = new EnumDefinition(ToLexicalInfo(id));
            }
            begin_with_doc(ed);
            if (0==inputState.guessing)
            {

                        ed.Name = id.getText();
                        ed.Modifiers = _modifiers;
                        AddAttributes(ed.Attributes);
                        container.Add(ed);

            }
            {
                { // ( ... )+
                    int _cnt40=0;
                    for (;;)
                    {
                        if ((LA(1)==ID||LA(1)==LBRACK))
                        {
                            enum_member(ed);
                        }
                        else
                        {
                            if (_cnt40 >= 1) { goto _loop40_breakloop; } else { throw new NoViableAltException(LT(1), getFilename());; }
                        }

                        _cnt40++;
                    }
            _loop40_breakloop:					;
                }    // ( ... )+
            }
            end(ed);
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_20_);
            }
            else
            {
                throw ex;
            }
            }
        }
Exemple #18
0
		private static void LiftBlockInto(TypeMemberCollection collection, Block block)
		{
			foreach (var stmt in block.Statements)
			{
				var childBlock = stmt as Block;
				if (childBlock != null)
					LiftBlockInto(collection, childBlock);
				else
					collection.Add(TypeMember.Lift(stmt));
			}
		}
Exemple #19
0
		public static TypeMemberCollection Lift(Block block)
		{
			var members = new TypeMemberCollection();
			LiftBlockInto(members, block);
			return members;
		}
Exemple #20
0
	protected void method(
		TypeMemberCollection container
	) //throws RecognitionException, TokenStreamException
{
		
		IToken  t = null;
		IToken  spliceBegin = null;
		IToken  c = null;
		IToken  d = null;
		IToken  cc = null;
		IToken  dd = null;
		
				Method m = null;
				TypeReference rt = null;
				TypeReference it = null;
				ExplicitMemberInfo emi = null;
				ParameterDeclarationCollection parameters = null;
				GenericParameterDeclarationCollection genericParameters = null;
				Block body = null;
				StatementCollection statements = null;
				Expression nameSplice = null;
				TypeMember typeMember = null;
				IToken id = null;
			
		
		try {      // for error handling
			{
				switch ( LA(1) )
				{
				case DEF:
				{
					t = LT(1);
					match(DEF);
					{
						switch ( LA(1) )
						{
						case EVENT:
						case GET:
						case INTERNAL:
						case PUBLIC:
						case PROTECTED:
						case REF:
						case SET:
						case YIELD:
						case ID:
						case SPLICE_BEGIN:
						{
							{
								{
									{
										if ((LA(1)==ID) && (LA(2)==DOT))
										{
											emi=explicit_member_info();
										}
										else if ((tokenSet_33_.member(LA(1))) && (tokenSet_34_.member(LA(2)))) {
										}
										else
										{
											throw new NoViableAltException(LT(1), getFilename());
										}
										
									}
									{
										switch ( LA(1) )
										{
										case EVENT:
										case GET:
										case INTERNAL:
										case PUBLIC:
										case PROTECTED:
										case REF:
										case SET:
										case YIELD:
										case ID:
										{
											id=member();
											break;
										}
										case SPLICE_BEGIN:
										{
											spliceBegin = LT(1);
											match(SPLICE_BEGIN);
											nameSplice=atom();
											break;
										}
										default:
										{
											throw new NoViableAltException(LT(1), getFilename());
										}
										 }
									}
								}
								if (0==inputState.guessing)
								{
									
														IToken token = id ?? spliceBegin;
														if (emi != null) {
															m = new Method(emi.LexicalInfo);
														} else {
															m = new Method(ToLexicalInfo(token));
														}
														m.Name = token.getText();
														m.ExplicitInfo  = emi;
														
														if (nameSplice != null) {
															typeMember = new SpliceTypeMember(m, nameSplice);
														} else {
															typeMember = m;
														}
													
								}
							}
							break;
						}
						case CONSTRUCTOR:
						{
							c = LT(1);
							match(CONSTRUCTOR);
							if (0==inputState.guessing)
							{
								typeMember = m = new Constructor(ToLexicalInfo(c));
							}
							break;
						}
						case DESTRUCTOR:
						{
							d = LT(1);
							match(DESTRUCTOR);
							if (0==inputState.guessing)
							{
								typeMember = m = new Destructor(ToLexicalInfo(d));
							}
							break;
						}
						default:
						{
							throw new NoViableAltException(LT(1), getFilename());
						}
						 }
					}
					break;
				}
				case CONSTRUCTOR:
				{
					cc = LT(1);
					match(CONSTRUCTOR);
					if (0==inputState.guessing)
					{
						typeMember = m = new Constructor(ToLexicalInfo(cc));
					}
					break;
				}
				case DESTRUCTOR:
				{
					dd = LT(1);
					match(DESTRUCTOR);
					if (0==inputState.guessing)
					{
						typeMember = m = new Destructor(ToLexicalInfo(dd));
					}
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			if (0==inputState.guessing)
			{
				
						m.Modifiers = _modifiers;
						AddAttributes(m.Attributes);
						parameters = m.Parameters;
						genericParameters = m.GenericParameters;
						body = m.Body;
						statements = body.Statements;
					
			}
			{
				if ((LA(1)==LBRACK) && (LA(2)==OF||LA(2)==ID))
				{
					match(LBRACK);
					{
						switch ( LA(1) )
						{
						case OF:
						{
							match(OF);
							break;
						}
						case ID:
						{
							break;
						}
						default:
						{
							throw new NoViableAltException(LT(1), getFilename());
						}
						 }
					}
					generic_parameter_declaration_list(genericParameters);
					match(RBRACK);
				}
				else if ((tokenSet_35_.member(LA(1))) && (tokenSet_36_.member(LA(2)))) {
				}
				else
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				
			}
			{
				switch ( LA(1) )
				{
				case LPAREN:
				{
					match(LPAREN);
					parameter_declaration_list(parameters);
					match(RPAREN);
					break;
				}
				case AS:
				case LBRACK:
				case COLON:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			attributes();
			if (0==inputState.guessing)
			{
				AddAttributes(m.ReturnTypeAttributes);
			}
			{
				switch ( LA(1) )
				{
				case AS:
				{
					match(AS);
					rt=type_reference();
					if (0==inputState.guessing)
					{
						m.ReturnType = rt;
					}
					break;
				}
				case COLON:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			begin_block_with_doc(m, body);
			block(statements);
			end(body);
			if (0==inputState.guessing)
			{
				
						container.Add(typeMember);
						m.EndSourceLocation = body.EndSourceLocation;
					
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "method");
				recover(ex,tokenSet_22_);
			}
			else
			{
				throw ex;
			}
		}
	}
Exemple #21
0
        //throws RecognitionException, TokenStreamException
        protected void interface_definition(
            TypeMemberCollection container
            )
        {
            IToken  id = null;

                InterfaceDefinition itf = null;
                TypeMemberCollection members = null;
                GenericParameterDeclarationCollection genericParameters = null;

            try {      // for error handling
            match(INTERFACE);
            id = LT(1);
            match(ID);
            if (0==inputState.guessing)
            {

                        itf = new InterfaceDefinition(SourceLocationFactory.ToLexicalInfo(id));
                        itf.Name = id.getText();
                        itf.Modifiers = _modifiers;
                        AddAttributes(itf.Attributes);
                        container.Add(itf);
                        members = itf.Members;
                        genericParameters = itf.GenericParameters;

            }
            {
                switch ( LA(1) )
                {
                case LBRACK:
                {
                    match(LBRACK);
                    {
                        switch ( LA(1) )
                        {
                        case OF:
                        {
                            match(OF);
                            break;
                        }
                        case ID:
                        {
                            break;
                        }
                        default:
                        {
                            throw new NoViableAltException(LT(1), getFilename());
                        }
                         }
                    }
                    generic_parameter_declaration_list(genericParameters);
                    match(RBRACK);
                    break;
                }
                case LPAREN:
                case COLON:
                {
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            {
                switch ( LA(1) )
                {
                case LPAREN:
                {
                    base_types(itf.BaseTypes);
                    break;
                }
                case COLON:
                {
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            begin_with_doc(itf);
            {    // ( ... )*
                for (;;)
                {
                    if ((tokenSet_33_.member(LA(1))))
                    {
                        attributes();
                        {
                            switch ( LA(1) )
                            {
                            case DEF:
                            {
                                interface_method(members);
                                break;
                            }
                            case EVENT:
                            {
                                event_declaration(members);
                                break;
                            }
                            case SELF:
                            case ID:
                            {
                                interface_property(members);
                                break;
                            }
                            default:
                            {
                                throw new NoViableAltException(LT(1), getFilename());
                            }
                             }
                        }
                    }
                    else
                    {
                        goto _loop77_breakloop;
                    }

                }
            _loop77_breakloop:				;
            }    // ( ... )*
            end(itf);
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_32_);
            }
            else
            {
                throw ex;
            }
            }
        }
Exemple #22
0
	protected void class_definition(
		TypeMemberCollection container
	) //throws RecognitionException, TokenStreamException
{
		
		IToken  id = null;
		IToken  begin = null;
		
				TypeDefinition td = null;
				TypeReferenceCollection baseTypes = null;
				TypeMemberCollection members = null;
				GenericParameterDeclarationCollection genericParameters = null;
				Expression nameSplice = null;
			
		
		try {      // for error handling
			{
				switch ( LA(1) )
				{
				case CLASS:
				{
					match(CLASS);
					if (0==inputState.guessing)
					{
						td = new ClassDefinition();
					}
					break;
				}
				case STRUCT:
				{
					match(STRUCT);
					if (0==inputState.guessing)
					{
						td = new StructDefinition();
					}
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			{
				switch ( LA(1) )
				{
				case ID:
				{
					id = LT(1);
					match(ID);
					break;
				}
				case SPLICE_BEGIN:
				{
					begin = LT(1);
					match(SPLICE_BEGIN);
					nameSplice=atom();
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			if (0==inputState.guessing)
			{
						
						IToken token = id ?? begin;
						td.LexicalInfo = ToLexicalInfo(token);
						td.Name = token.getText();
						td.Modifiers = _modifiers;
						AddAttributes(td.Attributes);
						baseTypes = td.BaseTypes;
						members = td.Members;
						genericParameters = td.GenericParameters;
						
						if (id != null) {
							container.Add(td);
						} else {
							container.Add(new SpliceTypeMember(td, nameSplice));
						}
					
			}
			{
				switch ( LA(1) )
				{
				case LBRACK:
				{
					match(LBRACK);
					{
						switch ( LA(1) )
						{
						case OF:
						{
							match(OF);
							break;
						}
						case ID:
						{
							break;
						}
						default:
						{
							throw new NoViableAltException(LT(1), getFilename());
						}
						 }
					}
					generic_parameter_declaration_list(genericParameters);
					match(RBRACK);
					break;
				}
				case LPAREN:
				case COLON:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			{
				switch ( LA(1) )
				{
				case LPAREN:
				{
					base_types(baseTypes);
					break;
				}
				case COLON:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			begin_with_doc(td);
			{
				switch ( LA(1) )
				{
				case PASS:
				{
					{
						match(PASS);
						eos();
					}
					break;
				}
				case EOL:
				case ABSTRACT:
				case CALLABLE:
				case CLASS:
				case CONSTRUCTOR:
				case DEF:
				case DESTRUCTOR:
				case ENUM:
				case EVENT:
				case FINAL:
				case INTERFACE:
				case INTERNAL:
				case NEW:
				case OVERRIDE:
				case PARTIAL:
				case PUBLIC:
				case PROTECTED:
				case PRIVATE:
				case SELF:
				case STATIC:
				case STRUCT:
				case THEN:
				case TRANSIENT:
				case VIRTUAL:
				case EOS:
				case ID:
				case LBRACK:
				case SPLICE_BEGIN:
				{
					{
						{
							switch ( LA(1) )
							{
							case EOL:
							case EOS:
							{
								eos();
								break;
							}
							case ABSTRACT:
							case CALLABLE:
							case CLASS:
							case CONSTRUCTOR:
							case DEF:
							case DESTRUCTOR:
							case ENUM:
							case EVENT:
							case FINAL:
							case INTERFACE:
							case INTERNAL:
							case NEW:
							case OVERRIDE:
							case PARTIAL:
							case PUBLIC:
							case PROTECTED:
							case PRIVATE:
							case SELF:
							case STATIC:
							case STRUCT:
							case THEN:
							case TRANSIENT:
							case VIRTUAL:
							case ID:
							case LBRACK:
							case SPLICE_BEGIN:
							{
								break;
							}
							default:
							{
								throw new NoViableAltException(LT(1), getFilename());
							}
							 }
						}
						{ // ( ... )+
							int _cnt76=0;
							for (;;)
							{
								bool synPredMatched75 = false;
								if (((LA(1)==SPLICE_BEGIN) && (tokenSet_37_.member(LA(2)))))
								{
									int _m75 = mark();
									synPredMatched75 = true;
									inputState.guessing++;
									try {
										{
											splice_expression();
											eos();
										}
									}
									catch (RecognitionException)
									{
										synPredMatched75 = false;
									}
									rewind(_m75);
									inputState.guessing--;
								}
								if ( synPredMatched75 )
								{
									splice_type_definition_body(members);
								}
								else if ((tokenSet_38_.member(LA(1))) && (tokenSet_39_.member(LA(2)))) {
									type_definition_member(members);
								}
								else
								{
									if (_cnt76 >= 1) { goto _loop76_breakloop; } else { throw new NoViableAltException(LT(1), getFilename());; }
								}
								
								_cnt76++;
							}
_loop76_breakloop:							;
						}    // ( ... )+
					}
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			end(td);
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "class_definition");
				recover(ex,tokenSet_22_);
			}
			else
			{
				throw ex;
			}
		}
	}
Exemple #23
0
        //throws RecognitionException, TokenStreamException
        protected void interface_method(
            TypeMemberCollection container
            )
        {
            Method m = null;
                TypeReference rt = null;
                IToken id = null;

            try {      // for error handling
            match(DEF);
            id=member();
            if (0==inputState.guessing)
            {

                        m = new Method(SourceLocationFactory.ToLexicalInfo(id));
                        m.Name = id.getText();
                        AddAttributes(m.Attributes);
                        container.Add(m);

            }
            {
                switch ( LA(1) )
                {
                case LBRACK:
                {
                    {
                        match(LBRACK);
                        {
                            switch ( LA(1) )
                            {
                            case OF:
                            {
                                match(OF);
                                break;
                            }
                            case ID:
                            {
                                break;
                            }
                            default:
                            {
                                throw new NoViableAltException(LT(1), getFilename());
                            }
                             }
                        }
                        generic_parameter_declaration_list(m.GenericParameters);
                        match(RBRACK);
                    }
                    break;
                }
                case OF:
                {
                    {
                        match(OF);
                        generic_parameter_declaration(m.GenericParameters);
                    }
                    break;
                }
                case LPAREN:
                {
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            match(LPAREN);
            parameter_declaration_list(m.Parameters);
            match(RPAREN);
            {
                switch ( LA(1) )
                {
                case AS:
                {
                    match(AS);
                    rt=type_reference();
                    if (0==inputState.guessing)
                    {
                        m.ReturnType=rt;
                    }
                    break;
                }
                case EOF:
                case EOS:
                case NEWLINE:
                case COLON:
                {
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            {
                switch ( LA(1) )
                {
                case EOF:
                case EOS:
                case NEWLINE:
                {
                    {
                        eos();
                        docstring(m);
                    }
                    break;
                }
                case COLON:
                {
                    {
                        empty_block(m);
                        {
                            switch ( LA(1) )
                            {
                            case EOF:
                            case EOS:
                            case NEWLINE:
                            {
                                eos();
                                break;
                            }
                            case DEF:
                            case END:
                            case EVENT:
                            case SELF:
                            case ID:
                            case LBRACK:
                            {
                                break;
                            }
                            default:
                            {
                                throw new NoViableAltException(LT(1), getFilename());
                            }
                             }
                        }
                    }
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_54_);
            }
            else
            {
                throw ex;
            }
            }
        }
Exemple #24
0
	protected void enum_definition(
		TypeMemberCollection container
	) //throws RecognitionException, TokenStreamException
{
		
		IToken  id = null;
		
				EnumDefinition ed = null;
				TypeMemberCollection members = null;
			
		
		try {      // for error handling
			match(ENUM);
			id = LT(1);
			match(ID);
			if (0==inputState.guessing)
			{
				ed = new EnumDefinition(ToLexicalInfo(id));
			}
			begin_with_doc(ed);
			if (0==inputState.guessing)
			{
				
							ed.Name = id.getText();
							ed.Modifiers = _modifiers;
							AddAttributes(ed.Attributes);
							container.Add(ed);
							members = ed.Members;
						
			}
			{
				switch ( LA(1) )
				{
				case PASS:
				{
					{
						match(PASS);
						eos();
					}
					break;
				}
				case ID:
				case LBRACK:
				case SPLICE_BEGIN:
				{
					{ // ( ... )+
						int _cnt48=0;
						for (;;)
						{
							switch ( LA(1) )
							{
							case ID:
							case LBRACK:
							{
								enum_member(members);
								break;
							}
							case SPLICE_BEGIN:
							{
								splice_type_definition_body(members);
								break;
							}
							default:
							{
								if (_cnt48 >= 1) { goto _loop48_breakloop; } else { throw new NoViableAltException(LT(1), getFilename());; }
							}
							break; }
							_cnt48++;
						}
_loop48_breakloop:						;
					}    // ( ... )+
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			end(ed);
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "enum_definition");
				recover(ex,tokenSet_22_);
			}
			else
			{
				throw ex;
			}
		}
	}
Exemple #25
0
        //throws RecognitionException, TokenStreamException
        protected void method(
            TypeMemberCollection container
            )
        {
            IToken  t = null;
            IToken  c = null;
            IToken  d = null;

                Method m = null;
                TypeReference rt = null;
                TypeReference it = null;
                ExplicitMemberInfo emi = null;
                ParameterDeclarationCollection parameters = null;
                GenericParameterDeclarationCollection genericParameters = null;
                Block body = null;
                StatementCollection statements = null;
                IToken id = null;

            try {      // for error handling
            t = LT(1);
            match(DEF);
            {
                switch ( LA(1) )
                {
                case EVENT:
                case GET:
                case INTERNAL:
                case PUBLIC:
                case PROTECTED:
                case REF:
                case SET:
                case ID:
                {
                    {
                        if ((LA(1)==ID) && (LA(2)==DOT))
                        {
                            emi=explicit_member_info();
                        }
                        else if ((tokenSet_27_.member(LA(1))) && (LA(2)==LPAREN||LA(2)==LBRACK)) {
                        }
                        else
                        {
                            throw new NoViableAltException(LT(1), getFilename());
                        }

                    }
                    id=member();
                    if (0==inputState.guessing)
                    {

                                    if (emi != null)
                                    {
                                        m = new Method(emi.LexicalInfo);
                                    }
                                    else
                                    {
                                        m = new Method(SourceLocationFactory.ToLexicalInfo(id));
                                    }
                                    m.Name = id.getText();
                                    m.ExplicitInfo  = emi;

                    }
                    break;
                }
                case CONSTRUCTOR:
                {
                    c = LT(1);
                    match(CONSTRUCTOR);
                    if (0==inputState.guessing)
                    {
                        m = new Constructor(SourceLocationFactory.ToLexicalInfo(c));
                    }
                    break;
                }
                case DESTRUCTOR:
                {
                    d = LT(1);
                    match(DESTRUCTOR);
                    if (0==inputState.guessing)
                    {
                        m = new Destructor(SourceLocationFactory.ToLexicalInfo(d));
                    }
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            if (0==inputState.guessing)
            {

                        m.Modifiers = _modifiers;
                        AddAttributes(m.Attributes);
                        parameters = m.Parameters;
                        genericParameters = m.GenericParameters;
                        body = m.Body;
                        statements = body.Statements;

            }
            {
                switch ( LA(1) )
                {
                case LBRACK:
                {
                    match(LBRACK);
                    {
                        switch ( LA(1) )
                        {
                        case OF:
                        {
                            match(OF);
                            break;
                        }
                        case ID:
                        {
                            break;
                        }
                        default:
                        {
                            throw new NoViableAltException(LT(1), getFilename());
                        }
                         }
                    }
                    generic_parameter_declaration_list(genericParameters);
                    match(RBRACK);
                    break;
                }
                case LPAREN:
                {
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            match(LPAREN);
            parameter_declaration_list(parameters);
            match(RPAREN);
            attributes();
            if (0==inputState.guessing)
            {
                AddAttributes(m.ReturnTypeAttributes);
            }
            {
                switch ( LA(1) )
                {
                case AS:
                {
                    match(AS);
                    rt=type_reference();
                    if (0==inputState.guessing)
                    {
                        m.ReturnType = rt;
                    }
                    break;
                }
                case COLON:
                {
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            begin_block_with_doc(m, body);
            block(statements);
            end(body);
            if (0==inputState.guessing)
            {

                        container.Add(m);

            }
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_32_);
            }
            else
            {
                throw ex;
            }
            }
        }
Exemple #26
0
	protected void enum_member(
		TypeMemberCollection container
	) //throws RecognitionException, TokenStreamException
{
		
		IToken  id = null;
			
				EnumMember em = null;
				Expression initializer = null;
			
		
		try {      // for error handling
			attributes();
			id = LT(1);
			match(ID);
			{
				switch ( LA(1) )
				{
				case ASSIGN:
				{
					match(ASSIGN);
					initializer=simple_initializer();
					break;
				}
				case EOL:
				case EOS:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			if (0==inputState.guessing)
			{
				
						em = new EnumMember(ToLexicalInfo(id));
						em.Name = id.getText();
						em.Initializer = initializer;
						AddAttributes(em.Attributes);
						container.Add(em);
					
			}
			eos();
			docstring(em);
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "enum_member");
				recover(ex,tokenSet_48_);
			}
			else
			{
				throw ex;
			}
		}
	}
Exemple #27
0
        //throws RecognitionException, TokenStreamException
        protected void class_definition(
            TypeMemberCollection container
            )
        {
            IToken  id = null;

                TypeDefinition td = null;
                TypeReferenceCollection baseTypes = null;
                TypeMemberCollection members = null;
                GenericParameterDeclarationCollection genericParameters = null;

            try {      // for error handling
            {
                switch ( LA(1) )
                {
                case CLASS:
                {
                    match(CLASS);
                    if (0==inputState.guessing)
                    {
                        td = new ClassDefinition();
                    }
                    break;
                }
                case STRUCT:
                {
                    match(STRUCT);
                    if (0==inputState.guessing)
                    {
                        td = new StructDefinition();
                    }
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            id = LT(1);
            match(ID);
            if (0==inputState.guessing)
            {

                        td.LexicalInfo = SourceLocationFactory.ToLexicalInfo(id);
                        td.Name = id.getText();
                        td.Modifiers = _modifiers;
                        AddAttributes(td.Attributes);
                        container.Add(td);
                        baseTypes = td.BaseTypes;
                        members = td.Members;
                        genericParameters = td.GenericParameters;

            }
            {
                switch ( LA(1) )
                {
                case LBRACK:
                {
                    match(LBRACK);
                    {
                        switch ( LA(1) )
                        {
                        case OF:
                        {
                            match(OF);
                            break;
                        }
                        case ID:
                        {
                            break;
                        }
                        default:
                        {
                            throw new NoViableAltException(LT(1), getFilename());
                        }
                         }
                    }
                    generic_parameter_declaration_list(genericParameters);
                    match(RBRACK);
                    break;
                }
                case LPAREN:
                case COLON:
                {
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            {
                switch ( LA(1) )
                {
                case LPAREN:
                {
                    base_types(baseTypes);
                    break;
                }
                case COLON:
                {
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            begin_with_doc(td);
            {    // ( ... )*
                for (;;)
                {
                    if ((tokenSet_28_.member(LA(1))))
                    {
                        type_definition_member(members);
                    }
                    else
                    {
                        goto _loop61_breakloop;
                    }

                }
            _loop61_breakloop:				;
            }    // ( ... )*
            end(td);
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_27_);
            }
            else
            {
                throw ex;
            }
            }
        }
Exemple #28
0
	protected void event_declaration(
		TypeMemberCollection container
	) //throws RecognitionException, TokenStreamException
{
		
		IToken  t = null;
		IToken  id = null;
		
				Event e = null;
				TypeReference tr = null;
			
		
		try {      // for error handling
			t = LT(1);
			match(EVENT);
			id = LT(1);
			match(ID);
			match(AS);
			tr=type_reference();
			eos();
			if (0==inputState.guessing)
			{
				
						e = new Event(ToLexicalInfo(id), id.getText(), tr);
						e.Modifiers = _modifiers;
						AddAttributes(e.Attributes);
						container.Add(e);
					
			}
			docstring(e);
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "event_declaration");
				recover(ex,tokenSet_55_);
			}
			else
			{
				throw ex;
			}
		}
	}
Exemple #29
0
 void CollectTypes(List<TypeDefinition> types, TypeMemberCollection members)
 {
     foreach (var member in members)
     {
         switch (member.NodeType)
         {
             case NodeType.InterfaceDefinition:
             case NodeType.ClassDefinition:
                 {
                     var typeDefinition = ((TypeDefinition)member);
                     types.Add(typeDefinition);
                     CollectTypes(types, typeDefinition.Members);
                     break;
                 }
             case NodeType.EnumDefinition:
                 {
                     types.Add((TypeDefinition) member);
                     break;
                 }
         }
     }
 }
Exemple #30
0
	protected void interface_method(
		TypeMemberCollection container
	) //throws RecognitionException, TokenStreamException
{
		
		IToken  begin = null;
		
				Method m = null;
				TypeReference rt = null;
				Expression nameSplice = null;
				IToken id = null;
			
		
		try {      // for error handling
			match(DEF);
			{
				switch ( LA(1) )
				{
				case EVENT:
				case GET:
				case INTERNAL:
				case PUBLIC:
				case PROTECTED:
				case REF:
				case SET:
				case YIELD:
				case ID:
				{
					id=member();
					break;
				}
				case SPLICE_BEGIN:
				{
					{
						begin = LT(1);
						match(SPLICE_BEGIN);
						nameSplice=atom();
					}
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			if (0==inputState.guessing)
			{
				
						IToken token = id ?? begin;
						m = new Method(ToLexicalInfo(token));
						m.Name = token.getText();
						AddAttributes(m.Attributes);
						if (nameSplice != null) {
							container.Add(new SpliceTypeMember(m, nameSplice));
						} else {
							container.Add(m);
						}
					
			}
			{
				switch ( LA(1) )
				{
				case LBRACK:
				{
					{
						match(LBRACK);
						{
							switch ( LA(1) )
							{
							case OF:
							{
								match(OF);
								break;
							}
							case ID:
							{
								break;
							}
							default:
							{
								throw new NoViableAltException(LT(1), getFilename());
							}
							 }
						}
						generic_parameter_declaration_list(m.GenericParameters);
						match(RBRACK);
					}
					break;
				}
				case OF:
				{
					{
						match(OF);
						generic_parameter_declaration(m.GenericParameters);
					}
					break;
				}
				case LPAREN:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			match(LPAREN);
			parameter_declaration_list(m.Parameters);
			match(RPAREN);
			{
				switch ( LA(1) )
				{
				case AS:
				{
					match(AS);
					rt=type_reference();
					if (0==inputState.guessing)
					{
						m.ReturnType=rt;
					}
					break;
				}
				case EOL:
				case EOS:
				case COLON:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			{
				switch ( LA(1) )
				{
				case EOL:
				case EOS:
				{
					{
						eos();
						docstring(m);
					}
					break;
				}
				case COLON:
				{
					{
						empty_block(m);
						{
							switch ( LA(1) )
							{
							case EOL:
							case EOS:
							{
								eos();
								break;
							}
							case DEDENT:
							case DEF:
							case EVENT:
							case SELF:
							case ID:
							case LBRACK:
							{
								break;
							}
							default:
							{
								throw new NoViableAltException(LT(1), getFilename());
							}
							 }
						}
					}
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "interface_method");
				recover(ex,tokenSet_58_);
			}
			else
			{
				throw ex;
			}
		}
	}
Exemple #31
0
	public void ast_literal_block(
		QuasiquoteExpression e
	) //throws RecognitionException, TokenStreamException
{
		
		
			// TODO: either cache or construct these objects on demand
			TypeMemberCollection collection = new TypeMemberCollection();
			Block b = new Block();
			StatementCollection statements = b.Statements;
			Node node = null;
		
		
		try {      // for error handling
			bool synPredMatched453 = false;
			if (((tokenSet_110_.member(LA(1))) && (tokenSet_111_.member(LA(2)))))
			{
				int _m453 = mark();
				synPredMatched453 = true;
				inputState.guessing++;
				try {
					{
						ast_literal_module_prediction();
					}
				}
				catch (RecognitionException)
				{
					synPredMatched453 = false;
				}
				rewind(_m453);
				inputState.guessing--;
			}
			if ( synPredMatched453 )
			{
				{
					ast_literal_module(e);
				}
			}
			else {
				bool synPredMatched463 = false;
				if (((tokenSet_38_.member(LA(1))) && (tokenSet_39_.member(LA(2)))))
				{
					int _m463 = mark();
					synPredMatched463 = true;
					inputState.guessing++;
					try {
						{
							attributes();
							{
								if ((tokenSet_31_.member(LA(1))) && (true))
								{
									type_member_modifier();
								}
								else if ((tokenSet_112_.member(LA(1))) && (true)) {
									{
										modifiers();
										{
											switch ( LA(1) )
											{
											case CLASS:
											{
												match(CLASS);
												break;
											}
											case ENUM:
											{
												match(ENUM);
												break;
											}
											case STRUCT:
											{
												match(STRUCT);
												break;
											}
											case INTERFACE:
											{
												match(INTERFACE);
												break;
											}
											case EVENT:
											{
												match(EVENT);
												break;
											}
											case DEF:
											{
												match(DEF);
												break;
											}
											case CALLABLE:
											{
												match(CALLABLE);
												break;
											}
											case ID:
											case SPLICE_BEGIN:
											{
												{
													{
														switch ( LA(1) )
														{
														case ID:
														{
															match(ID);
															break;
														}
														case SPLICE_BEGIN:
														{
															splice_expression();
															break;
														}
														default:
														{
															throw new NoViableAltException(LT(1), getFilename());
														}
														 }
													}
													{
														switch ( LA(1) )
														{
														case AS:
														{
															match(AS);
															type_reference();
															break;
														}
														case COLON:
														{
															break;
														}
														default:
														{
															throw new NoViableAltException(LT(1), getFilename());
														}
														 }
													}
													begin_with_doc(null);
													{
														switch ( LA(1) )
														{
														case GET:
														{
															match(GET);
															break;
														}
														case SET:
														{
															match(SET);
															break;
														}
														default:
														{
															throw new NoViableAltException(LT(1), getFilename());
														}
														 }
													}
												}
												break;
											}
											default:
											{
												throw new NoViableAltException(LT(1), getFilename());
											}
											 }
										}
									}
								}
								else
								{
									throw new NoViableAltException(LT(1), getFilename());
								}
								
							}
						}
					}
					catch (RecognitionException)
					{
						synPredMatched463 = false;
					}
					rewind(_m463);
					inputState.guessing--;
				}
				if ( synPredMatched463 )
				{
					{
						{ // ( ... )+
							int _cnt466=0;
							for (;;)
							{
								if ((tokenSet_38_.member(LA(1))))
								{
									type_definition_member(collection);
								}
								else
								{
									if (_cnt466 >= 1) { goto _loop466_breakloop; } else { throw new NoViableAltException(LT(1), getFilename());; }
								}
								
								_cnt466++;
							}
_loop466_breakloop:							;
						}    // ( ... )+
						if (0==inputState.guessing)
						{
							
										if (collection.Count == 1) {
											e.Node = collection[0];
										} else {
											Module m = CodeFactory.NewQuasiquoteModule(e.LexicalInfo);
											m.Members = collection;
											e.Node = m;
										}
									
						}
					}
				}
				else if ((tokenSet_17_.member(LA(1))) && (tokenSet_91_.member(LA(2)))) {
					{ // ( ... )+
						int _cnt468=0;
						for (;;)
						{
							if ((tokenSet_17_.member(LA(1))))
							{
								stmt(statements);
							}
							else
							{
								if (_cnt468 >= 1) { goto _loop468_breakloop; } else { throw new NoViableAltException(LT(1), getFilename());; }
							}
							
							_cnt468++;
						}
_loop468_breakloop:						;
					}    // ( ... )+
					if (0==inputState.guessing)
					{
						e.Node = b.Statements.Count > 1 ? b : b.Statements[0];
					}
				}
				else
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				}
			}
			catch (RecognitionException ex)
			{
				if (0 == inputState.guessing)
				{
					reportError(ex, "ast_literal_block");
					recover(ex,tokenSet_67_);
				}
				else
				{
					throw ex;
				}
			}
		}
Exemple #32
0
	protected void type_member_stmt(
		StatementCollection container
	) //throws RecognitionException, TokenStreamException
{
		
		
			TypeMemberCollection members = new TypeMemberCollection();
		
		
		try {      // for error handling
			type_definition_member(members);
			if (0==inputState.guessing)
			{
				
						foreach (var member in members)
							container.Add(new TypeMemberStatement(member));
					
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "type_member_stmt");
				recover(ex,tokenSet_55_);
			}
			else
			{
				throw ex;
			}
		}
	}
Exemple #33
0
	protected void type_definition(
		TypeMemberCollection container
	) //throws RecognitionException, TokenStreamException
{
		
		
		try {      // for error handling
			{
				switch ( LA(1) )
				{
				case CLASS:
				case STRUCT:
				{
					class_definition(container);
					break;
				}
				case INTERFACE:
				{
					interface_definition(container);
					break;
				}
				case ENUM:
				{
					enum_definition(container);
					break;
				}
				case CALLABLE:
				{
					callable_definition(container);
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "type_definition");
				recover(ex,tokenSet_22_);
			}
			else
			{
				throw ex;
			}
		}
	}
Exemple #34
0
        //throws RecognitionException, TokenStreamException
        public void type_definition_member(
		TypeMemberCollection container
	)
        {
            try {      // for error handling
            attributes();
            modifiers();
            {
                switch ( LA(1) )
                {
                case DEF:
                {
                    method(container);
                    break;
                }
                case EVENT:
                {
                    event_declaration(container);
                    break;
                }
                case SELF:
                case THEN:
                case ID:
                case SPLICE_BEGIN:
                {
                    field_or_property(container);
                    break;
                }
                case CALLABLE:
                case CLASS:
                case ENUM:
                case INTERFACE:
                case STRUCT:
                {
                    type_definition(container);
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex, "type_definition_member");
                recover(ex,tokenSet_52_);
            }
            else
            {
                throw ex;
            }
            }
        }
Exemple #35
0
 public static TypeMemberCollection Lift(Block block)
 {
     var members = new TypeMemberCollection();
     foreach (var stmt in block.Statements)
         members.Add(TypeMember.Lift(stmt));
     return members;
 }