# Strategies ## Interpretation - **Portability** : no need to compile - **Impact on the input language** : first order eval function, dynamic everything ## Virtual machines Allows processor emulation to allow execution on any platform ## Transpilation Conversion from a language to another (e.g. Arduino $\rightarrow$ C) ## Compilation **Ahead of time** compilation : produce a binary file that can be run in the targeted architecture **Just in time** compilation : involves compilation during execution ## Bytecode strategy - portable - low level - no physical machine can understand it - can be : - compiled - interpreted - executed by a VM # Development tools - Use warnings - Use **assert/static_assert** (C++11) - {Address,Thread,Memory,Leaks}Sanitizer - lcov ## Autotools - **autoconf** : package configuration - **automake** : package build - **libtool** : a portable build of shared libs - **gettext** : # Lexical analysis $$ chars \rightrightarrows SCAN \rightrightarrows tokens $$ ## Flex - **F**ast **L**exical Analyzer generator - GNU version of Lex - TC now uses RE/Flex ### Variables - **yytext** : token text - **yyleng** : size of token text - **yylex** : starts the scanning - **yywrap** : called when end of text is encountered, can be redefined if needed ## Bison - **yyparse** - **yyerror** ## Coupling Flex & Bison ```sh $ bison -o parser.cc -d --graph tmp.yy $ flex -o lexer.cc tmp.ll $ g++ -std=c++20 lexer.cc parser.cc $ echo "1+2+3+98" | ./a.out 104 $ echo "1+2+3++98" | ./a.out 1.7: syntax error, unexpected +, expecting number 0 ``` ## Error recovery