Skip to content

Commit

Permalink
added #error directive
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent Pinson committed Apr 22, 2022
1 parent 2d05991 commit a7d0f16
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pypreprocessor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,12 @@ def lexer(self, line):
print('Warning trying to remove more blocks than present',
self.input, self.__linenum)

elif self.__is_directive(line, 'error'):
if self.__validate_ifs():
print('File: "' + self.input + '", line ' + str(self.__linenum + 1))
print('Error directive reached')
sys.exit(1)

else:
# escapechar + space ==> comment
# starts with #!/ ==> shebang
Expand Down
2 changes: 1 addition & 1 deletion pypreprocessor/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
p=preprocessor(inFile=args.input, defines=args.define, mode=None, removeMeta=args.removeMeta, escapeChar=None,
run=args.run, resume=False, save=True, overload=args.overload, quiet=args.quiet)
if args.output:
p.define = args.output
p.output = args.output
if args.escape:
p.escape = args.escape

Expand Down

0 comments on commit a7d0f16

Please sign in to comment.