summaryrefslogtreecommitdiff
path: root/mesonbuild/mparser.py
Commit message (Collapse)AuthorAgeFilesLines
* typing: fix code reviewDaniel Mensinger2020-09-081-1/+1
|
* typing: fully annotate mparser.pyDaniel Mensinger2020-09-081-14/+25
|
* ast: Add AST JSON printerDaniel Mensinger2020-05-231-7/+5
|
* mparser: fix precedence of arithmetic operatorsAndrei Alexeyev2020-04-041-27/+33
| | | | | | | | | | | | | | | | | | The arithmetic operators are now split into two groups: * The add/sub group: +, - * The mul/div group: *, /, % All operators within the same group are left-associative and have equal precedence. The mul/div group has a higher precedence than the add/sub group, as one would expect. Previously every operator had a different precedence and was right-associative, which resulted in surprising behavior. This is a potentially breaking change for projects that relied on the old incorrect behavior. Fixes #6870
* types: Remove redundant __init__() -> None annotationDaniel Mensinger2020-03-021-26/+26
|
* types: Use import typing as TDaniel Mensinger2020-03-021-20/+19
|
* review: Initial fixupDaniel Mensinger2020-03-021-28/+31
|
* types: Annotate the AST visitorsDaniel Mensinger2020-03-021-0/+5
|
* types: Annotate mparser.pyDaniel Mensinger2020-03-021-233/+219
| | | | | | This also fixes that the keys in ArgumentNode.kwargs are all of the type BaseNode now. Before this commit, it was possible that both strings and Nodes where used as keys.
* Rename 'subdir' -> 'filename' in location objectsJon Turney2020-02-281-35/+35
|
* lgtm: Fix redundant codeDaniel Mensinger2019-12-051-1/+0
|
* dict: Fully evaluate keysXavier Claessens2019-12-041-13/+1
| | | | | The only restriction is keys must be string after evaluation. This fix various inconsistencies.
* mparser.py: actually check the type of key variable, not its valueMarc Herbert2019-12-031-1/+1
| | | | | | | | | | Fixes PR #6166 and more specifically commit 4e460f04f3b2 that tried to make sure the type of a key variable is a string but checked the type of the value instead. Extends test common/228's limited coverage, its only test case had (surprise) a string value. Also avoid reserved python keyword 'dict' and potentially confusing string 'key'. Implements #5231 for real.
* Fixed issue that the key's value type wasn't checked correctly.fchin2019-11-121-3/+4
| | | Added two new failing tests.
* Adding dictionary entry using string variable as key.franczc2019-11-121-8/+12
|
* Fix flake8-bugbear warningsDaniel Mensinger2019-04-291-1/+1
|
* consistent invalid escape sequence behaviourJon Turney2019-04-281-6/+6
| | | | | | | | | | | | | | | * 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
* rewriter: Use mparser to detect the end of some nodesDaniel Mensinger2019-03-031-6/+12
|
* Fix ternary in thing (#5007)Dylan Baker2019-03-021-2/+3
| | | | | | | | | | | | | | | | * 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
* Fixed flake8Daniel Mensinger2019-02-161-1/+1
|
* Can now find the assignment node of a valueDaniel Mensinger2019-02-161-4/+6
|
* pep8 py37Michael Hirsch, Ph.D2019-01-291-1/+1
|
* Fixed line and column numbers for dict and array nodesDaniel Mensinger2019-01-221-8/+8
|
* Basic AST visitor patternDaniel Mensinger2019-01-221-21/+29
|
* parser: Fix line continuation outside of (), [] or {}Xavier Claessens2019-01-051-1/+5
| | | | | | | | 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
* Interpreter: Add 'continue' and 'break' keywordsXavier Claessens2018-10-041-2/+12
| | | | Closes: #3601
* Interpreter: Add "in" and "not in" operatorsXavier Claessens2018-10-041-3/+8
| | | | Closes: #3600
* Warn for future keyword (#3908)Xavier Claessens2018-07-271-0/+5
|
* Add support for octal and binary int literals.Filipe Brandenburger2018-05-231-6/+2
| | | | | | | | | | | | | | 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.
* dict: fix CI issuesMathieu Duponchelle2018-05-211-1/+1
|
* dict: address review commentsMathieu Duponchelle2018-05-201-8/+9
|
* Add new built-in type, dictMathieu Duponchelle2018-05-201-4/+53
| | | | | | 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.
* Remove escaping for triple-quoted stringsNiklas Claesson2018-04-211-16/+0
| | | | Fixes #3429
* Exit meson with an error if an invalid escape sequence is found in aNiklas Claesson2018-04-171-3/+17
| | | | string
* Complete python escape sequences aware stringsTim 'mithro' Ansell2018-04-171-4/+30
| | | | Fixes #3169
* Newlines in single line strings should only be a warning for now.Jussi Pakkanen2018-02-211-1/+2
|
* Fail if singleline string has multiple linesCaio Marcelo de Oliveira Filho2018-02-201-0/+3
|
* Add support for hex int literals.Jussi Pakkanen2018-02-051-0/+4
|
* Report warning/error locations in a format IDEs may already know how to parseJon Turney2018-01-301-1/+1
| | | | | | | | | | | | | | | 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
* Consolidate warning location formatting in mlog.warning()Jon Turney2018-01-011-2/+3
| | | | | Also use .format() rather than % Also use build.environment rather than hardcoding 'meson.build'
* Add filename and lineno to duplicate kwargs warningJon Turney2017-12-301-2/+2
| | | | | | Fixes #1626 Also fix 'a an error' typo
* Fix escaping of newlines in string literalsJoergen Ibsen2017-11-271-4/+4
| | | | | | | Replace '\n' escape sequence before '\\' to allow a literal backslash to be inserted before the character 'n'. Fixes #2682
* Do not permit invalid and/or nodes to be declared. Closes #1886.Jussi Pakkanen2017-06-251-0/+7
|
* Added missing argument to a few function calls. Closes #1647.Jussi Pakkanen2017-04-211-8/+11
|
* Print a warning on duplicated keywords.Jussi Pakkanen2017-04-191-0/+3
|
* Don't crash if a meson.build file is empty (#1570)Aaron Plattner2017-04-071-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Don't crash if a meson.build file is empty Commit 9adef3a8e878 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'
* EmptyNode needs a line/column number too. There are times its lineAaron Small2017-03-251-25/+65
| | | | | | | | | | 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.
* fix logic operationsNicolas Schneider2017-03-231-4/+5
| | | | Closes #1479.
* Better error message when using = rather than : for defining keywords.Jussi Pakkanen2017-01-231-1/+1
|
* cleanup: Replace assignment with augmented assignmentMike Sinkovsky2017-01-181-1/+1
|