Skip to content

Commit

Permalink
Charseq -> match object.
Browse files Browse the repository at this point in the history
  • Loading branch information
rickardlindberg committed May 4, 2020
1 parent fab5272 commit 2bdd81f
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 203 deletions.
2 changes: 2 additions & 0 deletions writing/rlmeta-vm-poster/README.md
Expand Up @@ -55,3 +55,5 @@ Diff from memoizing:
* Let compile.sh do error reporting (support only gives information)
* Compact and modify formatting to better suit poster
* Only one semantic action class
* charseq -> and + match object
* Remove string matching
3 changes: 1 addition & 2 deletions writing/rlmeta-vm-poster/codegenerator.rlmeta
Expand Up @@ -40,8 +40,7 @@ CodeGenerator {
SemanticAction = ast:x -> { "I('ACTION', lambda scope: " x ")\n" }
MatchRule = py:x -> { "I('CALL', " x ")\n" }
MatchRange = py:x py:y -> { "I('MATCH_RANGE', " x ", " y ")\n" }
MatchString = py:x -> { "I('MATCH_STRING', " x ")\n" }
MatchCharseq = py:x -> { "I('MATCH_CHARSEQ', " x ")\n" }
MatchObject = py:x -> { "I('MATCH_OBJECT', " x ")\n" }
MatchAny = -> { "I('MATCH_ANY')\n" }
MatchList = ast:x -> { "I('PUSH_STREAM')\n"
x
Expand Down
6 changes: 3 additions & 3 deletions writing/rlmeta-vm-poster/parser.rlmeta
Expand Up @@ -22,8 +22,7 @@ Parser {
| space '->' hostExpr:x -> ["SemanticAction" x]
| name:x !(space '=') -> ["MatchRule" x]
| space char:x '-' char:y -> ["MatchRange" x y]
| space string:x -> ["MatchString" x]
| space charseq:x -> ["MatchCharseq" x]
| space charseq
| space '.' -> ["MatchAny"]
| space '(' choice:x space ')' -> x
| space '[' expr*:xs space ']' -> ["MatchList" ["And" ~xs]]
Expand All @@ -38,8 +37,9 @@ Parser {
formatExpr =
| space '>' formatExpr*:xs space '<' -> ["Indent" ["Format" ~xs]]
| hostExpr
charseq = '\'' (!'\'' matchChar)*:xs '\'' -> ["And" ~xs]
matchChar = innerChar:x -> ["MatchObject" x]
string = '"' (!'"' innerChar)*:xs '"' -> { xs }
charseq = '\'' (!'\'' innerChar)*:xs '\'' -> { xs }
char = '\'' !'\'' innerChar :x '\'' -> x
innerChar = '\\' escape | .
escape = '\\' -> "\\" | '\'' -> "'"
Expand Down

0 comments on commit 2bdd81f

Please sign in to comment.