summaryrefslogtreecommitdiffstats
path: root/gfx/skia/skia/src/sksl/lex/DFA.h
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/skia/skia/src/sksl/lex/DFA.h')
-rw-r--r--gfx/skia/skia/src/sksl/lex/DFA.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/gfx/skia/skia/src/sksl/lex/DFA.h b/gfx/skia/skia/src/sksl/lex/DFA.h
new file mode 100644
index 0000000000..1fab51f921
--- /dev/null
+++ b/gfx/skia/skia/src/sksl/lex/DFA.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef SKSL_DFA
+#define SKSL_DFA
+
+#include <string>
+#include <vector>
+
+/**
+ * Tables representing a deterministic finite automaton for matching regular expressions.
+ */
+struct DFA {
+ DFA(std::vector<int> charMappings, std::vector<std::vector<int>> transitions,
+ std::vector<int> accepts)
+ : fCharMappings(charMappings)
+ , fTransitions(transitions)
+ , fAccepts(accepts) {}
+
+ // maps chars to the row index of fTransitions, as multiple characters may map to the same row.
+ // starting from state s and looking at char c, the new state is
+ // fTransitions[fCharMappings[c]][s].
+ std::vector<int> fCharMappings;
+
+ // one row per character mapping, one column per state
+ std::vector<std::vector<int>> fTransitions;
+
+ // contains, for each state, the token id we should report when matching ends in that state (-1
+ // for no match)
+ std::vector<int> fAccepts;
+};
+
+#endif