Commit Graph

127 Commits

Author SHA1 Message Date
Lesenechal Remi
4d56a71bd1 propagate location for cameligo variables 2020-01-03 16:23:18 +01:00
Sander
ce6ccab728 Add support for empty constructors. 2020-01-03 13:01:13 +00:00
Lesenechal Remi
c8339ed2ef first try 2019-12-31 14:23:51 +01:00
John David Pressman
dcfc8d6391 Horrible hack to rewrite CST for tuple param destruct,
Fails because Let In doesn't support multi-bind
2019-12-29 01:24:22 +00:00
John David Pressman
3d9489530a Merge branch 'dev' into feature/cameligo-multi-bind-let-in 2019-12-27 09:29:30 -08:00
John David Pressman
e1ecb36e61 Have let ... in evaluate right hand side first during multi-bind 2019-12-26 21:06:24 -08:00
John David Pressman
2d9de2aef0 Clean up let ... in multi-bind 2019-12-24 15:35:05 -08:00
John David Pressman
48a3bebadd Working rough draft of let ... in multi-bind 2019-12-24 14:54:22 -08:00
Lesenechal Remi
bdd1d09c04 t_operator can not throw exceptions 2019-12-24 12:43:32 +01:00
Tom Jack
172038cef0 Kill warning 45 by reusing Pervasives.result for Trace 2019-12-18 21:20:35 +00:00
John David Pressman
310dde6dc9 [LIGO-286] Tuple destructuring doesn't do left hand type inference in CameLIGO 2019-12-17 21:04:53 +00:00
Christian Rinderknecht
f8d6396fcd Refactoring of the parsers
* [CameLIGO/ReasonLIGO] The AST node [EAnnot] (expressions
    annotated by a type) now records the region in the source
    code for the colon.

  * [CameLIGO/ReasonLIGO/PascaLIGO] I added the syntax
     %token <...> TOKEN "lexeme"

  * [ReasonLIGO] I changed the AST nodes [Mtz] and [Str] to
    [Mutez] and [String], respectively (in accordance with the
    PascaLIGO front-end). I changed token [DOTDOTDOT] to
    [ELLIPSIS].

  * [ReasonLIGO] I added what was missing to make a loca build
    with my Makefile.
2019-12-15 17:46:08 +01:00
Christian Rinderknecht
e685e313f0 Fixed the build after I made a small error when fixing the latest
merge conflict.
2019-12-13 12:30:59 +01:00
Christian Rinderknecht
c7ffa6d563 Merge remote-tracking branch 'origin/dev' into rinderknecht-dev 2019-12-13 12:28:33 +01:00
Christian Rinderknecht
0226b9f23c Refactoring of comments (for [dune build @doc]).
Refactoring of parsing command-line arguments

  * The type [options] is now abstract and implemented as an
    object type to avoid struggling with scoping and type
    inference when record types share some common field names.

Refactoring of ParserLog for PascaLIGO and CameLIGO

  * The immediate motivation behind that refactoring was to
    remove the use of a couple of global references. A
    consequence is that we have a nicer and more compact code, by
    threading a state. The files [pascaligo/Tests/pp.ligo] and
    [ligodity/Tests/pp.mligo].

  * Another consequence is that the choice of making strings from
    AST nodes depends on the CLI (offsets? mode?). After this
    refactoring, that choice is hardcoded in the simplifiers in a
    few places (TODO), waiting for a general solution that would
    have all CL options flow through the compiler.

  * I removed the use of vendors [x_option.ml], [x_map.ml] and
    [x_list.ml] when handling optional values. (Less dependencies
    this way.)

Refactoring of the ASTs

  * I removed the node [local_decl], which was set to [[]]
    already in a previous commit (which removed local
    declarations as being redundant, as statements could already
    be instructions or declarations).

  * I changed [StrLit] to [String] in the AST of CameLIGO and
    ReasonLIGO.

  * I also changed the type [fun_expr] so now either a block is
    present, and therefore followed by the [with] keyword, or it
    is not. (Before, the presence of a block was not enforced in
    the type with the presence of the keyword.)

Notes

  * [LexerMain.ml] and [ParserMain.ml] for CameLIGO and PascaLIGO
    are almost identical and differ in the same way (language
    name and file extension), which suggests that they should be
    in the [shared] folder and instanciated as a functor in the
    future (TODO).

  * I removed the blank characters at the end of many lines in
    the parser of ReasonLIGO.
