diff options
author | Akshay <[email protected]> | 2021-04-30 17:52:42 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2021-04-30 17:52:42 +0100 |
commit | 87181ffbb1c0850a5f174509be008897893366f9 (patch) | |
tree | d80e17cddc779acb0e38ab406543e4fa235ed860 | |
parent | 8cb6a5bbc3dff236c951eb1ff73ecd5b2d55556d (diff) |
streamline build process
-rw-r--r-- | 11/main.l | 1 | ||||
-rw-r--r-- | 11/main.y | 1 | ||||
-rw-r--r-- | 3/main.l | 2 | ||||
-rw-r--r-- | 6/main.l | 1 | ||||
-rw-r--r-- | 7/main.l | 1 | ||||
-rw-r--r-- | 8/main.l | 1 | ||||
-rw-r--r-- | 9/main.l | 1 | ||||
-rw-r--r-- | flake.nix | 28 |
8 files changed, 11 insertions, 25 deletions
@@ -1,5 +1,4 @@ | |||
1 | %{ | 1 | %{ |
2 | #include "y.tab.h" | ||
3 | extern int yylval; | 2 | extern int yylval; |
4 | %} | 3 | %} |
5 | 4 | ||
@@ -1,7 +1,6 @@ | |||
1 | %{ | 1 | %{ |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include "lex.yy.cc" | ||
5 | int yylex(); | 4 | int yylex(); |
6 | int yyerror(char *); | 5 | int yyerror(char *); |
7 | int loop_count = 0; | 6 | int loop_count = 0; |
@@ -18,6 +18,8 @@ d [0-9] | |||
18 | -{d}+ negint++; | 18 | -{d}+ negint++; |
19 | \+?{d}*\.{d}+ posfrac++; | 19 | \+?{d}*\.{d}+ posfrac++; |
20 | -{d}*\.{d}+ negfrac++; | 20 | -{d}*\.{d}+ negfrac++; |
21 | \n ; | ||
22 | . ; | ||
21 | %% | 23 | %% |
22 | 24 | ||
23 | int main(void) { | 25 | int main(void) { |
@@ -1,5 +1,4 @@ | |||
1 | %{ | 1 | %{ |
2 | #include "y.tab.h" | ||
3 | #include <stdlib.h> | 2 | #include <stdlib.h> |
4 | %} | 3 | %} |
5 | 4 | ||
@@ -1,5 +1,4 @@ | |||
1 | %{ | 1 | %{ |
2 | #include "y.tab.h" | ||
3 | extern int yylval; | 2 | extern int yylval; |
4 | %} | 3 | %} |
5 | 4 | ||
@@ -1,5 +1,4 @@ | |||
1 | %{ | 1 | %{ |
2 | #include "y.tab.h" | ||
3 | extern int yylval; | 2 | extern int yylval; |
4 | %} | 3 | %} |
5 | 4 | ||
@@ -1,5 +1,4 @@ | |||
1 | %{ | 1 | %{ |
2 | #include "y.tab.h" | ||
3 | extern int yylval; | 2 | extern int yylval; |
4 | %} | 3 | %} |
5 | 4 | ||
@@ -12,7 +12,7 @@ | |||
12 | flex | 12 | flex |
13 | bison | 13 | bison |
14 | ]; | 14 | ]; |
15 | defs = [ | 15 | execs = [ |
16 | { name = "1"; yacc = false; } | 16 | { name = "1"; yacc = false; } |
17 | { name = "2"; yacc = false; } | 17 | { name = "2"; yacc = false; } |
18 | { name = "3"; yacc = false; } | 18 | { name = "3"; yacc = false; } |
@@ -21,6 +21,9 @@ | |||
21 | { name = "6"; yacc = true; } | 21 | { name = "6"; yacc = true; } |
22 | { name = "7"; yacc = true; } | 22 | { name = "7"; yacc = true; } |
23 | { name = "8"; yacc = true; } | 23 | { name = "8"; yacc = true; } |
24 | { name = "9"; yacc = true; } | ||
25 | { name = "10"; yacc = true; } | ||
26 | { name = "11"; yacc = true; } | ||
24 | ]; | 27 | ]; |
25 | apps = builtins.listToAttrs (builtins.map | 28 | apps = builtins.listToAttrs (builtins.map |
26 | (def: | 29 | (def: |
@@ -35,8 +38,10 @@ | |||
35 | buildPhase = '' | 38 | buildPhase = '' |
36 | flex -o ${def.name}.yy.cc main.l | 39 | flex -o ${def.name}.yy.cc main.l |
37 | if [[ ${pkgs.lib.trivial.boolToString def.yacc} = true ]]; then | 40 | if [[ ${pkgs.lib.trivial.boolToString def.yacc} = true ]]; then |
38 | yacc -d main.y | 41 | yacc -b ${def.name} -d main.y |
39 | gcc -o exec y* ${def.name}.yy.cc | 42 | gcc -o exec ${def.name}.tab.c \ |
43 | -include ${def.name}.tab.h \ | ||
44 | -include ${def.name}.yy.cc | ||
40 | else | 45 | else |
41 | gcc -o exec ${def.name}.yy.cc | 46 | gcc -o exec ${def.name}.yy.cc |
42 | fi | 47 | fi |
@@ -54,22 +59,7 @@ | |||
54 | program = "${builder}/bin/exec"; | 59 | program = "${builder}/bin/exec"; |
55 | }; | 60 | }; |
56 | }) | 61 | }) |
57 | defs); | 62 | execs); |
58 | # buildYacc = pkgs.writeScriptBin "build-yacc" | ||
59 | # '' | ||
60 | # set -e | ||
61 | # prog_name="$1" | ||
62 | # outdir="outputs/$prog_name" | ||
63 | # mkdir -p "$outdir" | ||
64 | |||
65 | # ${pkgs.flex}/bin/flex -o "$outdir"/lex.yy.cc "$prog_name"/main.l | ||
66 | # ${pkgs.bison}/bin/yacc -b "$outdir"/y -d "$prog_name"/main.y | ||
67 | # ${pkgs.gcc}/bin/gcc -o "$outdir"/exec "$outdir"/y.* | ||
68 | |||
69 | # ./"$outdir"/exec < "$prog_name"/input | ||
70 | # rm -r outputs | ||
71 | # ''; | ||
72 | |||
73 | in | 63 | in |
74 | rec { | 64 | rec { |
75 | devShell = pkgs.mkShell { | 65 | devShell = pkgs.mkShell { |