Commit Graph

52 Commits

Author SHA1 Message Date
Peter Lesslie d771fc7d0b Add support for multiline f-strings
+ Extend the parser to recognize the multiline f-strings, which the
documentation already implies will work.

The syntax is like:
```
x = 'hello'
y = 'world'

msg = f'''This is a multiline string.

Sending a message: '@x@ @y@'
'''
```

which produces:
```
This is a multiline string.

Sending a message: 'hello world'

```

+ Added some f-string tests cases to "62 string arithmetic" to exercise
the new behavior.
2022-05-01 12:47:37 -04:00
Peter Lesslie ab5ed4db09 Add note in docs that multiline f-strings are not supported
Companion to https://github.com/mesonbuild/meson/pull/10284
2022-04-15 11:08:22 -04:00
Daniel Mensinger 0808ae1b3d docs: Document argument flattening 2022-04-07 17:16:26 -04:00
Christian Clauss a5020857f3 Fix typos discovered by codespell 2021-10-10 16:12:25 -04:00
Daniel Mensinger 2327cb5eb3
docs: Fix broken links 2021-10-03 12:19:45 +02:00
Daniel Mensinger c10e228371
docs: Fixes found during the YAML conversion process 2021-10-03 11:51:37 +02:00
Stone Tickle fbc2e9b0ef doc: document string.strip() optional argument [skip ci] 2021-09-30 00:27:48 +03:00
Daniel Mensinger 6b00c7dc81 Remove helpers.check_stringlist() 2021-09-25 12:44:11 +02:00
jimman2003 10151d8738
Make assignment a statement in Syntax.md (#9188) [skip-ci]
* Make assignment a statement in Syntax

force to change line 709 to something kind of non sensical

* Applied code review changes
2021-08-31 08:57:03 -07:00
Alexander Lyashuk cdc6c866ca
doc: update syntax description of immutability
"Stored by value" is more correct way to explain that example.

Mutable vs immutable means that you cannot mutate the value (e.g. list vs tuple in Python), and the example shows that `var2` is actually mutable.

Copying/storing a reference vs value is what what matters in the assignment, in Python `a=b` means `a` and `b` are references to the same list, while in meson `a=b` copies the value of `b` into `a`.
2021-04-28 00:39:56 -04:00
Simon Ser 974e49fe0e docs: document bool to_int and to_string methods
This documents the bool methods to_int and to_string implemented in
[1].

[1]: a9e9b7c750/mesonbuild/interpreterbase.py (L1109)
2021-04-06 08:15:03 -04:00
Laurin-Luis Lehning f7dd111333 Some documentation language adjustments & improved error messages 2021-03-10 08:55:22 -05:00
Laurin-Luis Lehning aa71452f1a Yet another documentation update 2021-03-10 08:55:22 -05:00
Laurin-Luis Lehning 3739780b0e Add syntax documentation with tentative version target 2021-03-10 08:55:22 -05:00
Tristan Partin c83106ee38 Add str.replace() method 2021-03-09 06:27:58 -05:00
Jussi Pakkanen f72ee8e742 Rewrap long text lines in docs. [skip ci] 2021-01-30 16:19:59 +00:00
Evgeny Ermakov a24546d7da docs: Fix typo in Syntax.md [skip ci] 2021-01-23 17:25:51 +00:00
Danilo Spinella e7009d439c Syntax.md: Fix variable used in substring example 2020-10-22 08:47:24 -04:00
Nirbheek Chauhan 94ea9d97be docs: Clarify what literal strings mean [skip ci]
Someone on IRC was confused by this paragraph.
2020-09-21 15:36:24 +05:30
Stéphane Cerveau 8f106a2b9a string: add substring method
This method aims to offer a simple way to 'substring'
an existing string with start and end values.
2020-07-20 20:04:01 -04:00
Michael Hirsch, Ph.D b9b15816e8 syntax.md: document version_compare ambiguities [skip ci] 2020-06-28 23:54:16 +03:00
Michael Hirsch, Ph.D 1e140c002b syntax.md: correct markdown heading syntax [skip ci] 2020-06-28 23:54:16 +03:00
Nirbheek Chauhan 83df219747 docs: Document string path building with examples
Also document that line continuation didn't work before 0.50.

90c9b868b2 fixed it.
2020-06-24 16:56:54 +00:00
Flow-It a124624c0e
Document formal Meson grammar [skip ci]
* WIP: Document formal Meson grammar

* Various little fixes [skip ci]

1) Add missing logical_not_expr
2) 'in' and 'not in' are valid relational operators at least for dicts
3) dictionary keys can be expressions, but kwarg names cannot
4) typo logical_end_expression -> logical_and_expression
5) Make jump statements only allowed inside an iteration statement

* Rework EBNF style [skip ci]

As there is no good order for the productions, just go alphabetically.
The EBNF style was changed to match the one the Python lark project
uses, that is colons for productions and terminals enclosed in double
quotes.

* Add missing production for unary operators [skip ci]

* Add production for multiline strings [skip ci]

* Properly define terminal symbols [skip ci]