2019-12-13 12:21:52 +01:00
Sander Spies
6f9134834f Remove original Cameligo and rename Ligodity to Cameligo. 2019-12-12 14:35:07 +01:00
Pierre-Emmanuel Wulfman
034c92a64c Use ADT for types and move type to ast_common
and Making name, type_variable, built-in, constructor, label and string uncompatible types in ligo (weird bug with types in ligodity)
2019-12-04 11:40:58 +00:00
John David Pressman
085a756ed3 Fix bug where tuples are destructured with the members in the wrong order 2019-12-03 10:49:58 -08:00
Lesenechal Remi
848b902cd9 generated variable name typo 2019-11-26 17:49:23 +01:00
Tom Jack
7f7d5972ac Fix a Region.Invalid error in Cameligo simplifier 2019-11-21 16:53:17 -06:00
Lesenechal Remi
f27f8c10d1 For collection loop: also capture variable in logical blocks
Also, the iterated element/s are appended tot he list of local declaration
2019-11-21 11:28:32 +01:00
John David Pressman
4270cc0d22 [LIGO-229] Change ordering of collection operation args 2019-11-20 12:16:31 +00:00
John David Pressman
9b0eb636fb Properly typed multi-variable binding simplification
Thanks for the help Sanders. :)
2019-11-19 21:13:52 +00:00
Rémi Lesenechal
f0655eab28 Pascaligo for collection loops: take locally declared variable into account 2019-11-19 13:25:48 +00:00
John David Pressman
bbcacc253b Merge branch 'feature/pascaligo-anon-functions' into 'dev'
Feature/pascaligo anon functions

See merge request ligolang/ligo!201
2019-11-19 08:33:54 +00:00
galfour
ddc4b7b7a5 add anon functions; remove pre-block declarations; update tests 2019-11-18 16:10:48 +01:00
Lesenechal Remi
91e245ef70 Fix issue with nested collection loop where inner loop iterated elements were shadowing outer loop iterated element 2019-11-18 14:14:54 +01:00
galfour
5422049dba Merge branch 'dev' into feature/more-applications-pascaligo 2019-11-18 09:53:57 +01:00
Lesenechal Remi
e689d3d3b7 more doc 2019-11-15 20:05:35 +01:00
Lesenechal Remi
683bc0a72b fix problems with nested for collection loop 2019-11-15 20:05:35 +01:00
galfour
d0efbd9f92 add and test more ways to do function application in pascaligo 2019-11-14 20:13:15 +01:00
Christian Rinderknecht
fe90246e3a Fixed the printing of some AST nodes. 2019-11-06 17:23:49 +01:00
Christian Rinderknecht
351025b52d Refactoring of Ligodity (CameLIGO) and making an AST pretty-printer
- AST.ml/AST.mli:
  - The AST now distinguishes the constructors `None` and `Some` as being
    predefined, as in PascaLIGO. See type `AST.constr_pattern`.
  - I removed the nodes specific to Liquidity,
    e.g. `let%entry`, and, in particular, the natural literals
    ending with `p`. Now it should be `n`, as in `10n`.
  - I renamed the node `TAlias` to `TVar`.
  - I have applied the rule of expanding type expressions after `of` when
    those were not records.
  - The type of the argument to a data constructor is now
    `type_expr`, instead of `cartesian`.
  - I added the patterns for bytes (`PBytes`) and natural literals (`PNat`).
  - I renamed the node `Sugar` into
    `PListComp` (meaning "pattern of list comprehension").
  - Record types in CameLIGO now must have at least one field declaration.
  - Replaced the type `closing` and `opening` with one type `compound`,
    which captures only the right combinations of opening and closing.
  - Components of tuples in a selection must not be written
    between parentheses. For example, `a.b.(1).(0)` is now
    `a.b.1.0`, as in PascaLIGO.
- LexToken.mli/LexToken.mll
  - I renamed the string literal `Str` into `String`.
  - I added the tokens `C_None` and `C_Some` (to distinguish the
    constructors `None` and `Some`. See AST.ml)
  - Fixed the function `mk_sym` so it does not fail with `failwith`, but
    with `Error Invalid_symbol`.
