preview

How The Relationship Between The Paarer And The Scanner System?

Good Essays

Obviously, I don’t have a complete 100% grasp on what the compiler for the Graphviz program works, but I have some ideas. I assume the first thing that happens is our .dot file is scanned for tokens. It must search through the file and scan the stream of characters recognizing that certain characters represent numbers, words, brackets, or end of lines. I’m not sure how the relationship between the Parser and the Scanner works in this compiler. With our simple python compiler, the Parser already had defined what to look for and it worked with a specific program structure that you couldn’t differentiate from as the programmer. Here, the parser doesn’t care what order the code is written (I can put the node declarations before the edge …show more content…

After parsing and building the AST, the parser hands the tree representation off to the semantic analyzer. In the case of the visgraph language, this is probably simpler than most semantic analyzer’s and it probably just ensures that everything makes sense from a logical point of view. It probably does things like check that a polygon wasn’t declared with -1 sides or that a box was declared with 3 sides. It ensures that the program is sound and makes sense so that it knows what to do during code/picture generation. From what I’ve found, when things don’t make sense (for example if I declare a polygon with -1 sides) it just omits that element from the graph completely. Without any visible knowledge of some sort of super complex error handling going on I imagine this portion of the visgraph compiler is somewhat simple. Unlike other compilers it doesn’t have to do as much logical analysis to make sure things like object types align (which you might see in a compiler for a statically typed language). We would usually then expect the AST to be handed to an optimizer, which I’m not sure is existent in the visgraph compiler. It might have an optimizer that handles things like removing any duplicate node declarations just to make code generation easier. Similar to the case of the python compiler, I’m not sure how much optimizing can really be done here. We’re not writing code to perform logic,

Get Access