Skip to content

Commit cfd5755

Browse files
committed
Switch syntax checking on and off via specific comments.
1 parent 0ce669d commit cfd5755

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

syntax/check.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ def check_file(code_file, syntax_file, verbose):
123123
stack = []
124124

125125
state = State.CODE
126+
enabled = True
126127

127128
# parse line by line
128129
while True:
@@ -132,6 +133,20 @@ def check_file(code_file, syntax_file, verbose):
132133
break
133134
line = line.strip()
134135

136+
# identify comments that enable/disable syntax checking
137+
if line.startswith("//"):
138+
if line[2:].strip() == "opdi-syntax-on":
139+
print_status("enable syntax checking", line_no, line, verbose)
140+
enabled = True
141+
continue
142+
if line[2:].strip() == "opdi-syntax-off":
143+
print_status("disable syntax checking", line_no, line, verbose)
144+
enabled = False
145+
continue
146+
147+
if not enabled:
148+
continue
149+
135150
# eliminate /* */ comments within this line
136151
begin = line.find("/*")
137152
while begin != -1 and line.find("*/", begin) != -1:

0 commit comments

Comments
 (0)