--- a/data.sty Tue Oct 06 13:32:00 2020 +0100
+++ b/data.sty Wed Oct 07 09:08:55 2020 +0100
@@ -101,6 +101,22 @@
27 22.430
\end{filecontents}
+% Dart, example (a*)*b
+\begin{filecontents}{re-dart.data}
+20 0.042
+21 0.084
+22 0.190
+23 0.340
+24 0.678
+25 1.369
+26 2.700
+27 5.462
+28 10.908
+29 21.725
+30 43.492
+\end{filecontents}
+
+
% Java 8, example (a*)*b
\begin{filecontents}{re-java.data}
5 0.00298
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/progs/catastrophic/catastrophic.dart Wed Oct 07 09:08:55 2020 +0100
@@ -0,0 +1,23 @@
+/// A case of catastrophic backtracking in Dart
+///---------------------------------------------
+/// example provided by Martin Todorov
+///
+/// regex: (a*)*b
+/// strings: aa...a
+///
+/// run with
+///
+/// dart catastrophic.dart n
+
+
+main(List<String> args) {
+ final n = int.parse(args[0]);
+ final evilRegex = RegExp("(a*)*b");
+
+ for(int i = 1; i <= n; i++) {
+ final toMatch = "a" * i;
+ final stopwatch = Stopwatch()..start();
+ evilRegex.hasMatch(toMatch);
+ print("$i a's matched in ${stopwatch.elapsed}");
+ }
+}
Binary file slides/slides02.pdf has changed
--- a/slides/slides02.tex Tue Oct 06 13:32:00 2020 +0100
+++ b/slides/slides02.tex Wed Oct 07 09:08:55 2020 +0100
@@ -20,7 +20,7 @@
numbers=none,
xleftmargin=0mm}
-\pgfplotsset{compat=1.12}
+\pgfplotsset{compat=1.17}
\newcommand{\bl}[1]{\textcolor{blue}{#1}}
@@ -887,13 +887,14 @@
axis lines=left,
width=9cm,
height=5.5cm,
- legend entries={Java 8, Python, JavaScript, Swift},
+ legend entries={Java 8,Python,JavaScript,Swift,Dart},
legend pos=north west,
legend cell align=left]
\addplot[blue,mark=*, mark options={fill=white}] table {re-python2.data};
\addplot[cyan,mark=*, mark options={fill=white}] table {re-java.data};
\addplot[red,mark=*, mark options={fill=white}] table {re-js.data};
\addplot[magenta,mark=*, mark options={fill=white}] table {re-swift.data};
+\addplot[brown,mark=*, mark options={fill=white}] table {re-dart.data};
\end{axis}
\end{tikzpicture}
\end{center}