Create bison tokens
Create tokens for bison out of a known list of words
Start file
call real integer write read while end do if then else program var begin return include
End file
call { yylval.type = strdup("res"); yylval.value = strdup(yytext); return Call; } real { yylval.type = strdup("res"); yylval.value = strdup(yytext); return Real; } integer { yylval.type = strdup("res"); yylval.value = strdup(yytext); return Integer; } write { yylval.type = strdup("res"); yylval.value = strdup(yytext); return Write; } read { yylval.type = strdup("res"); yylval.value = strdup(yytext); return Read; } while { yylval.type = strdup("res"); yylval.value = strdup(yytext); return While; } end { yylval.type = strdup("res"); yylval.value = strdup(yytext); return End; } do { yylval.type = strdup("res"); yylval.value = strdup(yytext); return Do; } if { yylval.type = strdup("res"); yylval.value = strdup(yytext); return If; } then { yylval.type = strdup("res"); yylval.value = strdup(yytext); return Then; } else { yylval.type = strdup("res"); yylval.value = strdup(yytext); return Else; } program { yylval.type = strdup("res"); yylval.value = strdup(yytext); return Program; } var { yylval.type = strdup("res"); yylval.value = strdup(yytext); return Var; } begin { yylval.type = strdup("res"); yylval.value = strdup(yytext); return Begin; } return { yylval.type = strdup("res"); yylval.value = strdup(yytext); return Return; } include { yylval.type = strdup("res"); yylval.value = strdup(yytext); return Include; }
View Diff
1c1,80 < call real integer write read while end do if then else program var begin return include --- > call { > yylval.type = strdup("res"); > yylval.value = strdup(yytext); > return Call; > } > real { > yylval.type = strdup("res"); > yylval.value = strdup(yytext); > return Real; > } > integer { > yylval.type = strdup("res"); > yylval.value = strdup(yytext); > return Integer; > } > write { > yylval.type = strdup("res"); > yylval.value = strdup(yytext); > return Write; > } > read { > yylval.type = strdup("res"); > yylval.value = strdup(yytext); > return Read; > } > while { > yylval.type = strdup("res"); > yylval.value = strdup(yytext); > return While; > } > end { > yylval.type = strdup("res"); > yylval.value = strdup(yytext); > return End; > } > do { > yylval.type = strdup("res"); > yylval.value = strdup(yytext); > return Do; > } > if { > yylval.type = strdup("res"); > yylval.value = strdup(yytext); > return If; > } > then { > yylval.type = strdup("res"); > yylval.value = strdup(yytext); > return Then; > } > else { > yylval.type = strdup("res"); > yylval.value = strdup(yytext); > return Else; > } > program { > yylval.type = strdup("res"); > yylval.value = strdup(yytext); > return Program; > } > var { > yylval.type = strdup("res"); > yylval.value = strdup(yytext); > return Var; > } > begin { > yylval.type = strdup("res"); > yylval.value = strdup(yytext); > return Begin; > } > return { > yylval.type = strdup("res"); > yylval.value = strdup(yytext); > return Return; > } > include { > yylval.type = strdup("res"); > yylval.value = strdup(yytext); > return Include; > }
Solutions
The best way to learn is to practice. Below, you will find some of the solutions other golfers have entered. To unlock higher ranked solutions, submit your own entry which does as well or better than the solutions you can currently see - climb the ladder!
Check out these helpful resources to improve your Vim skills... Game on.
Unlock 17 remaining solutions by signing in and submitting your own entry
#18 Alexander Botticelli / @BotticelliAlex - Score: 125 - 12/19/15 @ 11:49
q2wi<CR><Esc>kA{<CR><Tab>yylval.type = strdup("res");<Esc>yypwwciwvalue<Esc>4wci(yytr<BS>ext<Esc>kkbviwy2jA<CR>return ;<Esc>Pb~A<CR>}<Esc>i<BS><Esc>jq@<Esc>15@2ddkA<BS>e;<Esc>kkkie <Esc>:wq<CR>
0 comments