1
votes

I'm learning Flex / Bison right now, thinking I can do a compiler, but the more I inquire the more I get the impression that they are only Syntactic Analyzers, and do not allow to generate new files executable universal windows from our programming language. I explain, when the file generated by Bison is executed, it is only interpreted our code language in C.

Is it possible to create a compiler that generates executable files from any windows that do not have my compiler?

1

1 Answers

1
votes

Yes, it's possible (and perfectly common) to write compilers using flex+bison, but these tools only help you do the lexical and syntactic analysis. You'll have to do the rest yourself or using additional tools like LLVM.

For example to create a simple single-pass compiler you could simply write assembly instructions into a file from within your bison-actions. Then you could run that file through an assembler and linker at the end and get an executable.

Or for a more complicated compiler you might create an abstract syntax tree inside your bison actions and then walk that tree in later phases to perform transformations and analyses on it until you finally generate assembly.

Either way bison only helps you with the parsing, you'll need to perform the other steps yourself.