Commit Graph

73 Commits

Author SHA1 Message Date
Christian Rinderknecht
757b0da78c Removed the open type [Error.t] (less [assert false]).
I also had to remove the keywords [Down], [Fail] and [Step] in
PascaLIGO that made a mysterious and unwanted come back. (I did not
bother with [git blame]).
2019-12-17 15:58:27 +00:00
Christian Rinderknecht
531dd238a7 Added unlexer for PascaLIGO. 2019-12-17 15:58:27 +00:00
Christian Rinderknecht
a94ee53fd3 Finished the refactoring of the parsers. 2019-12-15 20:59:04 +01: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
6692643cc5 Streamlined LexerMain and ParserMain for ReasonLIGO. 2019-12-13 17:28:15 +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
Sander
95a7e19be6 Add ReasonLIGO support 2019-12-10 13:47:31 +00:00
Christian Rinderknecht
04a770e22d To enable local builds of the PascaLIGO parser. 2019-12-09 15:52:17 +00:00
John David Pressman
e1a05a27c5 Remove vestigial commented-out code 2019-11-18 23:45:26 -08:00
galfour
ddc4b7b7a5 add anon functions; remove pre-block declarations; update tests 2019-11-18 16:10:48 +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
02f58ee212 I removed the annotation for the variable that iterates over collections.
for x in set s block { ... } // now
for x : t in set s block { ... } // before
2019-11-06 20:12:25 +01:00
Christian Rinderknecht
9da6d81a0f Added local test file. 2019-11-06 17:33:00 +01:00
Christian Rinderknecht
fe90246e3a Fixed the printing of some AST nodes. 2019-11-06 17:23:49 +01:00
Christian Rinderknecht
bd6ce2f28c Bug fix: Some nodes were not indented. 2019-11-05 15:57:43 +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
Christian Rinderknecht
2c4183f008 Merge branch 'feature/cameligo-bitwise-operators' into 'dev'
[LIGO-177] Add bitwise operators to CameLIGO

See merge request ligolang/ligo!160
2019-10-28 18:13:54 +00:00
John David Pressman
c7e4f3f651 Remove lxor, land, and lor from reserved words 2019-10-28 09:18:16 -07:00
Tom Jack
0191d8b0ed Replace "mtz" with "mutez" 2019-10-27 11:50:24 -05:00
Rémi Lesenechal
5a5c3a8dd4 Merge branch 'feature/clean-big-map' into 'dev'
Feature/clean big map

See merge request ligolang/ligo!145
2019-10-25 21:30:09 +00:00
Christian Rinderknecht
4a9150f560 WIP: Fixing a regression (blocks in case clauses as intructions). 2019-10-24 10:33:22 +02:00
Christian Rinderknecht
eae3348d51 I forbade empty patches (parser). Fixed AST pretty-printer (PascaLIGO).
Changed accordingly the simplifier: the dead code for the error about
empty record patches is no long.
2019-10-23 00:35:29 +02:00
Lesenechal Remi
cefac0d8e7 add big_map injection 2019-10-22 12:23:48 +02:00
Christian Rinderknecht
9ad0859a4c Merge branch 'feature/pascaligo-remove-case-as-expression' into 'dev'
Feature/pascaligo add conditional as an expression

See merge request ligolang/ligo!144
2019-10-22 08:42:59 +00:00
Christian Rinderknecht
312dc65950 Merge remote-tracking branch 'origin/dev' into rinderknecht-dev 2019-10-21 21:42:52 +02:00
John David Pressman
09230df60a Remove kwd_expr 2019-10-19 10:55:39 -07:00
John David Pressman
daad15c57d Write blockless function test and make it pass 2019-10-19 10:46:24 -07:00
John David Pressman
6e0173a9a7 Fix type error when where blockfun types eat regions 2019-10-18 17:46:20 -07:00
Christian Rinderknecht
d95f345dbf First attempt at adding conditionals as expressions.
Warning: The simplifier is not done yet.
2019-10-18 17:44:10 +02:00
Christian Rinderknecht
704c744ace First attempt at adding conditionals as expressions.
Warning: The simplifier is not done yet.
2019-10-18 13:52:26 +02:00
John David Pressman
2bffba379d Remove anonymous records 2019-10-17 22:34:38 -07:00
John David Pressman
35a59a0867 Add parser tokens, guru meditation on why the AST types don't work 2019-10-17 21:33:45 -07:00
John David Pressman
8997155a57 Rough draft of single-expr function syntax 2019-10-17 20:50:41 -07:00
Christian Rinderknecht
36d9858e97 Removed sub-blocks from PascaLIGO. 2019-10-17 18:33:58 +02:00
Christian Rinderknecht
00016d09bb I removed the definition of procedures.
Note: This immediately removes some unsupported cases of the
simplifier, pertaining to the definition of procedures.
2019-10-16 15:39:08 +02:00
Christian Rinderknecht
1299ecac6b Merge remote-tracking branch 'origin/dev' into rinderknecht-dev 2019-10-16 12:00:40 +02:00
Christian Rinderknecht
157e24ff08 Fixed documentation.
There was an error in the syntax of tuple projection (no parentheses
are needed, in fact).

