예제 #1
0
 public override Template Visit(ArrayType type)
 {
     Template template = new Template("<type><list>");
     template.Add("type", type.Type.Accept(this));
     List<Template> list = new List<Template>();
     foreach (var x in type.Args)
     {
         Template tmp = new Template("[<expr>]");
         tmp.Add("expr", x.Accept(this));
         list.Add(tmp);
     }
     template.Add("list", list);
     return template;
 }
예제 #2
0
 public abstract Template Visit(ArrayType type);
예제 #3
0
	private SugarType type_array()
	{
		EnterRule_type_array();
		EnterRule("type_array", 16);
		TraceIn("type_array", 16);
		SugarType value = default(SugarType);


		SugarType a = default(SugarType);
		Expr b = default(Expr);


			List<Expr> list = new List<Expr>();

		try { DebugEnterRule(GrammarFileName, "type_array");
		DebugLocation(221, 1);
		try
		{
			// SugarWalker.g:226:2: ( ^( Type_Array a= type_name (b= expr )+ ) )
			DebugEnterAlt(1);
			// SugarWalker.g:226:4: ^( Type_Array a= type_name (b= expr )+ )
			{
			DebugLocation(226, 4);
			DebugLocation(226, 6);
			Match(input,Type_Array,Follow._Type_Array_in_type_array922); 

			Match(input, TokenTypes.Down, null); 
			DebugLocation(226, 18);
			PushFollow(Follow._type_name_in_type_array926);
			a=type_name();
			PopFollow();

			DebugLocation(226, 29);
			// SugarWalker.g:226:29: (b= expr )+
			int cnt30=0;
			try { DebugEnterSubRule(30);
			while (true)
			{
				int alt30=2;
				try { DebugEnterDecision(30, false);
				int LA30_0 = input.LA(1);

				if (((LA30_0>=Expr_Access && LA30_0<=Expr_Alloc_Equal)||(LA30_0>=Expr_Bin && LA30_0<=Expr_Where)||LA30_0==IDENT||LA30_0==Match_Expr||LA30_0==Match_Tuple||LA30_0==NUMBER||LA30_0==STRING||LA30_0==89||LA30_0==92||LA30_0==96||LA30_0==99||LA30_0==104||LA30_0==110||LA30_0==113||LA30_0==118||LA30_0==121||LA30_0==128||LA30_0==131||LA30_0==135||LA30_0==183||LA30_0==DOUBLE))
				{
					alt30 = 1;
				}


				} finally { DebugExitDecision(30); }
				switch (alt30)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarWalker.g:226:30: b= expr
					{
					DebugLocation(226, 31);
					PushFollow(Follow._expr_in_type_array931);
					b=expr();
					PopFollow();

					DebugLocation(226, 37);
					 list.Add(b); 

					}
					break;

				default:
					if (cnt30 >= 1)
						goto loop30;

					EarlyExitException eee30 = new EarlyExitException( 30, input );
					DebugRecognitionException(eee30);
					throw eee30;
				}
				cnt30++;
			}
			loop30:
				;

			} finally { DebugExitSubRule(30); }


			Match(input, TokenTypes.Up, null); 

			DebugLocation(227, 2);

					value = new ArrayType(a, list);
				

			}

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			TraceOut("type_array", 16);
			LeaveRule("type_array", 16);
			LeaveRule_type_array();
		}
		DebugLocation(230, 1);
		} finally { DebugExitRule(GrammarFileName, "type_array"); }
		return value;

	}