diff --git a/Dockerfile b/Dockerfile index d330367..3956dd1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -52,13 +52,14 @@ RUN sed -i 's/-zx/-ozx/g' \ /usr/class/assignments/PA4J/grade.pl /usr/class/assignments/PA4/grade.pl \ /usr/class/assignments/PA5J/grade.pl /usr/class/assignments/PA5/grade.pl -# Patch cool.flex in submission folder +# Patch cool.flex, cool.y in submission folder # This is a hack to # a) satisfy the cool compiler which expects yylex to be named cool_yylex # b) satisfy libfl > 2.5.39 which expects a yylex symbol # c) fix mangling errors of yylex when compiled with a c++ compiler # d) be as non-invasive as possible to the existing assignment code -RUN patch -u /usr/class/assignments/PA2/cool.flex -i /tmp/build/cool.flex.patch +RUN patch -u /usr/class/assignments/PA2/cool.flex -i /tmp/build/cool.flex.patch \ + && patch -u /usr/class/assignments/PA3/cool.y -i /tmp/build/cool.y.patch # Setup working directory RUN mkdir -p /class diff --git a/cool.y.patch b/cool.y.patch new file mode 100644 index 0000000..c31e145 --- /dev/null +++ b/cool.y.patch @@ -0,0 +1,26 @@ +--- cool.y 2020-12-22 01:57:18.912461835 +0000 ++++ cool.y.work 2020-12-22 01:57:06.089590582 +0000 +@@ -11,6 +11,23 @@ + + extern char *curr_filename; + ++ /* This is a hack to ++ * a) satisfy the cool compiler which expects yylex to be named cool_yylex (see below) ++ * b) satisfy libfl > 2.5.39 which expects a yylex symbol ++ * c) fix mangling errors of yylex when compiled with a c++ compiler ++ * d) be as non-invasive as possible to the existing assignment code ++ * ++ * WARNING: We are now leaving standard country, but `push_macro` is supported ++ * in all major compilers. ++ */ ++ #pragma push_macro("yylex") ++ #undef yylex ++ int cool_yylex(); ++ extern "C" { ++ int (&yylex) (void) = cool_yylex; ++ } ++ #pragma pop_macro("yylex") ++ + + /* Locations */ + #define YYLTYPE int /* the type of locations */