Compiler project 1.0.0 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

Compiler project 1.0.0

yet another exciting project, i have being assigned a project to build a simple compiler in c++, i dont know how simple it has to be, how should the blue print of my compiler look like? i just need help with general ideas in developing the compiler. what are the common tools i need for this project to be a success??

28th Aug 2017, 6:40 PM
Germain F
Germain F - avatar
23 Answers
+ 8
join our project : https://code.sololearn.com/W9G1YlB8mozL/?ref=app else 1 what do you mean by compiler? even python has a compiler 2 a assuming to assembly compilers, b assuming you know assembly see your target platform. as you will have to deal with assembly, you might want to see how assembly works and link on different platforms 3 if simple, you might want to write your own lexer 4 if simple, your own parser is fun i can continue but please give more info particularly 1
28th Aug 2017, 6:46 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 8
You could use the YACC (Yet Another Compiler Compiler) and LEX (Lexical Analyzer) tools to build your first compiler. http://dinosaur.compilertools.net http://tldp.org/HOWTO/Lex-YACC-HOWTO-5.html
28th Aug 2017, 7:46 PM
Karl T.
Karl T. - avatar
+ 8
@Abdur, in a very simple expression evaluator that calculated a math expression. I have a code on SL that uses a lexer and a parser that does just that. I had to convert BNF syntax to create a recursive descent parser which is based in part on the code I have studied with YACC.
28th Aug 2017, 8:38 PM
Karl T.
Karl T. - avatar
+ 7
@Germain in that case you need a good brush up on compiler design / compiler theory tutorials point just revamped it's section check that out else, i made a small tuto series : https://www.sololearn.com/Discuss/549601/?ref=app take a look ! our hub? it's on discord
28th Aug 2017, 8:26 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 7
@Abdur, what do you mean by that? ☺
28th Aug 2017, 8:28 PM
Karl T.
Karl T. - avatar
+ 7
1 have you used lex or yacc? @Karl?
28th Aug 2017, 8:29 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 7
@Abdur, yes a long time ago.
28th Aug 2017, 8:30 PM
Karl T.
Karl T. - avatar
+ 7
both @Karl?
28th Aug 2017, 8:31 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 7
@Abdur, yeah why?
28th Aug 2017, 8:31 PM
Karl T.
Karl T. - avatar
+ 7
so, in what context, which lang? @Karl
28th Aug 2017, 8:34 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 7
no good @Germain these tools are good but worthless if you don't understand what you are doing
28th Aug 2017, 8:35 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 7
@Abdur, you're right I guess. Just tought studying code generated from those tools could have helped.
28th Aug 2017, 8:49 PM
Karl T.
Karl T. - avatar
+ 7
i saw the link you posted, it explains the steps, how things get done but someone might think that lex == lexical analysis i.e. that lex analysis cannot be performed without lex
28th Aug 2017, 8:54 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 6
@karl T lol lexer and yacc it's easy to say while you increase the learning curve of the beginner trite
28th Aug 2017, 8:23 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
+ 6
@Karl look you know what a recursive descent parser but did not see it fit that the asker might study those things you straight suggested the use of tools you did not care to assess the level of knowledge of the asker you did well, just pointing out ... a point
28th Aug 2017, 8:47 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
28th Aug 2017, 7:54 PM
Manual
Manual - avatar
+ 4
@Abdur is it a complicated approach? i mean using lexer and yacc as a basic tool to learn compiler development
28th Aug 2017, 8:34 PM
Germain F
Germain F - avatar
+ 4
@Abdur that's true, maybe Karl can share his experience
28th Aug 2017, 8:38 PM
Germain F
Germain F - avatar
+ 3
@Abdur give me tips on writing a simple parser and lexer
28th Aug 2017, 7:13 PM
Germain F
Germain F - avatar
+ 3
@Karl thanks for tips
28th Aug 2017, 7:53 PM
Germain F
Germain F - avatar