Advertisement
NovaYoshi

syntax tree

Nov 27th, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. Token list:
  2. (int)
  3. (main, identifier)
  4. ((, lparen)
  5. (void)
  6. (), rparen)
  7. ({, lcurly)
  8. (int)
  9. (num, identifier)
  10. (,, comma)
  11. (denom, identifier)
  12. (,, comma)
  13. (quot, identifier)
  14. (,, comma)
  15. (rem, identifier)
  16. (;, end_statement)
  17. (read)
  18. (num, identifier)
  19. (,, comma)
  20. (denom, identifier)
  21. (;, end_statement)
  22. (if)
  23. (denom, identifier)
  24. (=, logical)
  25. (0, integer)
  26. (then)
  27. (write, identifier)
  28. ((, lparen)
  29. ("the denominator has an invalid value 0!", string)
  30. (), rparen)
  31. (;, end_statement)
  32. (else)
  33. ({, lcurly)
  34. (rem, identifier)
  35. (:=, assignment)
  36. (num, identifier)
  37. (;, end_statement)
  38. (quot, identifier)
  39. (:=, assignment)
  40. (0, integer)
  41. (;, end_statement)
  42. (while)
  43. (rem, identifier)
  44. (>=, logical)
  45. (denom, identifier)
  46. (do)
  47. ({, lcurly)
  48. (rem, identifier)
  49. (:=, assignment)
  50. (rem, identifier)
  51. (-, add/sub)
  52. (denom, identifier)
  53. (;, end_statement)
  54. (quot, identifier)
  55. (:=, assignment)
  56. (quot, identifier)
  57. (+, add/sub)
  58. (1, integer)
  59. (;, end_statement)
  60. (}, rcurly)
  61. (;, end_statement)
  62. (write, identifier)
  63. ((, lparen)
  64. ("quotient = ", string)
  65. (,, comma)
  66. (quot, identifier)
  67. (), rparen)
  68. (;, end_statement)
  69. (write, identifier)
  70. ((, lparen)
  71. ("remainder = ", string)
  72. (,, comma)
  73. (rem, identifier)
  74. (), rparen)
  75. (;, end_statement)
  76. (}, rcurly)
  77. (;, end_statement)
  78. (}, rcurly)
  79.  
  80.  
  81.  
  82. Symbol table:
  83. (main, identifier)
  84. (num, identifier)
  85. (denom, identifier)
  86. (quot, identifier)
  87. (rem, identifier)
  88. (0, integer)
  89. (write, identifier)
  90. ("the denominator has an invalid value 0!", string)
  91. (1, integer)
  92. ("quotient = ", string)
  93. ("remainder = ", string)
  94.  
  95.  
  96.  
  97. Syntax tree:
  98. (int)
  99. (main, identifier)
  100. ((, lparen)
  101. (void)
  102. ({, lcurly)
  103. (int)
  104. (num, identifier)
  105. (denom, identifier)
  106. (quot, identifier)
  107. (rem, identifier)
  108. (read)
  109. (num, identifier)
  110. (denom, identifier)
  111. (if)
  112. (=, logical)
  113. (denom, identifier)
  114. (0, integer)
  115. (then)
  116. (write, identifier)
  117. ((, lparen)
  118. ("the denominator has an invalid value 0!", string)
  119. (else)
  120. ({, lcurly)
  121. (:=, assignment)
  122. (rem, identifier)
  123. (num, identifier)
  124. (:=, assignment)
  125. (quot, identifier)
  126. (0, integer)
  127. (while)
  128. (>=, logical)
  129. (rem, identifier)
  130. (denom, identifier)
  131. (do)
  132. ({, lcurly)
  133. (:=, assignment)
  134. (rem, identifier)
  135. (-, add/sub)
  136. (rem, identifier)
  137. (denom, identifier)
  138. (:=, assignment)
  139. (quot, identifier)
  140. (+, add/sub)
  141. (quot, identifier)
  142. (1, integer)
  143. (write, identifier)
  144. ((, lparen)
  145. ("quotient = ", string)
  146. (quot, identifier)
  147. (write, identifier)
  148. ((, lparen)
  149. ("remainder = ", string)
  150. (rem, identifier)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement