2

Where can I find the LL(1) grammar used in TCC?

Fabrice Bellard's TCC is admirable. I wanted to learn more about its source code. Its parsing is done by hand, not automatically. Now I have found decl() function is related to parsing. Can someone who has studied TCC tell me how to find the documents about LL (1) grammar in TCC? Thank you so much!

Zhou
  • 21
  • 3
  • If my expression is not clear enough, welcome to ask me. – Zhou Aug 27 '19 at 12:42
  • [ANTLR has one](https://github.com/antlr/grammars-v4/tree/master/tinyc). From the comments on that page: `The grammar and examples are copied directory from the comments at the top of the TinyC source code.` – 500 - Internal Server Error Aug 27 '19 at 12:42
  • Questions about where to find source code, documentation and other off-site resources are unfortunately off-topic. – Lundin Aug 27 '19 at 12:49
  • If you want the formal C grammar you have to read the C specification. – Some programmer dude Aug 27 '19 at 12:51
  • @500-InternalServerError Many thanks for your reply! But the link is about Tiny C rather than TCC. What I wanted was the LL(1) grammar of the C language used in Tiny C Compiler coding. Tiny C Compiler supports complete C syntax. – Zhou Aug 27 '19 at 13:00
  • @Ludin So sorry – Zhou Aug 27 '19 at 13:04
  • After a quick glance of the TCC source, it seems to be a standard top-down recursive-descent parser. If you want to extract the grammar from that you have to do it from the source. – Some programmer dude Aug 27 '19 at 13:08
  • @Someprogrammerdude Yes, it is a standard top-down recursive-descent parser. I'm trying to do it, but I'm afraid I won't be able to complete it without errors, so I wonder if anyone has ever done it. Thank for your reply! – Zhou Aug 27 '19 at 13:18
  • @Ludin I'm a rookie on stack overflow. I would like to ask which type my question can be forwarded to on stack overflow, or is there no type on stack overflow that supports this kind of question? – Zhou Aug 27 '19 at 13:23
  • In order for it to be on-topic, you would have to ask about a specific technical problem. For example you could post a certain snippet or function from the compiler source and ask about how the part you don't understand works. It needs to be a specific, narrowed-down problem. – Lundin Aug 27 '19 at 13:26
  • As a beginner here on SO, please take some time to read [the help pages](http://stackoverflow.com/help), especially the sections named ["What topics can I ask about here?"](http://stackoverflow.com/help/on-topic) and ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask). Also please [take the tour](http://stackoverflow.com/tour) and [read about how to ask good questions](http://stackoverflow.com/help/how-to-ask). Lastly please read [this question checklist](https://codeblog.jonskeet.uk/2012/11/24/stack-overflow-question-checklist/). – Some programmer dude Aug 27 '19 at 13:27
  • OK! Thank you so much! – Zhou Aug 27 '19 at 13:31

0 Answers0