File tree Expand file tree Collapse file tree
tests/arch/zx48k/peephole Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111TreeType = list [str | list ["TreeType" ]]
1212
1313COMMENT : Final [str ] = ";;"
14- RE_REGION = re .compile (r"([_a-zA-Z][a-zA-Z0-9]*)[ \t]*{{ " )
14+ RE_REGION = re .compile (r"([_a-zA-Z][a-zA-Z0-9]*)[ \t]*\{\{$ " )
1515RE_DEF = re .compile (r"([_a-zA-Z][a-zA-Z0-9]*)[ \t]*:[ \t]*(.*)" )
1616RE_IFPARSE = re .compile (r'"(""|[^"])*"|[(),]|\b[_a-zA-Z]+\b|[^," \t()]+' )
1717RE_ID = re .compile (r"\b[_a-zA-Z]+\b" )
Original file line number Diff line number Diff line change @@ -355,3 +355,46 @@ def test_in_list(self):
355355 "WITH" : ["pop $1" , "$2" ],
356356 "DEFINE" : [],
357357 }
358+
359+ def test_parse_cond (self ):
360+ result = parser .parse_str (
361+ """
362+ OLEVEL: 1
363+ OFLAG: 14
364+ REPLACE {{
365+ $1
366+ }}
367+
368+ WITH {{
369+ }}
370+
371+ IF {{
372+ $1 == "nop"
373+ }}
374+ """
375+ )
376+ assert result == {
377+ "OLEVEL" : 1 ,
378+ "OFLAG" : 14 ,
379+ "REPLACE" : ["$1" ],
380+ "WITH" : [],
381+ "DEFINE" : [],
382+ "IF" : ["$1" , "==" , "nop" ],
383+ }
384+
385+ def test_parse_if_must_start_in_a_new_line (self ):
386+ result = parser .parse_str (
387+ """
388+ OLEVEL: 1
389+ OFLAG: 14
390+ REPLACE {{
391+ $1
392+ }}
393+
394+ WITH {{
395+ }}
396+ ;; this is not valid
397+ IF {{ $1 == "nop" }}
398+ """
399+ )
400+ assert result is None
You can’t perform that action at this time.
0 commit comments