Пример #1
0
 public override Template Visit(Import import)
 {
     Template template = new Template("<list; separator=\"\n\">");
     List<Template> list = new List<Template>();
     foreach (var name in import.NameList)
     {
         Template node = new Template("#include <name>");
         node.Add("name", name);
         list.Add(node);
     }
     template.Add("list", list);
     return template;
 }
Пример #2
0
	private Import import_def()
	{
		EnterRule_import_def();
		EnterRule("import_def", 11);
		TraceIn("import_def", 11);
		Import value = default(Import);


		CommonTree a = default(CommonTree);
		List<Attr> attr = default(List<Attr>);


			value = new Import();

		try { DebugEnterRule(GrammarFileName, "import_def");
		DebugLocation(141, 1);
		try
		{
			// SugarWalker.g:146:2: ( ^( Import (attr= attribute )? (a= STRING )* ) )
			DebugEnterAlt(1);
			// SugarWalker.g:146:4: ^( Import (attr= attribute )? (a= STRING )* )
			{
			DebugLocation(146, 4);
			DebugLocation(146, 6);
			Match(input,Import,Follow._Import_in_import_def594); 

			if (input.LA(1) == TokenTypes.Down)
			{
				Match(input, TokenTypes.Down, null); 
				DebugLocation(146, 13);
				// SugarWalker.g:146:13: (attr= attribute )?
				int alt17=2;
				try { DebugEnterSubRule(17);
				try { DebugEnterDecision(17, false);
				int LA17_0 = input.LA(1);

				if ((LA17_0==Attribute))
				{
					alt17 = 1;
				}
				} finally { DebugExitDecision(17); }
				switch (alt17)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarWalker.g:146:14: attr= attribute
					{
					DebugLocation(146, 18);
					PushFollow(Follow._attribute_in_import_def599);
					attr=attribute();
					PopFollow();

					DebugLocation(146, 29);
					 value.Attribute = attr; 

					}
					break;

				}
				} finally { DebugExitSubRule(17); }

				DebugLocation(146, 61);
				// SugarWalker.g:146:61: (a= STRING )*
				try { DebugEnterSubRule(18);
				while (true)
				{
					int alt18=2;
					try { DebugEnterDecision(18, false);
					int LA18_0 = input.LA(1);

					if ((LA18_0==STRING))
					{
						alt18 = 1;
					}


					} finally { DebugExitDecision(18); }
					switch ( alt18 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarWalker.g:146:62: a= STRING
						{
						DebugLocation(146, 63);
						a=(CommonTree)Match(input,STRING,Follow._STRING_in_import_def609); 
						DebugLocation(146, 71);
						 value.NameList.Add(a.Text); 

						}
						break;

					default:
						goto loop18;
					}
				}

				loop18:
					;

				} finally { DebugExitSubRule(18); }


				Match(input, TokenTypes.Up, null); 
			}


			}

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			TraceOut("import_def", 11);
			LeaveRule("import_def", 11);
			LeaveRule_import_def();
		}
		DebugLocation(147, 1);
		} finally { DebugExitRule(GrammarFileName, "import_def"); }
		return value;

	}
Пример #3
0
 public override Template Visit(Import import)
 {
     Template template = new Template("<list; separator=\"\n\">");
     List<Template> list = new List<Template>();
     foreach (var name in import.NameList)
     {
         Template node = new Template("#include <name>");
         if (name.EndsWith(".sc\""))
         {
             // Todo: recursive compilation
             node.Add("name", name.Substring(0, name.Length - 4) + ".h\"");
         }
         else
         {
             node.Add("name", name);
         }
         list.Add(node);
     }
     template.Add("list", list);
     return template;
 }
Пример #4
0
 public abstract Template Visit(Import import);