summaryrefslogtreecommitdiffstats
path: root/third_party/rust/jsparagus-stencil/src/regexp.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/jsparagus-stencil/src/regexp.rs
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/jsparagus-stencil/src/regexp.rs')
-rw-r--r--third_party/rust/jsparagus-stencil/src/regexp.rs54
1 files changed, 54 insertions, 0 deletions
diff --git a/third_party/rust/jsparagus-stencil/src/regexp.rs b/third_party/rust/jsparagus-stencil/src/regexp.rs
new file mode 100644
index 0000000000..47356b1fd3
--- /dev/null
+++ b/third_party/rust/jsparagus-stencil/src/regexp.rs
@@ -0,0 +1,54 @@
+use ast::source_slice_list::SourceSliceIndex;
+
+#[derive(Debug)]
+pub struct RegExpItem {
+ pub pattern: SourceSliceIndex,
+ pub global: bool,
+ pub ignore_case: bool,
+ pub multi_line: bool,
+ pub dot_all: bool,
+ pub sticky: bool,
+ pub unicode: bool,
+}
+
+/// Index into RegExpList.atoms.
+#[derive(Debug, Clone, Copy)]
+pub struct RegExpIndex {
+ index: usize,
+}
+
+impl RegExpIndex {
+ fn new(index: usize) -> Self {
+ Self { index }
+ }
+}
+
+impl From<RegExpIndex> for usize {
+ fn from(index: RegExpIndex) -> usize {
+ index.index
+ }
+}
+
+/// List of RegExp.
+#[derive(Debug)]
+pub struct RegExpList {
+ items: Vec<RegExpItem>,
+}
+
+impl RegExpList {
+ pub fn new() -> Self {
+ Self { items: Vec::new() }
+ }
+
+ pub fn push(&mut self, item: RegExpItem) -> RegExpIndex {
+ let index = self.items.len();
+ self.items.push(item);
+ RegExpIndex::new(index)
+ }
+}
+
+impl From<RegExpList> for Vec<RegExpItem> {
+ fn from(list: RegExpList) -> Vec<RegExpItem> {
+ list.items
+ }
+}