Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: remove include and #include #117

Merged
merged 1 commit into from
Apr 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions src/plcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,12 +925,6 @@ def sem(nxt, stubs,
done()
for line in nxt:
line = line.strip()
if line[:7] == 'include':
# add file names to be processed
fn = line[7:].split()
argv.extend(fn)
# print('== extend argv by {}'.format(fn))
continue
if line == "%":
break
if len(line) == 0 or line[0] == '#':
Expand Down Expand Up @@ -1031,12 +1025,12 @@ def nextLine():
global stack # used for '%include ...' processing
global argv # file arguments
global nlgen # next line generator for Fname
maxStack = 4 # maximum #include stacking level
maxStack = 4 # maximum %include stacking level
stack = []
# debug('...here...')
while True:
if len(stack) > 0:
# pop any #include parent off the stack (stack is initially empty)
# pop any %include parent off the stack (stack is initially empty)
(Fname, Lno, nlgen) = stack.pop()
debug('back to reading from file ' + Fname)
elif len(argv) > 0:
Expand All @@ -1055,15 +1049,15 @@ def nextLine():
Line = Line.rstrip()
debug('[{}]: {}'.format(Fname, Line))
# Line is the next line in this file
# first handle '#include ...' directives
# first handle '%include ...' directives
if lineMode:
pass # don't process #include directives when in line mode
pass # don't process %include directives when in line mode
else:
if Line[:8] in ['#include', '%include']:
if Line[:8] == '%include':
ary = Line.split(None, maxsplit = 1)
if len(ary) == 2 and ary[0] in ['#include', '%include']:
if len(ary) == 2 and ary[0] == '%include':
if len(stack) >= maxStack:
death('max #include nesting depth exceeded')
death('max %include nesting depth exceeded')
debug('include directive: {} {}'
.format(ary[0],ary[1]))
# ary[1] must be a filename
Expand All @@ -1073,7 +1067,7 @@ def nextLine():
nlgen = nextLineGen(Fname)
continue
else:
death(line + ': invalid #include directive')
death(line + ': invalid %include directive')
line = Line.rstrip()
debug('{:4} [{}] {}'.format(Lno,Fname,Line), level=2)
yield line
Expand Down
Loading