From 87181ffbb1c0850a5f174509be008897893366f9 Mon Sep 17 00:00:00 2001 From: Akshay Date: Fri, 30 Apr 2021 22:22:42 +0530 Subject: streamline build process --- 11/main.l | 1 - 11/main.y | 1 - 3/main.l | 2 ++ 6/main.l | 1 - 7/main.l | 1 - 8/main.l | 1 - 9/main.l | 1 - flake.nix | 28 +++++++++------------------- 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 @@ %{ -#include "y.tab.h" extern int yylval; %} 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 @@ %{ #include #include -#include "lex.yy.cc" int yylex(); int yyerror(char *); int 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] -{d}+ negint++; \+?{d}*\.{d}+ posfrac++; -{d}*\.{d}+ negfrac++; +\n ; +. ; %% int 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 @@ %{ -#include "y.tab.h" #include %} 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 @@ %{ -#include "y.tab.h" extern int yylval; %} 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 @@ %{ -#include "y.tab.h" extern int yylval; %} 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 @@ %{ -#include "y.tab.h" extern int yylval; %} diff --git a/flake.nix b/flake.nix index 2e717b8..c94f08a 100644 --- a/flake.nix +++ b/flake.nix @@ -12,7 +12,7 @@ flex bison ]; - defs = [ + execs = [ { name = "1"; yacc = false; } { name = "2"; yacc = false; } { name = "3"; yacc = false; } @@ -21,6 +21,9 @@ { name = "6"; yacc = true; } { name = "7"; yacc = true; } { name = "8"; yacc = true; } + { name = "9"; yacc = true; } + { name = "10"; yacc = true; } + { name = "11"; yacc = true; } ]; apps = builtins.listToAttrs (builtins.map (def: @@ -35,8 +38,10 @@ buildPhase = '' flex -o ${def.name}.yy.cc main.l if [[ ${pkgs.lib.trivial.boolToString def.yacc} = true ]]; then - yacc -d main.y - gcc -o exec y* ${def.name}.yy.cc + yacc -b ${def.name} -d main.y + gcc -o exec ${def.name}.tab.c \ + -include ${def.name}.tab.h \ + -include ${def.name}.yy.cc else gcc -o exec ${def.name}.yy.cc fi @@ -54,22 +59,7 @@ program = "${builder}/bin/exec"; }; }) - defs); - # buildYacc = pkgs.writeScriptBin "build-yacc" - # '' - # set -e - # prog_name="$1" - # outdir="outputs/$prog_name" - # mkdir -p "$outdir" - - # ${pkgs.flex}/bin/flex -o "$outdir"/lex.yy.cc "$prog_name"/main.l - # ${pkgs.bison}/bin/yacc -b "$outdir"/y -d "$prog_name"/main.y - # ${pkgs.gcc}/bin/gcc -o "$outdir"/exec "$outdir"/y.* - - # ./"$outdir"/exec < "$prog_name"/input - # rm -r outputs - # ''; - + execs); in rec { devShell = pkgs.mkShell { -- cgit v1.2.3