23 AnswersNew Answer
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??
8/28/2017 6:40:18 PMZion Coder
23 AnswersNew Answer
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
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
@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.
@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
@Abdur, what do you mean by that? ☺
1 have you used lex or yacc? @Karl?
@Abdur, yes a long time ago.
@Abdur, yeah why?
so, in what context, which lang? @Karl
no good @Germain these tools are good but worthless if you don't understand what you are doing
@Abdur, you're right I guess. Just tought studying code generated from those tools could have helped.
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
@karl T lol lexer and yacc it's easy to say while you increase the learning curve of the beginner trite
@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
Maybe this could help https://www.sololearn.com/discuss/540958/?ref=app
@Abdur is it a complicated approach? i mean using lexer and yacc as a basic tool to learn compiler development
@Abdur that's true, maybe Karl can share his experience
@Abdur give me tips on writing a simple parser and lexer
@Karl thanks for tips
Learn Playing. Play Learning
SoloLearn Inc.4 Embarcadero Center, Suite 1455
Send us a message