122 Commits

Author SHA1 Message Date
paulpatault
2cc29e8963 Micro Python : syntax improvements & added functions
- added break and continue
- added range with one, two or three argument(s)
- added slice (`list[i1:i2]`)
- added negative index (`list[n], with -len(list) ≤ n < len(list)`)
- added lists methods:
  - `list.append(n)`
  - `list.pop()`
  - `list.clear()`
  - `list.sort()`
  - `list.reverse()`
- added `is_permutation(list1, list2)` predicate
- added assignment operators `+=`, `-=`, `*=`, `//=`, `%=`
- functions can now return `bool` and `list`
2021-06-24 11:44:07 +02:00
Guillaume Melquiond
1fc6be8459 Update headers. 2021-03-13 07:55:14 +01:00
Jean-Christophe Filliatre
b8719248ef micro-Python: fixed parser when no newline at end of file 2020-10-08 17:51:53 +02:00
Jean-Christophe Filliatre
cff973030c micro-C/Python: fixed translation of <> and not 2020-06-24 22:19:17 +02:00
Guillaume Melquiond
0070b9408d Update headers. 2020-03-17 09:52:33 +01:00
Sylvain Dailler
f3931e641f external printers: propagate protect_on in pretty 2019-12-06 10:31:55 +01:00
Sylvain Dailler
627275d19b ada_terms: Add task printer, transformation with args parser for Ada
This is inspired from the python printer/parser, the changes are:
- and, or, and then, or else are now supported instead of /\, \/, &&, ||
- different (LTGT) is now '/=' instead of '<>'
- allowing A'Last, A'First using "name" attributes
- allowing the notation "for all i in A .. B => stuff"
- allowing syntax for arrays as A(I) using new attributes "syntax" (also
  the reason why we need to pass a name table to the parser)
- some constants are printed as "(cst:type)" (This is not real Ada syntax
and should probably be replaced by "type'(cst)"

This also adds a test at tests/ada_terms/print_test.adb

This adds new cases in any_pp: note that all these cases are needed as we
cannot use the legacyprinter for calls to, for instance, print_ls.
This would have the disadvantage that, when printed twice (reload), idents
gets reprinted which would change their disambiguation number (break at
every reload).

Also, pass the task to the printer in order to be able to detect which
lsymbols are used in record fields definitions.

Parser edition with respect to the Why3 parser:
- Removing qualification (not usable in transformation anyway)
- QUOTE disallowed in ident: still allowing it for type variable
- the ada parser uses a naming table during the parsing phase. The naming
table does not influence the parsing but is used to generate different
trees depending on the names recognized. It is useful to distinct a
function from an array in application as the syntax is the same.

Note that the naming_table is passed with a reference: we may want to
improve this in the future (no other known solution to the author of this
message).

New attributes appears:
- [@syntax:array:] followed by name of the getter function to be used:
this is used to know which function should be used as getter for this type
during the parsing.
- [@syntax:getter:] followed by its own name: this is used to know during
the printing if the function should be removed from the display to
simplify the notation. The name is checked in case attributes of a
specific ident are derived or copied to another one.

Add README with some changes in to be changed syntax
2019-11-25 11:57:11 +01:00
Cláudio Belo Lourenço
83b02e04ac Merge branch 'master' into 28-string-literals 2019-10-21 15:05:46 +02:00
Jean-Christophe Filliatre
572064dfb8 Python plugin: minor change 2019-10-04 15:51:18 +02:00
Sylvain
974ef24c68 Merge branch 'external_printer'
This is a proof of concept of the external printing/parsing. This works by
adding externally defined (from Pretty) elements to the standard
printing/parsing. We use the example of the Python plugin to show how it
works:

- the tasks should contain new notations (example python: /\ replaced by "and")
- the new notations can be used in the transformations (example python:
  "assert (0 == 0 and b > 1)"

The file format contained in the session is used to decide which external
parser/printer to use. These are registered in a similar way that language,
parser, or transformations are registered. For example, a goal whose ancestor
is a python file (according to the file format inside the session) will be
printed with the Python external printer; and transformations originating
from this goal will be parsed with the same language.
2019-10-03 10:48:31 +02:00
Sylvain
6da047f744 external printer python: replace /\ \/ with and/or in tasks 2019-09-26 15:23:34 +02:00
Sylvain
c454feef96 external printer: fix nim.py 2019-09-25 17:48:44 +02:00
Sylvain
c05e74efef external printer: add "!=" 2019-09-25 17:39:52 +02:00
Sylvain
212ea87ccd external python printer: fix parenthesis 2019-09-25 17:29:43 +02:00
Sylvain
cb1e8f28c6 external python printer/parser: div -> // and mod -> % 2019-09-25 17:23:49 +02:00
Sylvain
d47ea7b5b0 external_printer: protect priority and fix indentation 2019-09-25 16:32:30 +02:00
Sylvain
1259ec07c8 external printer/parser: task printer/parser depends of the language
An external printer/argument parser can now be registered. This changes
args_wrapper and Trans so that transformation now takes the Env.fformat
representing the language as argument.
Function lang of session_itp now uses file_format.
2019-09-25 16:32:30 +02:00
Sylvain
ea286888a6 External printer/parser: proof of concept on python plugin 2019-09-25 16:31:23 +02:00
Cláudio Belo Lourenço
372ec5a396 All constant literals under the same data type: integer, reals, and strings 2019-09-20 10:42:31 +02:00
Cláudio Belo Lourenço
c7a09d626b Wrapping all constant literals under the same construct.
Strings not supported in this commit.
2019-09-19 20:14:54 +02:00
Raphael Rieu-Helft
f2a95dad7e Make alias work with named returns 2019-09-19 15:58:19 +02:00
Rehan MALAK
443cdcd136 adapt microc and python plugin to Ptree constructors (3d86e1c5f) 2019-07-26 13:26:59 +02:00
MARCHE Claude
f9228fac35 Merge branch 'ptree_typing_mlw_file' into 'master'
extends Ptree/Typing API to the entire mlw file

See merge request why3/why3!199
2019-07-26 12:42:01 +02:00
Jean-Christophe Filliatre
42c2e450b9 Python/micro-C: at/old/labels now supported
makes use of auto-dereference
2019-07-06 14:54:56 +02:00
Jean-Christophe Filliatre
5fceac32db micro-C
functions/predicates possibly with a definition
alternate syntax for but contracts/loop spec before or after curly braces
2019-07-06 13:39:38 +02:00