GetParseTree.xml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
  4. <sect1 id="GetParseTree">
  5. <title>GetParseTree</title>
  6. <para><emphasis role="bold">STD.System.Debug.GetParseTree<indexterm>
  7. <primary>STD.System.Debug.GetParseTree</primary>
  8. </indexterm> <indexterm>
  9. <primary>System.Debug.GetParseTree</primary>
  10. </indexterm> <indexterm>
  11. <primary>Debug.GetParseTree</primary>
  12. </indexterm> <indexterm>
  13. <primary>GetParseTree</primary>
  14. </indexterm>(</emphasis> <emphasis> </emphasis> <emphasis
  15. role="bold">)</emphasis></para>
  16. <informaltable colsep="0" frame="none" rowsep="0">
  17. <tgroup cols="2">
  18. <colspec colwidth="80.50pt" />
  19. <colspec />
  20. <tbody>
  21. <row>
  22. <entry>Return:<emphasis> </emphasis></entry>
  23. <entry>GetParseTree returns a STRING value.</entry>
  24. </row>
  25. </tbody>
  26. </tgroup>
  27. </informaltable>
  28. <para>The <emphasis role="bold">GetParseTree </emphasis>function returns a
  29. textual representation of the match that occurred, using square brackets
  30. (such as: a[b[c]d] ) to indicate nesting. This function is only used within
  31. the RECORD or TRANSFORM structure that defines the result of a PARSE
  32. operation. This function is useful for debugging PARSE operations.</para>
  33. <para>Example:</para>
  34. <programlisting format="linespecific">IMPORT STD;
  35. r := {string150 line};
  36. d := dataset([
  37. {'Ge 34:2 And when Shechem the son of Hamor the Hivite, '+
  38. 'prince of the country, saw her, he took her, and lay with her, '+
  39. 'and defiled her.'},
  40. {'Ge 36:10 These are the names of Esaus sons; Eliphaz the son of '+
  41. 'Adah the wife of Esau, Reuel the son of Bashemath the wife of '+
  42. 'Esau.'}
  43. ],r);
  44. PATTERN ws := [' ','\t',',']*;
  45. PATTERN patStart := FIRST | ws;
  46. PATTERN patEnd := LAST | ws;
  47. PATTERN article := ['A','The','Thou','a','the','thou'];
  48. TOKEN patWord := PATTERN('[a-zA-Z]+');
  49. TOKEN Name := PATTERN('[A-Z][a-zA-Z]+');
  50. RULE Namet := name OPT(ws 'the' ws name);
  51. PATTERN produced_by := OPT(article ws) ['son of','daughter of'];
  52. PATTERN produces_with := OPT(article ws) ['wife of'];
  53. RULE progeny := namet ws ( produced_by | produces_with ) ws namet;
  54. results := RECORD
  55. STRING LeftName := MATCHTEXT(Namet[1]);
  56. STRING RightName := MATCHTEXT(Namet[2]);
  57. STRING LinkPhrase := IF(MATCHTEXT(produced_by[1])&lt;&gt;'',
  58. MATCHTEXT(produced_by[1]),
  59. MATCHTEXT(produces_with[1]));
  60. STRING Tree := 'Tree: ' + STD.System.Debug.getParseTree();
  61. END;
  62. outfile1 := PARSE(d,line,progeny,results,SCAN ALL);
  63. /* the Tree field output looks like this:
  64. Tree: [namet[name"Shechem"] ws" " produced_by"the son of" ws" " namet[name"Hamor"]]
  65. */</programlisting>
  66. </sect1>