Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't comment out stuff if the # is inside a quoted string

  • Loading branch information...
commit 466e57382192050e264ab4aa617cb799da3907a8 1 parent 6f6e960
@davidcox authored
View
2  examples/mw_test_syntax_advanced.mw
@@ -15,7 +15,7 @@ block['blah0']{
}
# Stimuli
-stimulus["blah", type="image_stimulus"]
+stimulus["blah", type="image_stimulus", blah="#blah"]
# test of alt syntax
stimulus blah2[type='image_stimulus']
View
3  mwx/constants.py
@@ -7,7 +7,8 @@
noncontainer_types = ['stimulus',
'variable',
- 'selection_variable']
+ 'selection_variable',
+ 'channel']
class MWProperty(object):
View
6 mwx/parser.py
@@ -173,7 +173,7 @@ def quoted_string_fn(drop_quotes=True):
float_number.setParseAction(lambda x: float(x.str))
time_unit = Literal("ms") | Literal("us") | Literal("s") | Literal("min")
duration = Combine(integer_number + time_unit)
- identifier = Word(alphanums + '_')
+ identifier = Word(alphanums + '_' + '#')
function_call = identifier("name") + arg_list_open + Group(delimitedList(expression))("args") + arg_list_close
def function_call_helper(n, a):
@@ -421,7 +421,9 @@ def alias_parse_action(x):
# ------------------------------
comment_regex = r"(//|#).*?$" # accept either shell or c++ style comments
- self.comment_parser = Suppress(Regex(comment_regex, re.MULTILINE | re.DOTALL))
+ self.comment_parser = (QuotedString('"', unquoteResults=False) |
+ QuotedString("'", unquoteResults=False) |
+ Suppress(Regex(comment_regex, re.MULTILINE | re.DOTALL)))
def parse_string(self, s, process_templates=True):
"""Process a string containing valid MWX content, and return a tree of
Please sign in to comment.
Something went wrong with that request. Please try again.