Depending on the EBNF flavor, regex can be used to describe the terminal
symbols. Lark allows this, and as it was mentioned as a possible user of
this grammar, let's follow its flavor here. Most regexes used are easily
human-readable, and we can always add comments to more complicated ones.

* Small changes to which expressions can be used where [skip ci]

Let the grammar be very general. The type system then has to check, that
the used expression really evaluates to the correct type. Even if we
know today that assignment expressions always evaluate to None (and can
therefore only be used as a toplevel expression in an expression
statement), this needn't be the case forever. So this way, the grammar
stays stable even if such changes were made.

* Rework function argument list production [skip ci]

* Be more verbose for production names [skip ci]

Rename expr -> expression, stmt -> statement, op -> operator, program ->
build_definition. Also adjust some list productions.

* Add paragraph about syntax stability promises [skip ci]
2020-05-01 22:02:17 +03:00
Xavier Claessens 9b1a857473 dict: Fully evaluate keys
The only restriction is keys must be string after evaluation. This fix
various inconsistencies.
2019-12-04 16:45:56 -05:00
Nirbheek Chauhan 53830038ac
docs/syntax: fix typo in dict example [skip ci] 2019-09-03 17:50:39 +05:30
Nirbheek Chauhan 41b0fae0a9
docs/syntax: Document that dicts are unordered [skip ci] 2019-09-03 17:48:08 +05:30
Michael Hirsch, Ph.D b90b69d383 note that integers have .to_string() method [skip ci] 2019-07-26 11:57:47 +03:00
Michael Hirsch, Ph.D 44b6ccbe56 join_paths => / [skip ci] 2019-05-22 23:56:50 +03:00
Jon Turney 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
Dylan Baker 05fc81ac35 docs: Add warning about not using join_paths() with build targets [skip ci]
This comes up now and again when people try do do something like:

meson.build:
```meson
my_sources = ['foo.c']
subdir('subdir')
executable('foo', my_sources)
```
subdir/meson.build:
```meson
my_sources += ['bar.c']
```
2018-12-19 01:25:17 +02:00
Jussi Pakkanen 58b838a80b Can specify keyword arguments with a dict. 2018-12-04 23:44:17 +02:00
Xavier Claessens b6fc063b13 Add documentation and release notes for 'in', 'continue' and 'break' 2018-10-04 20:18:56 -04:00
Bruce Richardson 62d92e3a19 syntax guide: move logical ops section beside if statement [skip ci]
The "if" statement only covers a small set of the possible ways in
which conditionals can be written, since it leaves the use of
"and", "or" and "not" to the "Logical Operations" section. However,
this is likely to be of interest to those reading about "if" statments,
so move the "logical operations" section up to immediately follow it.
This change also puts in the use of the "!=" operator in the example
to widen the variety of combinations shown.
2018-09-20 08:13:08 -07:00
Yudi Matsuzake 4ee07dd165 docs: Fix dictionary syntax [skip ci] 2018-06-06 18:18:23 +00:00
Filipe Brandenburger 5572bbc6cc Document octal and binary integer literals in syntax.
Also add a release notes snippet for it.
2018-05-23 14:07:56 -07:00
Mathieu Duponchelle fe6fc59ee7 dict: add since annotations 2018-05-22 00:17:42 +02:00
Mathieu Duponchelle 1de7dce414 dict: Document, add release snippet 2018-05-20 22:39:33 +02:00
Nirbheek Chauhan a5b99dce5d Add more tests for multi-line strings and update docs 2018-04-21 22:57:19 +03:00
Tim 'mithro' Ansell 36aab0f4b2 Complete python escape sequences aware strings
Fixes #3169
2018-04-17 09:55:34 +00:00
Jussi Pakkanen a288b524bc Add support for hex int literals. 2018-02-05 22:33:48 +02:00
Lucas Werkmeister 5d9c72630a Fix literal backslash syntax
In CommonMark, there are no backslash escapes in code spans, so only two backslashes in the source document are necessary to produce two backslashes in the output document.
2017-11-19 18:16:35 +02:00
Jussi Pakkanen d2aa2f569b Cleanupping. 2017-11-11 20:12:43 +02:00
Jonas Platte e43332318b Fix invalid example in Syntax.md 2017-10-23 18:42:16 +02:00
Bruce Richardson bc3327ae6e doc: describe joining strings using the + symbol 2017-07-31 12:00:16 -04:00
Nirbheek Chauhan d5fc10fbd8 Fix wording about array immutability 2017-07-24 21:52:16 +00:00
Nirbheek Chauhan 8dd1d6d646 Clarify array immutability and document indexing 2017-07-24 21:50:09 +00:00
Tim Hutt b6dbb4ecc6 Improve user-defined function wording & link to FAQ 2017-06-07 20:03:14 +03:00
Tim 0e027c9616 Document that user-defined functions and methods are unsupported
Fixes #1870
2017-06-07 20:03:14 +03:00
Tim b54e1d29fe Add a note about multi-line statements by ending the line with \ 2017-06-03 21:30:30 +03:00