Another issue was a wrong Markdown layout for lists (my fault).
2019-10-16 11:50:31 +02:00
Christian Rinderknecht
15937a2459 Bug fixing in the AST pretty-printer and new syntax for iterators.
I added a type annotation for the variable iterating a
collection, which is also now marked as "map", "set" or "list".

I fixed and refactored the pretty-printer for the AST.
2019-10-16 01:11:54 +02:00
Christian Rinderknecht
27564426da Bug fixes and finished AST pretty-printer.
ParserLog: Finished the AST pretty-printer.
ParserMain: The CLI "ast" is now "ast-tokens" and the new "ast"
calls the AST pretty-printer.
Bug: Added nat literals as patterns.
AST: Removed unary constructor TupleInj.
Parser and simplifier:
  - The rule "cartesian" is now properly stratified.
  - Parenthesised expressions now correctly create EPar nodes.
2019-10-15 21:03:46 +02:00
John David Pressman
8a9a72b673 Merge branch 'dev' of gitlab.com:ligolang/ligo into gardening/code-comments 2019-10-14 16:31:57 -07:00
Christian Rinderknecht
f634d36b76 Refactorings for PascaLIGO.
- I aligned the names of the tokens in common with Ligodity.
  - I removed the "down" and "step" clauses in loops.
  - Note: the stratification of the rule "pattern" in the
    previous commit has the pleasant effect to remove a call
    to "corner_case" in function "simpl_case" of the
    file "2-simplify/pascaligo.ml".
  - Added more cases to the pretty-printer of the AST.
2019-10-13 19:51:01 +02:00
Christian Rinderknecht
f795f1216a Bug fixing in the lexers and the parser. Started AST pretty-printer.
LexToken, AST: Tiny refactoring.

Bug: Added the making of the AST node PBytes.

Parser: The rule "pattern" was not properly stratified (the
constructor "PCons" was always produced, even when no consing was
done (now a fall-through to "core_pattern").

Bug: When sharing the lexers between Ligodity and Pascaligo, a
regression was introduced with the lexing of symbols. Indeed,
symbols specific to Ligodity (like "<>") and
Pascaligo (like "=/=") were scanned, but the
function "LexToken.mk_sym" for each only accepted their own,
yielding to an assertion to be invalidated. Fix: I created an
error "sym_err" now to gracefully handle that situation and
provide a hint to the programmer (to wit, to check the LIGO
syntax in use).

WIP: Started to write pretty-printing functions for the nodes of
the AST.

CLI: The option "--verbose=ast" now calls that function instead
of printing the tokens from the AST. When the pretty-printer is
finished, the option for printing the tokens will likely
be "--verbose=ast-tokens".
2019-10-12 23:42:26 +02:00
Christian Rinderknecht
bcf73d01bf Printing of tokens from the AST is now done in a Buffer.t 2019-10-09 16:07:13 +02:00
John David Pressman
f990dc8a0f Merge branch 'dev' of gitlab.com:ligolang/ligo into gardening/code-comments 2019-10-08 13:46:25 -07:00
Christian Rinderknecht
1362fbae9e Made big_map a keyword, like map. 2019-10-08 12:24:56 +02:00
Christian Rinderknecht
6f414a8ad2 Merge branch 'feature/unsupported_ass_None' into 'dev'
Feature/unsupported_ass_none

See merge request ligolang/ligo!118
2019-10-07 16:31:19 +00:00
Christian Rinderknecht
76b4fa3f47 Merge branch 'rinderknecht-dev' into 'dev'
Gardening for Ligodity and update of the documentation of PascaLIGO.

See merge request ligolang/ligo!119
2019-10-07 15:44:36 +00:00
Tom Jack
36ec771adf Remove singleton inductive type 2019-10-07 16:54:28 +02:00