Our server costs ~$56 per month to run. Please consider donating or becoming a Patron to help keep the site running. Help us gain new members by following us on Twitter and liking our page on Facebook!
Current time: April 19, 2024, 5:18 pm

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Drawing ASTs
#1
Drawing ASTs
One of the features of my compiler is supposed to be the ability to draw ASTs in browsers that support manipulating SVG from JavaScript (which includes basically any modern browser, including Internet Explorer 11). You can check it out here. An example AST it draws is this :
[Image: seminar_html_32e0b75e29409762.gif]
While it works for such simple expressions, it fails to produce legible results for expressions with "deep" ASTs, such as even
Code:
1+2+3+4+5
. The diagram it produces for that expression (and similar ones) is a lot wider than necessary. So, which algorithm would you use to draw ASTs? How would you implement it in JavaScript?
Reply





Users browsing this thread: 1 Guest(s)