Beispiel #1
0
	private Namespace namespace_def()
	{
		EnterRule_namespace_def();
		EnterRule("namespace_def", 10);
		TraceIn("namespace_def", 10);
		Namespace value = default(Namespace);


		string a = default(string);
		GlobalBlock b = default(GlobalBlock);

		try { DebugEnterRule(GrammarFileName, "namespace_def");
		DebugLocation(134, 1);
		try
		{
			// SugarWalker.g:135:2: ( ^( Namespace a= ident (b= global_block )? ) )
			DebugEnterAlt(1);
			// SugarWalker.g:135:4: ^( Namespace a= ident (b= global_block )? )
			{
			DebugLocation(135, 4);
			DebugLocation(135, 6);
			Match(input,Namespace,Follow._Namespace_in_namespace_def558); 

			Match(input, TokenTypes.Down, null); 
			DebugLocation(135, 17);
			PushFollow(Follow._ident_in_namespace_def562);
			a=ident();
			PopFollow();

			DebugLocation(135, 24);
			// SugarWalker.g:135:24: (b= global_block )?
			int alt16=2;
			try { DebugEnterSubRule(16);
			try { DebugEnterDecision(16, false);
			int LA16_0 = input.LA(1);

			if ((LA16_0==Global_Block))
			{
				alt16 = 1;
			}
			} finally { DebugExitDecision(16); }
			switch (alt16)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarWalker.g:135:25: b= global_block
				{
				DebugLocation(135, 26);
				PushFollow(Follow._global_block_in_namespace_def567);
				b=global_block();
				PopFollow();


				}
				break;

			}
			} finally { DebugExitSubRule(16); }


			Match(input, TokenTypes.Up, null); 

			DebugLocation(136, 2);

					value = new Namespace(a, b);
				

			}

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			TraceOut("namespace_def", 10);
			LeaveRule("namespace_def", 10);
			LeaveRule_namespace_def();
		}
		DebugLocation(139, 1);
		} finally { DebugExitRule(GrammarFileName, "namespace_def"); }
		return value;

	}
Beispiel #2
0
 public override Template Visit(Namespace namespace_def)
 {
     if (namespace_def.Block == null || namespace_def.Block.List.Count() == 0)
     {
         return new Template(string.Format("namespace {0} {{ }}", namespace_def.Name));
     }
     Template template = new Template("namespace <name> {\n    <block>\n}");
     string name = namespace_def.Name;
     if (name.IndexOf("::") != -1)
     {
         int k = name.IndexOf("::");
         string prefix = name.Substring(0, k);
         string suffix = name.Substring(k + 2, name.Length - k - 2);
         template.Add("name", prefix);
         template.Add("block", Visit(new Namespace(suffix, namespace_def.Block)));
     }
     else
     {
         template.Add("name", namespace_def.Name);
         List<Template> list = new List<Template>();
         template.Add("block", namespace_def.Block.Accept(this));
     }
     return template;
 }
Beispiel #3
0
 public abstract Template Visit(Namespace namespace_def);