Permalink
Browse files

cleaning things up after a few months...

  • Loading branch information...
1 parent f630cd5 commit 69da7dec5910c5d6948fb19395a131971a83a9da Alok Menghrajani committed May 3, 2012
Showing with 48 additions and 10 deletions.
  1. +31 −0 Makefile
  2. +6 −2 README.md
  3. +11 −8 riskybird_eval.opa
View
31 Makefile
@@ -0,0 +1,31 @@
+
+OPA=opa --parser js-like
+OPAPLUGIN=opa-plugin-builder
+
+SRC= \
+ riskybird_eval.opa \
+ riskybird_lint.opa \
+ riskybird_parser.opa \
+ riskybird_string_printer.opa \
+ riskybird_xhtml_printer.opa \
+ riskybird.opa
+
+BINDINGS= \
+ riskybird_binding.js
+
+BINDINGS_OBJ=$(BINDINGS:.js=.opp)
+
+default: run
+
+run: riskybird.exe
+ ./riskybird.exe
+
+riskybird.exe: $(BINDINGS_OBJ) $(SRC)
+ opa --parser js-like -o riskybird.exe *.op?
+
+clean:
+ rm -Rf *~ *.exe *.log _build/ *.opp
+
+
+%.opp: %.js
+ $(OPAPLUGIN) -o $(@:.opp=) $<
View
8 README.md
@@ -4,8 +4,9 @@ RiskyBird
---------
**Regular expression authors best friend**
-Introduction
-------------
+
+Overview
+--------
Regular Expressions are notoriously hard to get right. When you are writing a new expression, it
is hard for reviewers to read & assert with confidence that the expression is correct. Tweaking
existing expressions can often lead to unintended consequences.
@@ -19,6 +20,9 @@ RiskyBird tries to mitigate this by offering a set of tools for software enginee
5. A collaboration platform: reviewers can add tests and provide feedback.
+This project also provides a reusable regular expression parser.
+
+
Why RiskyBird
-------------
We love AngryBirds and we wanted a name that starts with R.
View
19 riskybird_eval.opa
@@ -64,6 +64,7 @@ function option(candidate) consume_group(int n, candidate cand) {
}
+/*
function candidates core_regexp(core_regexp re, candidates cands) {
match(re) {
case {nil}:
@@ -72,6 +73,7 @@ function candidates core_regexp(core_regexp re, candidates cands) {
List.append(simple(hd, cands), core_regexp(tl, cands))
}
}
+*/
function candidates simple(simple re, candidates cands) {
match(re) {
@@ -135,7 +137,7 @@ function candidate pop_matched(candidate cand) {
matched: tl,
groups: IntMap.add(cand.grp, List.rev(hd), cand.groups)
}
- }
+ }
}
function candidates elementary(elementary elt, candidates cands) {
@@ -150,7 +152,7 @@ function candidates elementary(elementary elt, candidates cands) {
map_candidates(consume(escaped_char, _), cands)
case { egroup: re }:
cands = List.map(push_matched, cands)
- cands = core_regexp(re, cands)
+// cands = core_regexp(re, cands)
cands = List.map(pop_matched, cands)
cands
case _ /* TODO */: []
@@ -167,12 +169,13 @@ function test(f2, f1) {
match(re) {
case {none}: false
case {some: x}:
- re = x.core
- sl = String.fold(List.cons, s, [])
- sl = List.rev(sl)
- st = [{grp: 1, matched:[[]], rest:sl, groups:IntMap_empty}]
- res = core_regexp(re, st)
- List.exists(function(x){ x.rest == {nil}}, res)
+// re = x.core
+// sl = String.fold(List.cons, s, [])
+// sl = List.rev(sl)
+// st = [{grp: 1, matched:[[]], rest:sl, groups:IntMap_empty}]
+// res = core_regexp(re, st)
+// List.exists(function(x){ x.rest == {nil}}, res)
+ false
}
}

0 comments on commit 69da7de

Please sign in to comment.