aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-04-30 17:52:42 +0100
committerAkshay <[email protected]>2021-04-30 17:52:42 +0100
commit87181ffbb1c0850a5f174509be008897893366f9 (patch)
treed80e17cddc779acb0e38ab406543e4fa235ed860
parent8cb6a5bbc3dff236c951eb1ff73ecd5b2d55556d (diff)
streamline build process
-rw-r--r--11/main.l1
-rw-r--r--11/main.y1
-rw-r--r--3/main.l2
-rw-r--r--6/main.l1
-rw-r--r--7/main.l1
-rw-r--r--8/main.l1
-rw-r--r--9/main.l1
-rw-r--r--flake.nix28
8 files changed, 11 insertions, 25 deletions
diff --git a/11/main.l b/11/main.l
index 5cc2a4e..9229af8 100644
--- a/11/main.l
+++ b/11/main.l
@@ -1,5 +1,4 @@
1%{ 1%{
2#include "y.tab.h"
3extern int yylval; 2extern int yylval;
4%} 3%}
5 4
diff --git a/11/main.y b/11/main.y
index 9ed51a0..2561951 100644
--- a/11/main.y
+++ b/11/main.y
@@ -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"
5int yylex(); 4int yylex();
6int yyerror(char *); 5int yyerror(char *);
7int loop_count = 0; 6int loop_count = 0;
diff --git a/3/main.l b/3/main.l
index ebac3d7..f423e7a 100644
--- a/3/main.l
+++ b/3/main.l
@@ -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
23int main(void) { 25int main(void) {
diff --git a/6/main.l b/6/main.l
index 55dac30..d2eded0 100644
--- a/6/main.l
+++ b/6/main.l
@@ -1,5 +1,4 @@
1%{ 1%{
2#include "y.tab.h"
3#include <stdlib.h> 2#include <stdlib.h>
4%} 3%}
5 4
diff --git a/7/main.l b/7/main.l
index 7e1332f..2f98161 100644
--- a/7/main.l
+++ b/7/main.l
@@ -1,5 +1,4 @@
1%{ 1%{
2#include "y.tab.h"
3extern int yylval; 2extern int yylval;
4%} 3%}
5 4
diff --git a/8/main.l b/8/main.l
index 3db9d6d..ad755d5 100644
--- a/8/main.l
+++ b/8/main.l
@@ -1,5 +1,4 @@
1%{ 1%{
2#include "y.tab.h"
3extern int yylval; 2extern int yylval;
4%} 3%}
5 4
diff --git a/9/main.l b/9/main.l
index 04c6bf0..7e888e9 100644
--- a/9/main.l
+++ b/9/main.l
@@ -1,5 +1,4 @@
1%{ 1%{
2#include "y.tab.h"
3extern int yylval; 2extern int yylval;
4%} 3%}
5 4
diff --git a/flake.nix b/flake.nix
index 2e717b8..c94f08a 100644
--- a/flake.nix
+++ b/flake.nix
@@ -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 {