aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/lex/DFA.h
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-09-07 09:39:50 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-07 13:57:51 +0000
commitca82a922e3d081ae83c940f4fd3ccc8cc6f0916f (patch)
tree480d95845bf2ce5e24d26ff30ab96cdeb3ee6315 /src/sksl/lex/DFA.h
parente5756eccc41fabc421a7fe8b00807c3dcd257b9f (diff)
Revert "Revert "Initial checkin of SkSL lexical analyzer generator (not actually in use yet).""
This reverts commit 3ed4781ee1bd5af9b3ee2623e5356e86ce36e812. Bug: skia: Change-Id: If0de7ca17c4da8000d3526a73b71be6ee34ce060 Reviewed-on: https://skia-review.googlesource.com/43561 Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/lex/DFA.h')
-rw-r--r--src/sksl/lex/DFA.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/sksl/lex/DFA.h b/src/sksl/lex/DFA.h
new file mode 100644
index 0000000000..51e85ca2f8
--- /dev/null
+++ b/src/sksl/lex/DFA.h
@@ -0,0 +1,32 @@
+/*
+ * 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<std::vector<int>> transitions, std::vector<int> accepts)
+ : fTransitions(transitions)
+ , fAccepts(accepts) {}
+
+ static constexpr char END_CHAR = 126;
+
+ // one row per character, 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