AspGenerator.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. //
  2. // System.Web.Compilation.AspGenerator
  3. //
  4. // Authors:
  5. // Gonzalo Paniagua Javier ([email protected])
  6. //
  7. // (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
  8. // Copyright (c) 2004,2006 Novell, Inc (http://www.novell.com)
  9. //
  10. //
  11. // Permission is hereby granted, free of charge, to any person obtaining
  12. // a copy of this software and associated documentation files (the
  13. // "Software"), to deal in the Software without restriction, including
  14. // without limitation the rights to use, copy, modify, merge, publish,
  15. // distribute, sublicense, and/or sell copies of the Software, and to
  16. // permit persons to whom the Software is furnished to do so, subject to
  17. // the following conditions:
  18. //
  19. // The above copyright notice and this permission notice shall be
  20. // included in all copies or substantial portions of the Software.
  21. //
  22. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  23. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  26. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  27. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29. //
  30. using System;
  31. using System.Collections;
  32. using System.CodeDom.Compiler;
  33. using System.Globalization;
  34. using System.IO;
  35. using System.Text;
  36. using System.Web.Caching;
  37. using System.Web.Configuration;
  38. using System.Web.UI;
  39. using System.Web.UI.HtmlControls;
  40. using System.Web.Util;
  41. namespace System.Web.Compilation
  42. {
  43. class BuilderLocation
  44. {
  45. public ControlBuilder Builder;
  46. public ILocation Location;
  47. public BuilderLocation (ControlBuilder builder, ILocation location)
  48. {
  49. this.Builder = builder;
  50. this.Location = location;
  51. }
  52. }
  53. class BuilderLocationStack : Stack
  54. {
  55. public override void Push (object o)
  56. {
  57. if (!(o is BuilderLocation))
  58. throw new InvalidOperationException ();
  59. base.Push (o);
  60. }
  61. public virtual void Push (ControlBuilder builder, ILocation location)
  62. {
  63. BuilderLocation bl = new BuilderLocation (builder, location);
  64. Push (bl);
  65. }
  66. public new BuilderLocation Peek ()
  67. {
  68. return (BuilderLocation) base.Peek ();
  69. }
  70. public new BuilderLocation Pop ()
  71. {
  72. return (BuilderLocation) base.Pop ();
  73. }
  74. public ControlBuilder Builder {
  75. get { return Peek ().Builder; }
  76. }
  77. }
  78. class ParserStack
  79. {
  80. Hashtable files;
  81. Stack parsers;
  82. AspParser current;
  83. public ParserStack ()
  84. {
  85. files = new Hashtable (); // may be this should be case sensitive for windows
  86. parsers = new Stack ();
  87. }
  88. public bool Push (AspParser parser)
  89. {
  90. if (files.Contains (parser.Filename))
  91. return false;
  92. files [parser.Filename] = true;
  93. parsers.Push (parser);
  94. current = parser;
  95. return true;
  96. }
  97. public AspParser Pop ()
  98. {
  99. if (parsers.Count == 0)
  100. return null;
  101. files.Remove (current.Filename);
  102. AspParser result = (AspParser) parsers.Pop ();
  103. if (parsers.Count > 0)
  104. current = (AspParser) parsers.Peek ();
  105. else
  106. current = null;
  107. return result;
  108. }
  109. public int Count {
  110. get { return parsers.Count; }
  111. }
  112. public AspParser Parser {
  113. get { return current; }
  114. }
  115. public string Filename {
  116. get { return current.Filename; }
  117. }
  118. }
  119. class TagStack
  120. {
  121. Stack tags;
  122. public TagStack ()
  123. {
  124. tags = new Stack ();
  125. }
  126. public void Push (string tagid)
  127. {
  128. tags.Push (tagid);
  129. }
  130. public string Pop ()
  131. {
  132. if (tags.Count == 0)
  133. return null;
  134. return (string) tags.Pop ();
  135. }
  136. public bool CompareTo (string tagid)
  137. {
  138. if (tags.Count == 0)
  139. return false;
  140. return 0 == String.Compare (tagid, (string) tags.Peek (), true, CultureInfo.InvariantCulture);
  141. }
  142. public int Count {
  143. get { return tags.Count; }
  144. }
  145. public string Current {
  146. get { return (string) tags.Peek (); }
  147. }
  148. }
  149. class AspGenerator
  150. {
  151. ParserStack pstack;
  152. BuilderLocationStack stack;
  153. TemplateParser tparser;
  154. StringBuilder text;
  155. RootBuilder rootBuilder;
  156. bool inScript, javascript, ignore_text;
  157. ILocation location;
  158. bool isApplication;
  159. StringBuilder tagInnerText = new StringBuilder ();
  160. static Hashtable emptyHash = new Hashtable ();
  161. bool inForm;
  162. bool useOtherTags;
  163. public AspGenerator (TemplateParser tparser)
  164. {
  165. this.tparser = tparser;
  166. text = new StringBuilder ();
  167. stack = new BuilderLocationStack ();
  168. rootBuilder = new RootBuilder (tparser);
  169. stack.Push (rootBuilder, null);
  170. tparser.RootBuilder = rootBuilder;
  171. pstack = new ParserStack ();
  172. }
  173. public RootBuilder RootBuilder {
  174. get { return tparser.RootBuilder; }
  175. }
  176. public AspParser Parser {
  177. get { return pstack.Parser; }
  178. }
  179. public string Filename {
  180. get { return pstack.Filename; }
  181. }
  182. BaseCompiler GetCompilerFromType ()
  183. {
  184. Type type = tparser.GetType ();
  185. if (type == typeof (PageParser))
  186. return new PageCompiler ((PageParser) tparser);
  187. if (type == typeof (ApplicationFileParser))
  188. return new GlobalAsaxCompiler ((ApplicationFileParser) tparser);
  189. if (type == typeof (UserControlParser))
  190. return new UserControlCompiler ((UserControlParser) tparser);
  191. #if NET_2_0
  192. if (type == typeof(MasterPageParser))
  193. return new MasterPageCompiler ((MasterPageParser) tparser);
  194. #endif
  195. throw new Exception ("Got type: " + type);
  196. }
  197. void InitParser (string filename)
  198. {
  199. StreamReader reader = new StreamReader (filename, WebEncoding.FileEncoding);
  200. AspParser parser = new AspParser (filename, reader);
  201. reader.Close ();
  202. parser.Error += new ParseErrorHandler (ParseError);
  203. parser.TagParsed += new TagParsedHandler (TagParsed);
  204. parser.TextParsed += new TextParsedHandler (TextParsed);
  205. if (!pstack.Push (parser))
  206. throw new ParseException (Location, "Infinite recursion detected including file: " + filename);
  207. tparser.AddDependency (filename);
  208. }
  209. public void Parse (string file)
  210. {
  211. InitParser (file);
  212. pstack.Parser.Parse ();
  213. if (text.Length > 0)
  214. FlushText ();
  215. pstack.Pop ();
  216. #if DEBUG
  217. PrintTree (rootBuilder, 0);
  218. #endif
  219. if (stack.Count > 1 && pstack.Count == 0)
  220. throw new ParseException (stack.Builder.location,
  221. "Expecting </" + stack.Builder.TagName + "> " + stack.Builder);
  222. }
  223. public void Parse ()
  224. {
  225. Parse (Path.GetFullPath (tparser.InputFile));
  226. }
  227. public Type GetCompiledType ()
  228. {
  229. Type type = (Type) HttpRuntime.Cache.Get ("@@Type" + tparser.InputFile);
  230. if (type != null) {
  231. return type;
  232. }
  233. isApplication = tparser.DefaultDirectiveName == "application";
  234. #if NET_2_0
  235. tparser.RegisterConfigControls ();
  236. #endif
  237. Parse ();
  238. BaseCompiler compiler = GetCompilerFromType ();
  239. type = compiler.GetCompiledType ();
  240. CacheDependency cd = new CacheDependency ((string[])
  241. tparser.Dependencies.ToArray (typeof (string)));
  242. HttpRuntime.Cache.InsertPrivate ("@@Type" + tparser.InputFile, type, cd);
  243. return type;
  244. }
  245. #if DEBUG
  246. static void PrintTree (ControlBuilder builder, int indent)
  247. {
  248. if (builder == null)
  249. return;
  250. string i = new string ('\t', indent);
  251. Console.Write (i);
  252. Console.WriteLine ("b: {0} id: {1} type: {2} parent: {3}",
  253. builder, builder.ID, builder.ControlType, builder.parentBuilder);
  254. if (builder.Children != null)
  255. foreach (object o in builder.Children) {
  256. if (o is ControlBuilder)
  257. PrintTree ((ControlBuilder) o, indent++);
  258. }
  259. }
  260. static void PrintLocation (ILocation loc)
  261. {
  262. Console.WriteLine ("\tFile name: " + loc.Filename);
  263. Console.WriteLine ("\tBegin line: " + loc.BeginLine);
  264. Console.WriteLine ("\tEnd line: " + loc.EndLine);
  265. Console.WriteLine ("\tBegin column: " + loc.BeginColumn);
  266. Console.WriteLine ("\tEnd column: " + loc.EndColumn);
  267. Console.WriteLine ("\tPlainText: " + loc.PlainText);
  268. Console.WriteLine ();
  269. }
  270. #endif
  271. void ParseError (ILocation location, string message)
  272. {
  273. throw new ParseException (location, message);
  274. }
  275. void TagParsed (ILocation location, TagType tagtype, string tagid, TagAttributes attributes)
  276. {
  277. this.location = new Location (location);
  278. if (tparser != null)
  279. tparser.Location = location;
  280. // MS ignores tbody/thead
  281. if ((attributes == null || !attributes.IsRunAtServer ())) {
  282. if (String.Compare (tagid, "tbody", true, CultureInfo.InvariantCulture) == 0 ||
  283. String.Compare (tagid, "thead", true, CultureInfo.InvariantCulture) == 0)
  284. return;
  285. }
  286. if (text.Length != 0)
  287. FlushText ();
  288. if (0 == String.Compare (tagid, "script", true, CultureInfo.InvariantCulture)) {
  289. bool in_script = (inScript || ignore_text);
  290. if (in_script || (tagtype != TagType.Close && attributes != null)) {
  291. if ((in_script || attributes.IsRunAtServer ()) && ProcessScript (tagtype, attributes))
  292. return;
  293. }
  294. }
  295. switch (tagtype) {
  296. case TagType.Directive:
  297. if (tagid == "")
  298. tagid = tparser.DefaultDirectiveName;
  299. tparser.AddDirective (tagid, attributes.GetDictionary (null));
  300. break;
  301. case TagType.Tag:
  302. if (ProcessTag (tagid, attributes, tagtype)) {
  303. useOtherTags = true;
  304. break;
  305. }
  306. if (useOtherTags) {
  307. stack.Builder.EnsureOtherTags ();
  308. stack.Builder.OtherTags.Add (tagid);
  309. }
  310. TextParsed (location, location.PlainText);
  311. break;
  312. case TagType.Close:
  313. bool notServer = (useOtherTags && TryRemoveTag (tagid, stack.Builder.OtherTags));
  314. if (!notServer && CloseControl (tagid))
  315. break;
  316. TextParsed (location, location.PlainText);
  317. break;
  318. case TagType.SelfClosing:
  319. int count = stack.Count;
  320. if (!ProcessTag (tagid, attributes, tagtype)) {
  321. TextParsed (location, location.PlainText);
  322. } else if (stack.Count != count) {
  323. CloseControl (tagid);
  324. }
  325. break;
  326. case TagType.DataBinding:
  327. goto case TagType.CodeRender;
  328. case TagType.CodeRenderExpression:
  329. goto case TagType.CodeRender;
  330. case TagType.CodeRender:
  331. if (isApplication)
  332. throw new ParseException (location, "Invalid content for application file.");
  333. ProcessCode (tagtype, tagid, location);
  334. break;
  335. case TagType.Include:
  336. if (isApplication)
  337. throw new ParseException (location, "Invalid content for application file.");
  338. string file = attributes ["virtual"] as string;
  339. bool isvirtual = (file != null);
  340. if (!isvirtual)
  341. file = attributes ["file"] as string;
  342. if (isvirtual) {
  343. file = tparser.MapPath (file);
  344. } else {
  345. file = GetIncludeFilePath (tparser.BaseDir, file);
  346. }
  347. Parse (file);
  348. break;
  349. default:
  350. break;
  351. }
  352. //PrintLocation (location);
  353. }
  354. static bool TryRemoveTag (string tagid, ArrayList otags)
  355. {
  356. if (otags == null || otags.Count == 0)
  357. return false;
  358. for (int idx = otags.Count - 1; idx >= 0; idx--) {
  359. string otagid = (string) otags [idx];
  360. if (0 == String.Compare (tagid, otagid, true, CultureInfo.InvariantCulture)) {
  361. do {
  362. otags.RemoveAt (idx);
  363. } while (otags.Count - 1 >= idx);
  364. return true;
  365. }
  366. }
  367. return false;
  368. }
  369. static string GetIncludeFilePath (string basedir, string filename)
  370. {
  371. if (Path.DirectorySeparatorChar == '/')
  372. filename = filename.Replace ("\\", "/");
  373. return Path.GetFullPath (Path.Combine (basedir, filename));
  374. }
  375. void TextParsed (ILocation location, string text)
  376. {
  377. if (ignore_text)
  378. return;
  379. if (text.IndexOf ("<%") != -1 && !inScript) {
  380. if (this.text.Length > 0)
  381. FlushText ();
  382. CodeRenderParser r = new CodeRenderParser (text, stack.Builder);
  383. r.AddChildren ();
  384. return;
  385. }
  386. this.text.Append (text);
  387. //PrintLocation (location);
  388. }
  389. void FlushText ()
  390. {
  391. string t = text.ToString ();
  392. text.Length = 0;
  393. if (inScript) {
  394. // TODO: store location
  395. tparser.Scripts.Add (t);
  396. return;
  397. }
  398. if (tparser.DefaultDirectiveName == "application" && t.Trim () != "")
  399. throw new ParseException (location, "Content not valid for application file.");
  400. ControlBuilder current = stack.Builder;
  401. current.AppendLiteralString (t);
  402. if (current.NeedsTagInnerText ()) {
  403. tagInnerText.Append (t);
  404. }
  405. }
  406. bool ProcessTag (string tagid, TagAttributes atts, TagType tagtype)
  407. {
  408. if (isApplication) {
  409. if (String.Compare (tagid, "object", true, CultureInfo.InvariantCulture) != 0)
  410. throw new ParseException (location, "Invalid tag for application file.");
  411. }
  412. ControlBuilder parent = stack.Builder;
  413. ControlBuilder builder = null;
  414. Hashtable htable = (atts != null) ? atts.GetDictionary (null) : emptyHash;
  415. if (stack.Count > 1) {
  416. try {
  417. builder = parent.CreateSubBuilder (tagid, htable, null, tparser, location);
  418. } catch (TypeLoadException e) {
  419. throw new ParseException (Location, "Type not found.", e);
  420. } catch (Exception e) {
  421. throw new ParseException (Location, e.Message, e);
  422. }
  423. }
  424. if (builder == null && atts != null && atts.IsRunAtServer ()) {
  425. string id = htable ["id"] as string;
  426. if (id != null && !CodeGenerator.IsValidLanguageIndependentIdentifier (id))
  427. throw new ParseException (Location, "'" + id + "' is not a valid identifier");
  428. try {
  429. builder = rootBuilder.CreateSubBuilder (tagid, htable, null, tparser, location);
  430. } catch (TypeLoadException e) {
  431. throw new ParseException (Location, "Type not found.", e);
  432. } catch (Exception e) {
  433. throw new ParseException (Location, e.Message, e);
  434. }
  435. }
  436. if (builder == null)
  437. return false;
  438. builder.location = location;
  439. builder.ID = htable ["id"] as string;
  440. if (typeof (HtmlForm).IsAssignableFrom (builder.ControlType)) {
  441. if (inForm)
  442. throw new ParseException (location, "Only one <form> allowed.");
  443. inForm = true;
  444. }
  445. if (builder.HasBody () && !(builder is ObjectTagBuilder)) {
  446. if (builder is TemplateBuilder) {
  447. // push the id list
  448. }
  449. stack.Push (builder, location);
  450. } else {
  451. if (!isApplication && builder is ObjectTagBuilder) {
  452. ObjectTagBuilder ot = (ObjectTagBuilder) builder;
  453. if (ot.Scope != null && ot.Scope != "")
  454. throw new ParseException (location, "Scope not allowed here");
  455. if (tagtype == TagType.Tag) {
  456. stack.Push (builder, location);
  457. return true;
  458. }
  459. }
  460. parent.AppendSubBuilder (builder);
  461. builder.CloseControl ();
  462. }
  463. return true;
  464. }
  465. string ReadFile (string filename)
  466. {
  467. string realpath = tparser.MapPath (filename);
  468. using (StreamReader sr = new StreamReader (realpath, WebEncoding.FileEncoding)) {
  469. string content = sr.ReadToEnd ();
  470. return content;
  471. }
  472. }
  473. bool ProcessScript (TagType tagtype, TagAttributes attributes)
  474. {
  475. if (tagtype != TagType.Close) {
  476. if (attributes != null && attributes.IsRunAtServer ()) {
  477. CheckLanguage ((string) attributes ["language"]);
  478. string src = (string) attributes ["src"];
  479. if (src != null) {
  480. if (src == "")
  481. throw new ParseException (Parser,
  482. "src cannot be an empty string");
  483. string content = ReadFile (src);
  484. inScript = true;
  485. TextParsed (Parser, content);
  486. FlushText ();
  487. inScript = false;
  488. if (tagtype != TagType.SelfClosing) {
  489. ignore_text = true;
  490. Parser.VerbatimID = "script";
  491. }
  492. } else if (tagtype == TagType.Tag) {
  493. Parser.VerbatimID = "script";
  494. inScript = true;
  495. }
  496. return true;
  497. } else {
  498. if (tagtype != TagType.SelfClosing) {
  499. Parser.VerbatimID = "script";
  500. javascript = true;
  501. }
  502. TextParsed (location, location.PlainText);
  503. return true;
  504. }
  505. }
  506. bool result;
  507. if (inScript) {
  508. result = inScript;
  509. inScript = false;
  510. } else if (!ignore_text) {
  511. result = javascript;
  512. javascript = false;
  513. TextParsed (location, location.PlainText);
  514. } else {
  515. ignore_text = false;
  516. result = true;
  517. }
  518. return result;
  519. }
  520. bool CloseControl (string tagid)
  521. {
  522. ControlBuilder current = stack.Builder;
  523. string btag = current.TagName;
  524. if (String.Compare (btag, "tbody", true, CultureInfo.InvariantCulture) != 0 &&
  525. String.Compare (tagid, "tbody", true, CultureInfo.InvariantCulture) == 0) {
  526. if (!current.ChildrenAsProperties) {
  527. try {
  528. TextParsed (location, location.PlainText);
  529. FlushText ();
  530. } catch {}
  531. }
  532. return true;
  533. }
  534. if (0 != String.Compare (tagid, btag, true, CultureInfo.InvariantCulture))
  535. return false;
  536. // if (current is TemplateBuilder)
  537. // pop from the id list
  538. if (current.NeedsTagInnerText ()) {
  539. try {
  540. current.SetTagInnerText (tagInnerText.ToString ());
  541. } catch (Exception e) {
  542. throw new ParseException (current.location, e.Message, e);
  543. }
  544. tagInnerText.Length = 0;
  545. }
  546. if (typeof (HtmlForm).IsAssignableFrom (current.ControlType)) {
  547. inForm = false;
  548. }
  549. current.CloseControl ();
  550. stack.Pop ();
  551. stack.Builder.AppendSubBuilder (current);
  552. return true;
  553. }
  554. bool ProcessCode (TagType tagtype, string code, ILocation location)
  555. {
  556. ControlBuilder b = null;
  557. if (tagtype == TagType.CodeRender)
  558. b = new CodeRenderBuilder (code, false, location);
  559. else if (tagtype == TagType.CodeRenderExpression)
  560. b = new CodeRenderBuilder (code, true, location);
  561. else if (tagtype == TagType.DataBinding)
  562. b = new DataBindingBuilder (code, location);
  563. else
  564. throw new HttpException ("Should never happen");
  565. stack.Builder.AppendSubBuilder (b);
  566. return true;
  567. }
  568. public ILocation Location {
  569. get { return location; }
  570. }
  571. void CheckLanguage (string lang)
  572. {
  573. if (lang == null || lang == "")
  574. return;
  575. if (String.Compare (lang, tparser.Language, true, CultureInfo.InvariantCulture) == 0)
  576. return;
  577. #if NET_2_0
  578. CompilationSection section = (CompilationSection) WebConfigurationManager.GetSection ("system.web/compilation");
  579. if (section.Compilers[tparser.Language] != section.Compilers[lang])
  580. #else
  581. CompilationConfiguration cfg = CompilationConfiguration.GetInstance (HttpContext.Current);
  582. if (!cfg.Compilers.CompareLanguages (tparser.Language, lang))
  583. #endif
  584. throw new ParseException (Location,
  585. String.Format ("Trying to mix language '{0}' and '{1}'.",
  586. tparser.Language, lang));
  587. }
  588. // Used to get CodeRender tags in attribute values
  589. class CodeRenderParser
  590. {
  591. string str;
  592. ControlBuilder builder;
  593. public CodeRenderParser (string str, ControlBuilder builder)
  594. {
  595. this.str = str;
  596. this.builder = builder;
  597. }
  598. public void AddChildren ()
  599. {
  600. int index = str.IndexOf ("<%");
  601. if (index > 0) {
  602. TextParsed (null, str.Substring (0, index));
  603. str = str.Substring (index);
  604. }
  605. AspParser parser = new AspParser ("@@inner_string@@", new StringReader (str));
  606. parser.Error += new ParseErrorHandler (ParseError);
  607. parser.TagParsed += new TagParsedHandler (TagParsed);
  608. parser.TextParsed += new TextParsedHandler (TextParsed);
  609. parser.Parse ();
  610. }
  611. void TagParsed (ILocation location, TagType tagtype, string tagid, TagAttributes attributes)
  612. {
  613. if (tagtype == TagType.CodeRender)
  614. builder.AppendSubBuilder (new CodeRenderBuilder (tagid, false, location));
  615. else if (tagtype == TagType.CodeRenderExpression)
  616. builder.AppendSubBuilder (new CodeRenderBuilder (tagid, true, location));
  617. else if (tagtype == TagType.DataBinding)
  618. builder.AppendSubBuilder (new DataBindingBuilder (tagid, location));
  619. else
  620. builder.AppendLiteralString (location.PlainText);
  621. }
  622. void TextParsed (ILocation location, string text)
  623. {
  624. builder.AppendLiteralString (text);
  625. }
  626. void ParseError (ILocation location, string message)
  627. {
  628. throw new ParseException (location, message);
  629. }
  630. }
  631. }
  632. }