Skip to content

Commit 43313f5

Browse files
committed
project cleanups
1 parent 140262d commit 43313f5

File tree

6 files changed

+10
-53
lines changed

6 files changed

+10
-53
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
nimcache/
2+
*.exe

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
# lexim
22
Lexer generation and regex implementation for Nim.
3+
4+
# example
5+
Lexim requires a 'lexe' helper exe that is used by 'lexim'.
6+
Compile via ``nim c lexe`` and then you can run the example
7+
via ``nim c ex1.nim``.
File renamed without changes.

ex1.lex

Lines changed: 0 additions & 51 deletions
This file was deleted.

lexim.nim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ proc genMatcher(a: DFA; s, i, bodies: NimNode): NimNode {.compileTime.} =
8686
ifStmt.add newTree(nnkElse, actions)
8787
caseStmt.add newTree(nnkOfBranch, newLit(src), ifStmt)
8888

89+
template `/.`(x: string): string =
90+
(when defined(posix): "./" & x else: x)
91+
8992
macro match*(s: cstring|string; pos: int; sections: untyped): untyped =
9093
var res: seq[string] = @[]
9194
for sec in sections.children:
@@ -97,7 +100,7 @@ macro match*(s: cstring|string; pos: int; sections: untyped): untyped =
97100
error("Expected a node of kind nnkStrLit, got " & $sec[0].kind)
98101

99102
writeFile("lexe.input", $$res)
100-
let o = to[DFA](staticExec("lexe"))
103+
let o = to[DFA](staticExec(/."lexe"))
101104
result = genMatcher(o, s, pos, sections)
102105
#echo repr result
103106

regexprs.nim

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ type
3939
cc*: ref set[char]
4040
rule*: int # if >= 0 it is a final state;
4141
# then it is the rule that was matched
42-
# also misused for captures and backrefs!
4342

4443
RegexError* = object of ValueError
4544
RegexFlag* = enum ## how regexes are parsed

0 commit comments

Comments
 (0)