- Lexer.mll (shared)
  - I removed the character `%` from the identifiers (used to
    support Liquidity, like `entry%point` and `match%nat`).
  - I adde to the hint on broken strings: "or insert a backslash"
    (from a Gitlab issue).
- ParToken.mly
  - I added the tokens `C_None` and `C_Some` (to distinguish the
    constructors `None` and `Some`. See AST.ml and LexToken.mll)
- Parser.mly
  - Fixed the order of declarations in the AST (it was reversed).
  - I removed syntax support for Liquidity.
  - I added user-defined constructor applications to irrefutable
    patterns (the ones afer a `let`), even though only the type
    checker can decide that they are truly irrefutable because they
    are the only constructors of their types.
  - I added natural numbers and bytes to patterns.
  - Access of tuple components do not require parentheses now, like
    `a.b.1.0`.
  - I refactored the semantic actions.
  - I added the empty sequence `begin end`.
- ParserLog.ml/ParserLog.mli
  - I added a pretty-printer for the AST (with source locations).
- ParserMain.ml
  - The CLI for the pretty-printer is now `--verbose=ast`.
  - The old CLI `--verbose=ast` is now `--verbose=ast-tokens`.
- ligodity.ml (simplifier)
  - I removed the constructions of sets, lists and maps with
    `Set [...]`, `List [...]` and `Map [...]`, as there are already
    better ways (that is, more like the OCaml's way), like
    `Set.literal [...]` and `Map.literal [...]`. (The case for lists
    was entirely redundant with the rest of the language as it is.)
  - Everywhere there is now a non-empty list of elements, I made a
    change. In particular, I removed a corner case ("let without
    binding"), thanks to more precise OCaml types for non-empty
    lists.
  - I ported all the changes to the AST above.
- region.ml (vendors)
  - I changed the method `compact` so the end-line is not repeated
    if it is the same as the start line: this is even more compact. I
    use this in the new pretty-printer for the AST (see above)
- I updated all the CameLIGO contracts.
2019-11-04 23:51:47 +01:00
John David Pressman
c09116211f Merge branch 'feature/cameligo-negative-op' into 'dev'
[LIGO-172] Add negative operator to CameLIGO

See merge request ligolang/ligo!161
2019-10-29 18:12:17 +00:00
John David Pressman
dce98c06ec Merge branch 'dev' of gitlab.com:ligolang/ligo into feature/cameligo-negative-op 2019-10-29 09:59:37 -07:00
John David Pressman
102ffda7c3 Make negative operator test pass 2019-10-29 09:28:20 -07:00
Lesenechal Remi
a140e12394 add test for nested for collection loops (not supported yet) 2019-10-29 16:32:28 +01:00
Lesenechal Remi
402d849cec use intermediary tuple access to get key and value for maps. add tests. 2019-10-29 15:43:00 +01:00
Lesenechal Remi
c288f3c81e simplify the simplifier and now find the free variables with a expression_fold 2019-10-29 11:56:21 +01:00
Lesenechal Remi
e86c92bc3b improving simplifier 2019-10-29 11:41:59 +01:00
Lesenechal Remi
e77f3e4903 empty for collection loop 2019-10-28 20:52:14 +01:00
Lesenechal Remi
2ced2e784e add doc 2019-10-28 20:52:14 +01:00
Lesenechal Remi
e16eac77a6 fixes for loop on map.
Untested because of issue with deep tuple access (LIGO-131 LIGO-134)
An error message is in the simplifier
2019-10-28 20:52:14 +01:00
Lesenechal Remi
b71309bfa2 proper error message for deep accesses in loops of collection body 2019-10-28 20:52:14 +01:00
Lesenechal Remi
5a77b08aa7 cleaning & documenting 2019-10-28 20:52:14 +01:00
Lesenechal Remi
a3deccf352 changing the name of the lambda to 'arguments' make its arguments available 2019-10-28 20:52:14 +01:00
Lesenechal Remi
d651bfb3a3 remove misplaced 'skip' 2019-10-28 20:52:14 +01:00
Lesenechal Remi
0cf7471441 prepend the body of the lambda with let_in's 2019-10-28 20:52:14 +01:00
Lesenechal Remi
70502f62cb fix the way lambda arguments are accessed 2019-10-28 20:52:14 +01:00
Lesenechal Remi
db79b6b9da select op_name from collection key word 2019-10-28 20:52:14 +01:00