Commit Graph

51 Commits

Author SHA1 Message Date
2b5831f94f Fix flake8-bugbear warnings 2019-04-29 12:22:50 +02:00
ccc4ce28cc consistent invalid escape sequence behaviour
* docs: document unrecognized escape sequence behaviour [skip ci]

Document that unrecognized escape sequence behaviour is like python, not
C.

* Don't try to decode invalid hex escape sequences

Don't try to decode escape sequences which should contain a sequence of
hex digits, but don't, throwing a python exception.  These will treated
literally instead.

* Extend test case to cover invalid escape sequences
2019-04-28 23:06:36 +03:00
5a22bb7901 rewriter: Use mparser to detect the end of some nodes 2019-03-03 13:57:25 +02:00
841da29d2c Fix ternary in thing (#5007)
* tests: extend ternary test to cover bugs

See issues #5003, #3690, and #2404

* mparser: store subdir in ternary node

Ternaries don't really need subdirs, but they can be passed into
functions that expect the type they're provided to have a
subdir. Provide it to fulful the interface.

Fixes #5003
Fixes #3690
Fixes #2404
2019-03-02 12:57:24 +02:00
4b7b5a7185 Fixed flake8 2019-02-16 14:17:02 +01:00
24a2cf02e2 Can now find the assignment node of a value 2019-02-16 14:10:08 +01:00
da34bea893 pep8 py37 2019-01-29 22:06:11 +02:00
e089eb7665 Fixed line and column numbers for dict and array nodes 2019-01-22 16:41:25 +01:00
ccad493e85 Basic AST visitor pattern 2019-01-22 16:09:34 +01:00
90c9b868b2 parser: Fix line continuation outside of (), [] or {}
The documentation states: "In other cases you can get multi-line
statements by ending the line with a \." but that seems to never have
worked.

Closes: #4720
2019-01-05 21:45:37 +02:00
a816e1c1fa Interpreter: Add 'continue' and 'break' keywords
Closes: #3601
2018-10-04 20:14:37 -04:00
fa2e096aa0 Interpreter: Add "in" and "not in" operators
Closes: #3600
2018-10-04 20:14:37 -04:00
e7dcf5cf16 Warn for future keyword (#3908) 2018-07-27 14:31:54 +03:00
86d2f57e86 Add support for octal and binary int literals.
Simplify support for alternate bases using int(..., base=0) which
auto-detects it using the standard Python syntax for numbers.

Octal numbers are useful to specify permission bits and umasks.

Binary numbers are not super useful... But considering we get them for
free, let's allow them here too.

v2: Tweak the regex so it doesn't accept a decimal number with a leading
zero, which is invalid for int(..., base=0) and would raise a ValueError
if passed around.
2018-05-23 14:07:38 -07:00
10e7566ed8 dict: fix CI issues 2018-05-21 00:19:31 +02:00
195c356f91 dict: address review comments 2018-05-20 22:36:18 +02:00
ecb8838082 Add new built-in type, dict
For now dicts are immutable, and do not expose any methods,
they however support "native" syntax such as [] lookup,
and foreach iterating, and can be printed.
2018-05-20 21:19:44 +02:00
cb0960a91e Remove escaping for triple-quoted strings
Fixes #3429
2018-04-21 22:57:19 +03:00
348248f0a1 Exit meson with an error if an invalid escape sequence is found in a
string
2018-04-17 09:55:34 +00:00
36aab0f4b2 Complete python escape sequences aware strings
Fixes #3169
2018-04-17 09:55:34 +00:00
d0f2f0ad3b Newlines in single line strings should only be a warning for now. 2018-02-21 19:09:35 +02:00
37b702e9aa Fail if singleline string has multiple lines 2018-02-20 00:20:58 +02:00
a288b524bc Add support for hex int literals. 2018-02-05 22:33:48 +02:00
6a1a56ab57 Report warning/error locations in a format IDEs may already know how to parse
Examples:

meson.build:2:0: ERROR: Dependency is both required and not-found
meson.build:4: WARNING: Keyword argument "link_with" defined multiple times.

These are already matched by the default compilation-error-regexp-alist in
emacs.

Also:
Don't start 'red' markup until after the \n before an error
Unabsorb full-stop at end of warning with location from mlog.warning()
Update warning_location test
2018-01-30 06:48:22 +11:00
2ed875e1b4 Consolidate warning location formatting in mlog.warning()
Also use .format() rather than %
Also use build.environment rather than hardcoding 'meson.build'
2018-01-01 13:20:55 +00:00
3c75ae9ced Add filename and lineno to duplicate kwargs warning
Fixes #1626

Also fix 'a an error' typo
2017-12-30 19:32:54 +00:00
b9a0589067 Fix escaping of newlines in string literals
Replace '\n' escape sequence before '\\' to allow a literal backslash
to be inserted before the character 'n'.

Fixes #2682
2017-11-27 21:23:32 +02:00
506cc57cc8 Do not permit invalid and/or nodes to be declared. Closes #1886. 2017-06-25 21:43:38 +03:00
6c500fd9db Added missing argument to a few function calls. Closes #1647. 2017-04-21 13:01:19 +03:00
4588b91096 Print a warning on duplicated keywords. 2017-04-19 16:13:25 +03:00
c80ca384b2 Don't crash if a meson.build file is empty (#1570)
* 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'
2017-04-07 00:10:48 +03:00
9adef3a8e8 EmptyNode needs a line/column number too. There are times its line
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.
2017-03-25 19:08:35 +02:00
1efab9b5a9 fix logic operations
Closes #1479.
2017-03-23 15:40:00 -04:00
8ec9b0a71f Better error message when using = rather than : for defining keywords. 2017-01-23 22:02:37 +02:00
c9423cc3a8 cleanup: Replace assignment with augmented assignment 2017-01-18 21:22:47 +02:00
969be1f679 cleanup: Remove redundant parentheses 2017-01-18 21:22:47 +02:00
22eed4c417 cleanup: Redundant character escape 2017-01-18 21:22:47 +02:00
5b626ab4cb style: [E1**] Indentation 2017-01-11 12:33:27 -05:00
f0bc5568a7 style: fix E703 violations
E703: statement ends with a semicolon

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
5693758e46 style: fix E231 violations
E231: missing whitespace after ','

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
2017d8578a style: fix E226 violations
E226: missing whitespace around arithmetic operator

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
f0b30baa39 style: fix E225 violations
E225: missing whitespace around operator

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
14ca7d602c Store subdir information for each node so we can remove files set in other subdirectories. 2016-12-04 18:28:25 +02:00
f111a0b826 Track comma spans in arguments. 2016-11-20 03:11:58 +02:00
8734013690 I can haz source files added to targets. 2016-11-20 01:48:26 +02:00
00e5962aaa Add support to integer modulo operator
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))
2016-09-02 18:52:45 +01:00
b382abdd2c Forbid nested ternary operations. 2016-08-01 20:49:30 +03:00
d90fcb4048 Created ternary operator. Closes #538. 2016-08-01 20:46:40 +03:00
336904b553 Move MesonException from coredata to mesonlib. 2016-04-01 00:52:45 +03:00
4cd671e69e More comparison operators. Closes #363. 2016-01-25 22:12:40 +02:00