* Don't crash if a meson.build file is empty
Commit 9adef3a8e8 caused an empty meson.build file to generate a traceback:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/mesonbuild/mparser.py", line 415, in getsym
self.current = next(self.stream)
StopIteration
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 298, in run
app.generate()
File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 180, in generate
intr.run()
File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 2529, in run
super().run()
File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 125, in run
self.evaluate_codeblock(self.ast, start=1)
File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 146, in evaluate_codeblock
raise e
File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 140, in evaluate_codeblock
self.evaluate_statement(cur)
File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 151, in evaluate_statement
return self.function_call(cur)
File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 372, in function_call
return self.funcs[func_name](node, self.flatten(posargs), kwargs)
File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 47, in wrapped
return f(self, node, args, kwargs)
File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 2237, in func_subdir
self.evaluate_codeblock(codeblock)
File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 146, in evaluate_codeblock
raise e
File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 140, in evaluate_codeblock
self.evaluate_statement(cur)
File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 151, in evaluate_statement
return self.function_call(cur)
File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 372, in function_call
return self.funcs[func_name](node, self.flatten(posargs), kwargs)
File "/usr/lib/python3.6/site-packages/mesonbuild/interpreterbase.py", line 47, in wrapped
return f(self, node, args, kwargs)
File "/usr/lib/python3.6/site-packages/mesonbuild/interpreter.py", line 2233, in func_subdir
codeblock = mparser.Parser(code, self.subdir).parse()
File "/usr/lib/python3.6/site-packages/mesonbuild/mparser.py", line 410, in __init__
self.getsym()
File "/usr/lib/python3.6/site-packages/mesonbuild/mparser.py", line 417, in getsym
self.current = Token('eof', '', self.current.line_start, self.current.lineno, self.current.colno + self.current.bytespan[1] - self.current.bytespan[0], (0, 0), None)
AttributeError: 'Parser' object has no attribute 'current'
and column are printed out by other parser code.
Add a print of the line with the error, and where on the line the error
occurred.
Add a print of where the block scope started, if the error is due to
missing the block scope end token.
Having support for the '%' operator makes it easier to implement
even/odd version checks, like:
enable_debug = get_option('enable-debug')
if enable_debug == 'auto'
if minor_version % 2 == 0
enable_debug = 'minimum'
else
enable_debug = 'yes'
endif
endif
which would be impossible without resorting to less obvious long-hand
forms like:
a - (b * (a / b))
Addition (+), subtraction (-), multiplication (*) and division (/) for numbers
follows the BIDMAS rules.
Strings and arrays can be concatenated with the addition operator
Strings can be concatenated with numbers with the addition operator