diff --git a/Dockerfile b/Dockerfile index 3eda9a4..ebd915c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -49,6 +49,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 +# 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 cool.flex.patch + # Setup working directory RUN mkdir -p /class WORKDIR /class diff --git a/cool.flex.patch b/cool.flex.patch new file mode 100644 index 0000000..a9d5f6a --- /dev/null +++ b/cool.flex.patch @@ -0,0 +1,20 @@ +--- cool.flex 2011-06-18 03:22:02.000000000 +0000 ++++ cool.flex.work 2020-12-19 22:43:35.902153646 +0000 +@@ -12,6 +12,17 @@ + #include + #include + ++/* 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 ++ */ ++extern int cool_yylex(); ++extern "C" { ++ int (&yylex) (void) = cool_yylex; ++} ++ + /* The compiler assumes these identifiers. */ + #define yylval cool_yylval + #define yylex cool_yylex