I understand that we have a temporary stack of nodes that we push/pop as we buil...

Jared Answered 5 answers
Question by Jared 3 years ago

Question

I understand that we have a temporary stack of nodes that we push/pop as we build the tree, but for some reason I'm struggling to visualize what is happening as I write it.

What is the name of the parsing strategy we're using? I think I will benefit from having a higher level background understanding.

Answers

Answered by Daniel McCarthy

Instructor

Hi, usually you use grammer parsers so you use a special grammer syntax and pass it into a parser which follows that grammer as rules. You can read more about that here: https://www.geeksforgeeks.org/types-of-parsers-in-compiler-design/

For more complicated parsers it is sometimes best to avoid grammer parsers that take that rule input. Our parser in this course for example is completley programatic, we use no grammer at all we manually parse every part of the C language.

This allows us to have more flexibility of how we parse and making changes can be easier. I'm unable to give a name to this type of parser because it does not use a grammer. We manually parse everything. Theres probably a name for the type of parser it is but it is not so important.

Well take an input of 50 + 30 . This in our compiler results in an expression node that holds a left node and a right node. Left being 50, and right being 30.

What is it that your struggling to understand so I can help more.

Follow-up by Jared

Question author

Ok thank you. I reviewed the video and the link a few times and it makes sense.

Could you explain the relationship between the DragonCompiler and the PeachCompiler on GitHub? And are either of them at the point of being able to self compile yet?

Answered by Daniel McCarthy

Instructor

Hi,
Both PeachCompiler and DragonCompiler are C-Like compilers meaning they support majority of the syntax of the C programming language but do not meet the specification 100%. Our compilers can compile most C code. Initializers are one example of things that are not included. This is a training course on how to build a compiler so we focus only on the most important things and a C-Like compiler is much more exciting than a simple compile for a custom language (In my opinion). However at the end of the course you should have the skills to continue implementing every part of C should you choose.

When I go to build a course I first start by creating the whole project, then I make a course remaking that project, as you know bugs are very common in software development, this is why I build the project first then rebuild it for a course.

I may develop Dragon Compiler at some point to be at a stage it can self compile but at the moment I have no plans to do so. The projects have always been to just teach compiler development and a C-Like compiler in my opinion is much more interesting than a compiler that attempts to compile something like BASIC. That is why a more complicated project was chosen as this training exercise.

Answered by Daniel McCarthy

Instructor

Additionally PeachCompiler is the compiler that is the result of this video course with each commit in that repository being named after the video lecture that created it to allow you students to follow along easily.

Follow-up by Jared

Question author

Ok thank you!