Skip to content

Commit

Permalink
Minor edit to regex for variables in lexer to deal with variables better
Browse files Browse the repository at this point in the history
  • Loading branch information
r3 committed Jun 4, 2012
1 parent c287588 commit 6fb3692
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions Lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from collections import namedtuple


example = 'examples/link.flux'
example = 'examples/escape code.flux'


def char_stream(txt):
Expand Down Expand Up @@ -43,7 +43,12 @@ def _extract_occurance(lst, occurance):
the occurances. Matches will be removed from the list. Any
text found prior to matches will be returned as a string.
"""
index = ''.join(lst).find(occurance)
try:
index = ''.join(lst).find(occurance)
except TypeError:
print(lst)
print(occurance)
import sys; sys.exit()
end = index + len(occurance)

# Grab any text prior to match for return later
Expand Down Expand Up @@ -108,7 +113,7 @@ def pprint_token_stream(stream):
",": COMMA,
"=": EQUALS,
"\\\[\S]": ESCAPED,
"%.+(?=(?<!\\\)\ )": VARIABLE,
"%.+(?=(?<!\\\)\s)": VARIABLE,
"\[\[": OPEN_LINK,
"\]\]": CLOSE_LINK}

Expand Down
2 changes: 1 addition & 1 deletion examples/escape code.flux
Original file line number Diff line number Diff line change
@@ -1 +1 @@
\Hi() @template(arg) and a %variable or %v\ ar\ iable should match
\Hi() @template(arg) and a %variable or %v\ ar\ iable

0 comments on commit 6fb3692

Please sign in to comment.