Compare commits

...

826 Commits

Author SHA1 Message Date
7273e38a0f
Remove postinstall from vscode-plugin 2020-09-17 18:54:24 +03:00
a5874d7c2e
Update nixpkgs and haskell.nix to pinned versions 2020-09-17 18:24:37 +03:00
5105e0e692
DROP BEFORE MERGING UPSTREAM 2020-09-17 18:24:37 +03:00
977bb1095c
Add a job for vscode extension 2020-09-17 18:24:36 +03:00
db9371bfa6
Fully package vscode extension with nix 2020-09-17 18:24:36 +03:00
417b427f6d
Fix tree-sitter generation with make 2020-09-17 18:24:35 +03:00
Kirill Kuvshinov
7f3a662cbc
Add nix expressions for building a static musl executable 2020-09-17 18:24:34 +03:00
Kirill Kuvshinov
ee86539685 Merge branch 'kkirka/ligo47-fix-incorrect-parsing' into 'tooling'
[LIGO-47] Fix incorrect parsing of lambdas and case clauses

See merge request serokell/ligo/ligo!19
2020-09-15 08:35:45 +00:00
Kirill Kuvshinov
c44a35d4d1
[LIGO-47] PascaLIGO: Move block out of case_block alternatives
Problem: In multisig.ligo:48, the case alternative block is
interpreted as empty, while it is not. This happens because
PascaLIGO parser expects to find `fields "statements"` inside
a `case_block`. In practice, if a `case_block` contains a `block`,
statements are deeper in the hierarchy, and get ignored.

Solution: Move "block" option out of the "case_block"
(to _if_clause).
2020-09-15 11:25:21 +03:00
Kirill Kuvshinov
04724a1db2
[LIGO-47] Allow let .. in in lambda body
Problem: In multisig.mligo, else clause on line 36 ends on line 55,
while it should end on line 80. This happens because of incorrect
lambda parsing on lines 42-43. In particular, `let valid, keys = vk`
in lambda body gets parsed as a
`tuple (fun_app "let" "valid") (binary_op "=" "keys" "vk")`, and `in`
is considered as a part of the outer `let`.

Solution: Allow `_program` instead of `_expr` as the lambda body.
2020-09-15 11:22:15 +03:00
Anton Myasnikov
7f6820c368
[LIGO-42] Support for document symbols
Problem: We want to be able to extract document symbols from some
ligo contract that are realised by @haskell-lsp@ client.

Solution: Implement `extractDocumentSymbols` and integrate it with
@haskell-lsp@.
2020-09-09 14:08:09 +03:00
Anton Myasnikov
619a7de432
[LIGO-41] Convert ligo scopes to ScopedDecl 2020-09-08 18:48:53 +03:00
Anton Myasnikov
d5154dff36
[LIGO-41] Ligo binary integration
Problem: We want to integrate our lsp client with ligo binary to
be able to typecheck declarations as well as extract their scopes.

Solution: Implement a simple client that calls ligo and some helpers
functions to extract scopes from its output.
2020-09-08 18:48:53 +03:00
Anton Myasnikov
7c43cd9574
[LIGO-40] Move LSP request handlers to Capabilities directory 2020-09-08 18:47:23 +03:00
Anton Myasnikov
0b1590e324
[LIGO-40] Implement LSP range cconversion function
Problem: We need to be able to convert squirrel ranges to lsp
specific ones.

Solution: Add `toLSPRange` function.
2020-09-08 18:44:11 +03:00
Anton Myasnikov
283f41738d
[LIGO-40] Support for code hovering
Problem: We want to be able to show modal on hovering curson on
some specific declaration.

Solution: Add `hoverDecl` and integrate it with haskell-lsp client.
2020-09-08 18:44:11 +03:00
Kirill Kuvshinov
5d8f2c8526
[LIGO-13] Add CameLIGO and ReasonLIGO
Problem: The previous version of the extension only supported
PascaLIGO dialect. We need to add syntax highlighting and
activation events for ReasonLIGO and CameLIGO.

Solution: Add .tmlanguage.json files for ReasonLIGO and CameLIGO,
add activation events.
2020-09-08 13:14:51 +03:00
Kirill Kuvshinov
15fc6f25fd
[LIGO-13] Add a VSCode extension
Problem: We need to deliver a VSCode extension but the one we use
currently is located in a separate repo, requires manual patches
and does not support ReasonLIGO.

Solution: Add our extension that supports PascaLIGO and ReasonLIGO;
CamLIGO is WIP.
2020-09-08 13:14:43 +03:00
Anton Myasnikov
b48b461c28 Merge branch 'awkure/collect-errors' into 'tooling'
[LIGO-39] Parse whole directory

See merge request serokell/ligo/ligo!10
2020-09-03 06:26:51 +00:00
Anton Myasnikov
f0005c982a
[LIGO-39] Parse contracts in directory
Problem: We want to be able to parse whole directory for ligo
contracts for testing purposes.

Solution: Add `parseContracts` function that returns `ParsedContract`
data that ignores every file which is not a ligo contract.
2020-08-25 17:29:40 +03:00
Anton Myasnikov
fd862676b3
[LIGO-26] Support code folding capability
Problem: We want to support code folding for functions and types
in our lsp.

Solution: Add `foldingAST` function that produces an additional
list of ranges along with the given monad used in `haskell-lsp`
API to collect ranges that are consequently sent to server.
2020-08-25 13:39:47 +03:00
Kirill Andreev
d2a020434e
Fix contract 2020-08-24 20:22:46 +04:00
Kirill Andreev
28714af8cc
Additional fixes 2020-08-24 20:20:52 +04:00
Kirill Andreev
f2a3f0b579
Hopefully fix VFS loading (by falling back to loadByURI) 2020-08-24 20:10:00 +04:00
Kirill Andreev
da6ca97a9d
Fix 'field name not found' for reasonligo 2020-08-24 20:05:24 +04:00
Kirill Andreev
5533b07270
Fix pattern defs for pascaligo 2020-08-24 14:17:53 +04:00
Kirill Andreev
f554551f75
[LIGO-37] [LIGO-38] Looks like it fixes it 2020-08-24 12:29:51 +04:00
Anton Myasnikov
3037be689b
[LIGO-27] Fix parameters for lambdas and restructure grammar
Problem: It happens that "go to definition" fails with lambda
parameters meaning that we do not create proper AST for it.
Also we need to restructure grammar so that we can support it in
the future.

Solution: Restructure grammar to use "param_decl" and ensure that
we use proper fields for parser resolution.
2020-08-23 22:05:27 +03:00
Anton Myasnikov
1828fd6d46
[LIGO-29] Integrate existing completion framework with haskell-lsp
Problem: Currently we have not integrated our completions with
haskell-lsp server so that we could use this completion from text
editor itself.

Solution: Add the corresponding requests for handling code completion.
2020-08-23 22:01:00 +03:00
Kirill Andreev
1c684a791c
Fix camligo not registering fun/lam args 2020-08-21 18:24:06 +04:00
Kirill Andreev
7fa947e92e
Add all parser.c as symlinks 2020-08-21 18:23:39 +04:00
Kirill Andreev
5e0cf40ea7
[fix] Cleaning the commented code after CAML grammar 2020-08-19 14:29:44 +04:00
Kirill Andreev
41a49da1e0
Pin the vendor/camligo directory 2020-08-19 14:12:03 +04:00
Kirill Andreev
6e2f592094
[LIGO-17] Implementing CAMLligo dialect 2020-08-18 21:56:33 +04:00
Kirill Andreev
1a948bcae7
Extension and grammar 2020-08-17 16:29:42 +04:00
Kirill Andreev
26d11eea19
Rename debounced -> unsafeDebounce 2020-08-14 15:49:42 +04:00
Kirill Andreev
fe929fbe70
Link camligo grammar, get rid of personal loaders 2020-08-14 15:40:30 +04:00
Kirill Andreev
ba66f6e8e4
Make extension-aware parser entrypoint 2020-08-14 14:54:04 +04:00
Kirill Andreev
28e16ca068
Make grammar parse everything except inline M. 2020-08-13 16:13:48 +04:00
Kirill Andreev
78c408b76a
Untangle existing code for grammar 2020-08-13 16:13:42 +04:00
Anton Myasnikov
f1938eb2af
Hotfix: add missing Scoped instances 2020-08-12 14:28:51 +03:00
Kirill Andreev
31b5ffbeef
Keeps dirs, remove unused artifact 2020-08-11 15:41:20 +04:00
Anton Myasnikov
a1a846b554
[LIGO-25] Add ReasonLIGO parser
Problem: With generated ReasonLIGO grammar we need to develop its
parser as well. With it we also need to restructure AST a bit
and add expressions that are used for ReasonLIGO specifically.

Solution: Add ReasonLIGO parser and some dummy examples of its
usage, adapt AST to it, rename LIGO to AST.
2020-08-11 13:33:26 +03:00
Anton Myasnikov
820d73f345
[LIGO-25] Chores (add Makefile, scripts, vendor, stylish)
Problem: We need to add stylish config to settle code style for our
project. Makefile to simplify its building. Also we need to check
our project for trailing whitespaces so we need to add the corresponding
script to be used later in CI.

Solution:
Add
  - stylish-haskell config
  - Makefile
  - `check_trailing_whitespace` script
2020-08-11 13:31:22 +03:00
Anton Myasnikov
99321a59bb
[LIGO-25] Add grammar for ReasonLIGO and move it to squirrel
Problem: Before making parser for ReasonLIGO we need to construct
its grammar so that we can collect *all* errors and simplify our
further work with AST. Also since we use those grammars in squirrel
it would be conscise to use them from the project directory directly.

Solution: Add grammar for ReasonLIGO and move grammar to squirrel.
2020-08-11 13:30:46 +03:00
Anton Myasnikov
0fbfd134ec
[LIGO-25] Update .gitignore 2020-08-11 13:29:47 +03:00
Kirill Andreev
2a8cda17ce
Add type/doc capture 2020-08-11 12:32:55 +04:00
Kirill Andreev
38c32f01d4
Remove most warnings and renudant line in AST.Parser 2020-08-11 12:32:55 +04:00
Kirill Andreev
107018e6f3
Add basic code completion mechanism 2020-08-11 12:32:54 +04:00
Kirill Andreev
08a0eb55d1
Fix AST.Scope 2020-08-11 12:32:54 +04:00
Kirill Andreev
31274e1507
Tie all up 2020-08-11 12:32:54 +04:00
Kirill Andreev
9f29dab195
Fix letrec partially 2020-08-11 12:32:53 +04:00
Kirill Andreev
6bd5d9ef84
Update AST.Scope to new framework 2020-08-11 12:32:53 +04:00
Kirill Andreev
226b7264aa
Restore AST.Scope instances and part of the machinery 2020-08-11 12:32:53 +04:00
Kirill Andreev
b5e5bc25a1
[WIP] Conversion to descent-based parser 2020-08-11 12:32:52 +04:00
Kirill Andreev
3233270dba
Add debounced function 2020-08-11 12:32:10 +04:00
Kirill Andreev
58e5128142
Fix dying on broken code and handle errors in Main.hs 2020-08-11 12:32:10 +04:00
Kirill Andreev
508b111374
Fix blocks getting invalid ranges 2020-08-11 12:32:09 +04:00
Kirill Andreev
20014a7926
Remove warnings, refactor FullEnv 2020-08-11 12:32:09 +04:00
Kirill Andreev
a11e92af60
Remove unused traverseOnly 2020-08-11 12:32:09 +04:00
Kirill Andreev
5737cd5686
Fix tree traversal breaking on errors 2020-08-11 12:32:08 +04:00
Kirill Andreev
e5ec32f46a
Fix letrec behaviour 2020-08-11 12:32:08 +04:00
Kirill Andreev
c26bc044ee
Separate the namespaces for search 2020-08-11 12:32:08 +04:00
Kirill Andreev
ba3c0a76d9
Fix function stealing 'goto def's 2020-08-11 12:32:07 +04:00
Kirill Andreev
29bc1721d1
Load from VFS 2020-08-11 12:32:07 +04:00
Kirill Kuvshinov
bf6cc6ca16
[LIGO-18] Expose find ref and go to def via LSP
Problem: The current implementation of "Find references" and
"Go to definition" is not exposed via the LSP. We need to expose
them so that they are accessible from the client.

Solution: Add the necessary handlers, send response messages.
2020-08-11 12:32:07 +04:00
Kirill Andreev
65fc5bec75
Separate env-tree construction and usage 2020-08-11 12:32:06 +04:00
Kirill Andreev
24cc24b0d7
Prevent loop on recursive import 2020-08-11 12:32:06 +04:00
Kirill Andreev
b35a28853b
Add ability to recursively parse #included files 2020-08-11 12:32:06 +04:00
Kirill Andreev
583d7f8997
Clean the comments 2020-08-11 12:32:05 +04:00
Kirill Andreev
03b89bc5b7
Rewrite scope loader 2020-08-11 12:32:05 +04:00
Kirill Andreev
8d61a36918
[WIP] Implement a loader of Env from a ScopeTree 2020-08-11 12:32:05 +04:00
Kirill Andreev
9f124bf5af
Implement def/impl/type search 2020-08-11 12:32:04 +04:00
Kirill Andreev
9cf2e0cf97
Use Data.Sum instead of manual Union 2020-08-11 12:32:04 +04:00
Kirill Andreev
20de97c5c6
Make faster Union 2020-08-11 12:32:04 +04:00
Kirill Andreev
44defb2114
Remove Data.Fix, make recursion manually 2020-08-11 12:32:03 +04:00
Kirill Andreev
19f05f5afc
Rename HasComments to Comment; remove *.cabal 2020-08-11 12:32:03 +04:00
Kirill Andreev
e701e196fe
Improve documentation 2020-08-11 12:32:03 +04:00
Kirill Andreev
9d81ecf353
Silence warnings 2020-08-11 12:32:02 +04:00
Kirill Andreev
1f7af3c8cb
Make infoOf always return an info 2020-08-11 12:32:02 +04:00
Kirill Andreev
9b95006a71
Make Error a Functor; move all Error stuff to Error.hs 2020-08-11 12:32:02 +04:00
Kirill Andreev
41403426b0
Add project overview 2020-08-11 12:32:01 +04:00
Kirill Andreev
f3fbfb49a1
Add documentation 2020-08-11 12:32:01 +04:00
Kirill Andreev
95707100c2
Formatting Main.hs 2020-08-11 12:32:01 +04:00
Kirill Kuvshinov
9856476ebf
WIP: Add CTRL.run 2020-08-11 12:32:00 +04:00
Kirill Andreev
923a5bb9fe
Add documentation 2020-08-11 12:32:00 +04:00
Kirill Andreev
d380e46737
Convert to monotyped AST 2020-08-11 12:32:00 +04:00
Kirill Andreev
113a2425a4
Remove ScopeHelpers.hs 2020-08-11 12:31:59 +04:00
Kirill Andreev
11fdc0afa1
Fix error msg interpolation 2020-08-11 12:31:59 +04:00
Kirill Andreev
5c643a3b63
TMP 2020-08-11 12:31:59 +04:00
Kirill Andreev
67de82edec
[LIGO-6] Implement fallback scope system 2020-08-11 12:31:58 +04:00
Kirill Andreev
1536590edb
TMP 2020-08-11 12:31:58 +04:00
Kirill Andreev
bc155bea16
Add TODO 2020-08-11 12:31:58 +04:00
Kirill Andreev
c8b4c2bd35
Fix comment )-truncation 2020-08-11 12:31:57 +04:00
Kirill Andreev
e1a3903e18
Limit exports of Parser 2020-08-11 12:31:57 +04:00
Kirill Andreev
020b3ba334
Improve pretty-printer 2020-08-11 12:31:57 +04:00
Kirill Andreev
19e1018620
Add autocollector for comments 2020-08-11 12:31:56 +04:00
Kirill Andreev
c497da5841
Add automatic error collector to the parser 2020-08-11 12:31:56 +04:00
Kirill Andreev
916d9897bd
Simplifying parser 2020-08-11 12:31:56 +04:00
Kirill Andreev
7ff8226e1b
Remove obsolete checks for Parser.{some,many} 2020-08-11 12:31:55 +04:00
Kirill Andreev
6dc1eb23cd
Remove excess params of Parser.{many,some} 2020-08-11 12:31:55 +04:00
Kirill Andreev
b62cd58add
Add some more documentation 2020-08-11 12:31:55 +04:00
Kirill Andreev
eace901195
Remove debug print, document Parser.hs 2020-08-11 12:31:54 +04:00
Kirill Andreev
e6299a50ff
Make parser recognise all src/tests/contracts 2020-08-11 12:31:54 +04:00
Kirill Andreev
b4e6231340
Add [Big]Map literal/removal/projection parser 2020-08-11 12:31:54 +04:00
Kirill Andreev
2f269e32ea
Add attribute parser 2020-08-11 12:31:53 +04:00
Kirill Andreev
d928aaa39c
Add lists, if, assignments, string, tez parsers 2020-08-11 12:31:53 +04:00
Kirill Andreev
6e862bf5b9
Untie AST builder from comment accumulation 2020-08-11 12:31:53 +04:00
Kirill Andreev
1ed617c7d0
Convert parsers to applicative interface
Problem:  The aquisition of current range is manual, and therefore
          error-prone. The names in do-syntax create visual clutter.

Solution: Hide range aquisition (which makes it possible to do automatic
          comment aquisition as well).
2020-08-11 12:31:52 +04:00
Kirill Andreev
a8b898d396
Improve grammar, add Parsers for many things 2020-08-11 12:31:52 +04:00
Kirill Andreev
83cc13dd48
Convert into GLR-way of operator parsing 2020-08-11 12:31:52 +04:00
Kirill Andreev
f3c537d2ca
Make it parse let-expressions 2020-08-11 12:31:52 +04:00
Kirill Andreev
ad7650ea48
Stabilise parsing of let-expressions 2020-08-11 12:31:51 +04:00
Kirill Andreev
0cec59988e
Prevent many/some from making last error-element 2020-08-11 12:31:51 +04:00
Kirill Andreev
00b4dabe36
Add Pretty instance to AST, Error and Range 2020-08-11 12:31:51 +04:00
Kirill Andreev
efe1afb61d
Add byte offsets to Range 2020-08-11 12:31:50 +04:00
Kirill Andreev
c603cd399d
Refactor AST -> types/parser, extract Range/Printer 2020-08-11 12:31:50 +04:00
Kirill Andreev
017db45f8d
Fix bulk of function header parser 2020-08-11 12:31:50 +04:00
Kirill Andreev
cb40392554
Add README.md with install/run instructions 2020-08-11 12:31:49 +04:00
Kirill Andreev
510cda6613
Initial commit of LIGO tooling 2020-08-11 12:31:49 +04:00
Gabriel Alfour
0c0889f514 Merge branch 'optimize-inserted-michelson' into 'dev'
Optimize inserted michelson

See merge request ligolang/ligo!714
2020-07-05 07:36:10 +00:00
Tom Jack
9b4e881827 fix expect test 2020-07-04 23:16:54 -05:00
Tom Jack
b905c49579 Beta-reduce "inserted" Michelson lambdas 2020-07-04 16:36:27 -05:00
Tom Jack
fcb6647551 Strip annots in PUSH type 2020-07-04 16:36:26 -05:00
Sander
0b0de1ea59 Merge branch 'rinderknecht@fix-verbatim' into 'dev'
Improved the lexing of verbatim strings for Michelson inclusion

See merge request ligolang/ligo!713
2020-07-04 13:02:22 +00:00
Christian Rinderknecht
ca50603a7c Added to the scanning of verbatim strings: new line and preprocessor
line directive.
2020-07-04 14:38:47 +02:00
Jev Björsell
c489989cd3 Merge branch 'disable_id_contract_examples' into 'dev'
chore(ide) Disable the ID Example contracts until LIGO-676 is resolved

See merge request ligolang/ligo!711
2020-07-03 18:17:06 +00:00
Jev Björsell
61898eb52d
chore(ide) Disable the ID Example contracts until LIGO-676 is resolved 2020-07-03 10:42:50 -07:00
Gabriel Alfour
42c0baa00b Merge branch 'dont-trace-strong' into 'dev'
Remove a trace_strong in compiler

See merge request ligolang/ligo!710
2020-07-03 16:22:42 +00:00
Rémi Lesenechal
99448ef371 Merge branch '199-add-an-option-to-specify-output' into 'dev'
Resolve "Add an option to specify output"

Closes #199

See merge request ligolang/ligo!704
2020-07-03 13:45:48 +00:00
Tom Jack
cbf1680e36 Remove trace_strong in compiler 2020-07-03 08:24:50 -05:00
Rémi
ec2c1571af CLI: --output option for compile-contract 2020-07-03 14:35:45 +02:00
Lesenechal Remi
ab773a56a4 errors are printed to std err:
this has the weird side effect to indent the error after 'ligo: error'
2020-07-03 14:32:43 +02:00
Rémi Lesenechal
567515a5ce Merge branch 'feature/initial_req_serokell' into 'dev'
get-scope command

See merge request ligolang/ligo!690
2020-07-03 11:57:53 +00:00
Lesenechal Remi
f25c9bd33a get-scope: adding a test with includes 2020-07-03 12:37:35 +02:00
Pierre-Emmanuel Wulfman
93d96b2e7b Merge branch 'fix/order_of_match_bool' into 'dev'
Fix matching bool

See merge request ligolang/ligo!700
2020-07-02 21:42:11 +00:00
Pierre-Emmanuel Wulfman
2893fc0412 fix detection of matching on bool in the spiller 2020-07-02 23:21:14 +02:00
Rémi Lesenechal
43b70361bc Merge branch 'gardening/improve_on_error_formatting' into 'dev'
bunch of fixes to the PPs

See merge request ligolang/ligo!705
2020-07-02 18:10:56 +00:00
Rémi
d0071ca0e8 bunch of fixes to the PPs:
* Now uses the expression variable location in constant declaration tracer
* switched to horizontal boxes for record/sum types PP's
* removed weird indentation
2020-07-02 18:17:11 +02:00
Tom Jack
2f0ffc10ac Merge branch 'dont-strip-annots' into 'dev'
Don't strip annots when running Michelson

See merge request ligolang/ligo!701
2020-07-02 09:29:38 +00:00
Christian Rinderknecht
3656d9e1ff Merge branch 'rinderknecht@pprint_comments' into 'dev'
Refactoring of the build of the front-end

See merge request ligolang/ligo!698
2020-07-01 19:12:01 +00:00
Christian Rinderknecht
6c50ec0ed1 Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@pprint_comments 2020-07-01 20:49:05 +02:00
Rémi Lesenechal
42893548c5 Merge branch 'gardening/bad_pp_error_stacking' into 'dev'
gardening: fix bad error PP that can appear in tests

See merge request ligolang/ligo!703
2020-07-01 16:54:20 +00:00
Lesenechal Remi
e1177de402 fix bad error PP that can appear in tests 2020-07-01 16:40:12 +02:00
Lesenechal Remi
6a3ab09f7c get_scope: scopes for records update/access, constants and applications 2020-07-01 15:37:49 +02:00
Lesenechal Remi
728cf3f1ba get_scope fixes:
- merge inner_def maps in the main fold
- make use of the expression variable locations
2020-07-01 13:10:52 +02:00
Tom Jack
01423174b2 Don't strip annots when running Michelson
This fixes a bug in `compile-parameter` etc when the value contains
lambdas containing important annotations.
2020-07-01 04:40:03 -05:00
Lesenechal Remi
f9b3887753 get_scope : fix definition_id bug 2020-07-01 01:22:10 +02:00
Lesenechal Remi
50a1e48f28 get_scope command: fix recursive handling 2020-07-01 01:22:10 +02:00
Lesenechal Remi
8a551114c3 ignore generated variables 2020-07-01 01:22:10 +02:00
Lesenechal Remi
4026411e10 get-scope --with-types flag 2020-07-01 01:22:10 +02:00
Lesenechal Remi
21904f7e53 get_scope command : tests 2020-07-01 01:22:10 +02:00
Lesenechal Remi
2659570b8a get-scope command. New module Ligo.scopes 2020-07-01 01:22:10 +02:00
Lesenechal Remi
2a9ef440db to_json for locations 2020-07-01 01:22:10 +02:00
Lesenechal Remi
ca2ec3d795 use Yojson.t isntead of Yojson.Basic.t 2020-07-01 01:22:10 +02:00
Rémi Lesenechal
bff67e3779 Merge branch 'feature/expression_variable_locations' into 'dev'
Location for expression variable in the AST's

See merge request ligolang/ligo!699
2020-06-30 22:30:09 +00:00
Tom Jack
ead7832c50 Fix some polymorphic comparison bugs 2020-06-30 14:31:04 -05:00
Lesenechal Remi
e9db0afffa WIIP 2020-06-30 19:15:04 +02:00
Christian Rinderknecht
b304b82e11 Merge branch 'dev' into rinderknecht@pprint_comments 2020-06-30 17:10:48 +02:00
Christian Rinderknecht
d1b7388550 Refactoring of the dune files, minimised dependencies. 2020-06-30 14:34:15 +02:00
Pierre-Emmanuel Wulfman
b1ccaef07e Merge branch 'feature/transpiler' into 'dev'
Feature/transpiler

See merge request ligolang/ligo!696
2020-06-29 13:05:35 +00:00
Pierre-Emmanuel Wulfman
bc259fcde7 Feature/transpiler 2020-06-29 13:05:34 +00:00
Rémi Lesenechal
12f7b7c904 Merge branch 'typer-error-revert-rename' into 'dev'
Rename "Compare" module

See merge request ligolang/ligo!695
2020-06-24 19:54:17 +00:00
Suzanne Dupéron
0dc4315359 compare (lowercase) has a bit of a special meaning in OCaml, renaming the Compare module to Compare_types for now to avoid potential confusion (?) 2020-06-24 20:23:36 +01:00
Rémi Lesenechal
e319e2d2cd Merge branch 'typer-error-revert' into 'dev'
Typer error revert

See merge request ligolang/ligo!689
2020-06-24 17:44:31 +00:00
Lesenechal Remi
351018f8d2 errors for compare in the new typer 2020-06-24 19:24:08 +02:00
Suzanne Dupéron
9e02cb2969 Merge branch 'feature-weakly-typed-adt-creation' into 'dev'
ADT generator support to help building a JSON deserializer

See merge request ligolang/ligo!686
2020-06-24 10:33:37 +00:00
Suzanne Dupéron
1bd7af80b8 Merge branch 'feature-new-typer-14-debug-prints' into 'dev'
Debug prints for the new typer (guarded by a conditional)

See merge request ligolang/ligo!685
2020-06-24 10:18:44 +00:00
Suzanne Dupéron
5589d47123 Merge branch 'bugfix-temporarily-disable-webide-test' into 'dev'
Temporarily disable webide stage because it contains a randomly failing test

See merge request ligolang/ligo!693
2020-06-24 10:18:37 +00:00
Suzanne Dupéron
a4e414bd76 Temporarily disable webide stage, because it contains a randomly failing test. 2020-06-24 10:37:57 +01:00
Christian Rinderknecht
2eb16c2c56 Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@pprint_comments 2020-06-24 11:20:13 +02:00
Christian Rinderknecht
b07c57c159 Fixed variable. 2020-06-24 11:19:56 +02:00
Suzanne Dupéron
942000065b Weakly-typed creation of ADT elements 2020-06-24 02:07:02 +01:00
Suzanne Dupéron
c1d211d98c Debug prints for the new typer: output JSON 2020-06-24 02:07:02 +01:00
Suzanne Dupéron
1cc64d6812 reasons for failing tests 2020-06-24 02:07:02 +01:00
Suzanne Dupéron
283dcf418a Debug prints for the new typer 2020-06-24 02:07:02 +01:00
Suzanne Dupéron
bd8a57df44 Add a pretty-printer to the heuristics 2020-06-24 02:07:02 +01:00
Suzanne Dupéron
018e269b2e Have separate ppf and Yojson modules for PP_json 2020-06-24 02:07:02 +01:00
Suzanne Dupéron
65161148d3 Merge branch 'feature/new-typer-13-json-printer' into 'dev'
JSON printer to debug the new typer

See merge request ligolang/ligo!684
2020-06-23 22:47:18 +00:00
Rémi Lesenechal
2351dda44e Apply 1 suggestion(s) to 1 file(s) 2020-06-23 23:19:24 +01:00
Rémi Lesenechal
362e33c7f9 Apply 1 suggestion(s) to 1 file(s) 2020-06-23 23:19:24 +01:00
Rémi Lesenechal
27d7856e52 Apply 1 suggestion(s) to 1 file(s) 2020-06-23 23:19:24 +01:00
Rémi Lesenechal
d743605aee Apply 1 suggestion(s) to 1 file(s) 2020-06-23 23:19:24 +01:00
Lesenechal Remi
b4bf0ae159 using yojson to print typed AST program 2020-06-23 23:19:24 +01:00
Suzanne Dupéron
db051e7d3b Generic JSON pretty-printer for the typer's AST 2020-06-23 23:19:24 +01:00
Suzanne Dupéron
7a2e4b35d2 Merge branch 'fix/compare_sum_type_error' into 'dev'
[LIGO-674] rework error when comparing two sum types

See merge request ligolang/ligo!682
2020-06-23 22:13:52 +00:00
Suzanne Dupéron
242d99fd5e Improve error message 2020-06-23 22:51:29 +01:00
Lesenechal Remi
0cf9dc576e rework error when comparing two sum types 2020-06-23 22:45:16 +01:00
Suzanne Dupéron
ae4a13b63f Merge branch 'bugfix-url-mainnet-tezos' into 'dev'
Update URL to tezos documentation (the /mainnet/ path component was removed)

See merge request ligolang/ligo!692
2020-06-23 21:27:39 +00:00
Suzanne Dupéron
5cbeab0a3b Use xrefcheck's config to increase the timeout 2020-06-23 21:58:11 +01:00
Suzanne Dupéron
2b790b0ebc Disable remote link checks and use static version of xrefcheck because it's faster to install than the whole Haskell environment 2020-06-23 21:48:27 +01:00
Suzanne Dupéron
72bff930cc Update URL to tezos documentation (the /mainnet/ path component was removed) 2020-06-23 21:17:11 +01:00
Suzanne Dupéron
591f28014d Merge branch 'bugfix-typer-12' into 'dev'
Batch of small fixes for the new typer

See merge request ligolang/ligo!683
2020-06-23 19:36:25 +00:00
Suzanne Dupéron
64c6b8896d comment 2020-06-23 18:38:22 +02:00
Suzanne Dupéron
19f02a4b36 bugfix: forgot to explicitly discard new typer state 2020-06-23 18:38:22 +02:00
Suzanne Dupéron
424a0b0ba7 Bugfix: equality 2020-06-23 18:38:22 +02:00
Suzanne Dupéron
2c5f1f0e2b Bugfix in printer 2020-06-23 18:38:22 +02:00
Rémi Lesenechal
60c4f591fb Merge branch 'fix/xreftest' into 'dev'
fixing broken links

See merge request ligolang/ligo!691
2020-06-23 16:08:04 +00:00
Lesenechal Remi
18e645c73f fixing broken links 2020-06-23 17:12:55 +02:00
Pierre-Emmanuel Wulfman
8e558041f0 Merge branch 'refactor/passes' into 'dev'
Rename passes and refactor them

See merge request ligolang/ligo!679
2020-06-23 14:59:13 +00:00
Pierre-Emmanuel Wulfman
02d66cf536 rename operators to predefined 2020-06-23 16:35:30 +02:00
Pierre-Emmanuel Wulfman
aa849f6dcb renaming of passes 2020-06-23 16:35:28 +02:00
Suzanne Dupéron
c539f2d5f6 Merge branch 'balsoft/xrefcheck' into 'dev'
Check for invalid references in documentation on CI

See merge request ligolang/ligo!669
2020-06-23 12:40:54 +00:00
Christian Rinderknecht
d34b345edc Merged first changes towards handling comments. Refactoring. 2020-06-23 11:52:39 +02:00
Christian Rinderknecht
3ec21a8762 Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@pprint_comments 2020-06-23 01:23:33 +02:00
Christian Rinderknecht
77eb1335a1 Merge branch 'rinderknecht@fix-sequences' into 'dev'
[CameLIGO] Fix parsing of sequences

See merge request ligolang/ligo!688
2020-06-22 22:58:59 +00:00
Christian Rinderknecht
c379d1078e Fixed builds of ParserMain.exe. Fixed parser (code_inj). 2020-06-23 00:37:57 +02:00
Christian Rinderknecht
e42381fb84 Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@fix-sequences 2020-06-22 21:50:42 +02:00
Christian Rinderknecht
fb4a888867 Merge branch 'rinderknecht@code_inclusion' into 'dev'
Improved code injection

See merge request ligolang/ligo!680
2020-06-22 19:36:45 +00:00
Christian Rinderknecht
94039c4d65 Added back return instead of ok. 2020-06-22 16:29:32 +02:00
Christian Rinderknecht
bc5a5cd75b Move ESeq back to its original semantic action. 2020-06-20 20:03:04 +02:00
Christian Rinderknecht
8f4ed11539 Added comments. 2020-06-20 18:10:18 +02:00
Christian Rinderknecht
92e6d55aa8 Improved code injection. Fixed a few bugs on the way. 2020-06-20 18:10:17 +02:00
Christian Rinderknecht
e26b142c3c Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@fix-sequences 2020-06-20 15:50:13 +02:00
Christian Rinderknecht
8ce7ae0f27 Fixed the parsing of sequences in CameLIGO. 2020-06-20 15:49:52 +02:00
Pierre-Emmanuel Wulfman
46bd0315e2 Merge branch 'contract/basic_multisig' into 'dev'
Add a basic multisig contrat

See merge request ligolang/ligo!643
2020-06-19 11:24:28 +00:00
Pierre-Emmanuel Wulfman
36df068dfc wip: new error monad 2020-06-19 12:56:13 +02:00
ae8a3752ef
Check for invalid references on CI 2020-06-19 11:32:50 +03:00
Pierre-Emmanuel Wulfman
027f73fa01 Merge branch 'refactor/simplifier' into 'dev'
Redesign Pascaligo simplifier

See merge request ligolang/ligo!678
2020-06-19 05:48:11 +00:00
Pierre-Emmanuel Wulfman
98487d8bb7 Add a basic multisig contract 2020-06-18 18:23:18 +02:00
Pierre-Emmanuel Wulfman
c2e4f2f36d Add pp can assert_value_eq for Literal_op 2020-06-18 18:23:16 +02:00
Pierre-Emmanuel Wulfman
c8b8492ed9 remaking PacscaLIGO simplifier 2020-06-18 17:53:00 +02:00
Christian Rinderknecht
988776bd31 Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@code_inclusion 2020-06-15 18:16:16 +02:00
Christian Rinderknecht
b3da13251c Added comments. 2020-06-15 18:16:03 +02:00
Rémi Lesenechal
429a1dc412 Merge branch 'refactor/display-and-result' into 'dev'
Refactoring:  errors / formatting / display

See merge request ligolang/ligo!519
2020-06-15 14:46:50 +00:00
Lesenechal Remi
4969b34225 more annotation on the global error type 2020-06-15 15:33:32 +02:00
Lesenechal Remi
3fd93fc7b5 result monad refactoring: update test 2020-06-15 15:25:40 +02:00
Lesenechal Remi
c6b95bf07a result monad refactoring:
- do not use plain JSON rep for errors and use polymorphic variants instead
- split formatting for human readable and JSON output
- no more simple_errors simple_fails
- much less result bindings used in stages
2020-06-15 14:45:28 +02:00
Christian Rinderknecht
05923fbb4c Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@code_inclusion 2020-06-12 18:00:28 +02:00
Christian Rinderknecht
a7f6de9fac Improved code injection. Fixed a few bugs on the way. 2020-06-12 17:49:21 +02:00
Sander
d53be83490 Merge branch 'bytes-sub-change' into 'dev'
Update bytes.sub doc.

See merge request ligolang/ligo!676
2020-06-11 16:03:09 +00:00
Sander Spies
9eabec28dc Update bytes.sub doc. 2020-06-11 17:49:48 +02:00
ed3f2dcbff
Fix invalid references 2020-06-11 15:56:10 +03:00
Pierre-Emmanuel Wulfman
1c5ea4b3f2 Merge branch 'feature/code_insertion' into 'dev'
Code insertion in Ligo

See merge request ligolang/ligo!579
2020-06-11 09:55:19 +00:00
Pierre-Emmanuel Wulfman
195175287a review 2 2020-06-11 11:40:45 +02:00
Sander
c6ad617524 Merge branch 'doc-failwith' into 'dev'
Documentation improvements

See merge request ligolang/ligo!666
2020-06-11 09:28:19 +00:00
Sander Spies
9ea4c97dd4 Merge branch 'doc-failwith' of https://gitlab.com/ligolang/ligo into doc-failwith 2020-06-11 11:13:32 +02:00
Sander Spies
8937b762cd Merge branch 'dev' of https://gitlab.com/ligolang/ligo into doc-failwith 2020-06-11 11:12:59 +02:00
Pierre-Emmanuel Wulfman
44ee2be055 rebase on dev 2020-06-11 10:56:01 +02:00
Pierre-Emmanuel Wulfman
0b8effbf2b move the work from lexer to parser: this makes the rules symetrics but impose the language to have the same syntax as constructor. This may change in the future 2020-06-11 10:10:08 +02:00
Pierre-Emmanuel Wulfman
f25456a7a6 remove unsed symbol in parsers 2020-06-11 09:32:37 +02:00
Pierre-Emmanuel Wulfman
c110670a38 fix errors messages in parser 2020-06-11 09:32:36 +02:00
Pierre-Emmanuel Wulfman
dd4abbf46a test passing 2020-06-11 09:14:51 +02:00
Pierre-Emmanuel Wulfman
a4e2fe2447 WIP:handling parsing errors 2020-06-11 09:14:51 +02:00
Tom Jack
97e33a99da Emit LAMBDA directly from compiler 2020-06-11 09:14:51 +02:00
Pierre-Emmanuel Wulfman
dfcccff748 generating good code 2020-06-11 09:14:45 +02:00
Pierre-Emmanuel Wulfman
b044a4fbc5 wip: compiling code that doesn't typecheck 2020-06-11 09:13:29 +02:00
Pierre-Emmanuel Wulfman
5f4e1b83c7 remove {| and |} while transpling + error on wrong language 2020-06-11 09:13:29 +02:00
Pierre-Emmanuel Wulfman
9e5ae133d2 fix old typer 2020-06-11 09:13:28 +02:00
Pierre-Emmanuel Wulfman
fa7cc825eb parser and test 2020-06-11 09:13:21 +02:00
Pierre-Emmanuel Wulfman
7872a1d4bc first attempt 2020-06-11 09:10:44 +02:00
Sander
5365f97f47 Merge branch 'bitwise-examples' into 'dev'
Bitwise pseudomodule examples.

See merge request ligolang/ligo!670
2020-06-10 17:12:25 +00:00
Sander
62e9cd5796 Merge branch 'remove-ghost-selection' into 'dev'
Remove ghost selection on tabs.

See merge request ligolang/ligo!675
2020-06-10 17:12:20 +00:00
Eowyn Dean
fd26ad82cd Changed 'gast' to gas 2020-06-10 17:10:34 +00:00
Sander
82a8ee5697 Merge branch 'rinderknecht@pprint' into 'dev'
Adding a pretty-printer for CameLIGO source files

See merge request ligolang/ligo!599
2020-06-10 15:16:53 +00:00
Christian Rinderknecht
358ae530b8 Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@pprint 2020-06-10 16:59:39 +02:00
Christian Rinderknecht
c57f499fea Final touches to the pretty printers.
Fixed the syntaxes for field_assignment and field_path_assignment.
2020-06-10 16:58:59 +02:00
Sander Spies
a0d2eb733d Remove ghost selection on tabs. 2020-06-10 09:20:19 +02:00
Jev Björsell
29b483aa0c Merge branch 'tools/ligo-snippets-ide-fix' into 'dev'
update to use @ligolang/ligo-snippets@1.0.1

See merge request ligolang/ligo!674
2020-06-10 01:11:02 +00:00
Edmond Lee
eb2facfc11 update to use @ligolang/ligo-snippets@1.0.1 2020-06-09 17:33:50 -07:00
Jev Björsell
22699525b3 Merge branch 'tools/ligo-snippets-ide-fix' into 'dev'
add @babel/plugin-transform-runtime to ligo-snippets

See merge request ligolang/ligo!672
2020-06-10 00:11:52 +00:00
Edmond Lee
582dacf5d5 add @babel/plugin-transform-runtime to ligo-snippets 2020-06-09 16:33:19 -07:00
Jev Björsell
612694d603 Merge branch 'tools/ligo-snippets' into 'dev'
tools/ligo-snippets - add and implement ligo-snippets

See merge request ligolang/ligo!671
2020-06-09 22:39:33 +00:00
Edmond Lee
86a30b1e6f add getLanguageHighlight function to determine the language highlight, and added custom syntax highlighting rules to ligosnippets editor 2020-06-09 22:39:33 +00:00
Sander
34d726c2f3 Apply 1 suggestion(s) to 1 file(s) 2020-06-09 14:32:17 +00:00
Sander
d810ccc921 Apply 1 suggestion(s) to 1 file(s) 2020-06-09 14:32:14 +00:00
Sander
816afdd1b8 Apply 1 suggestion(s) to 1 file(s) 2020-06-09 14:32:07 +00:00
Sander Spies
5470893f68 Bitwise pseudomodule documentation. 2020-06-09 13:15:24 +02:00
Suzanne Dupéron
206f52d8e6 Merge branch 'balsoft/gitignore' into 'dev'
Improve nix gitignore

See merge request ligolang/ligo!667
2020-06-08 17:11:43 +00:00
Christian Rinderknecht
dfbba95cbf Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@pprint 2020-06-08 16:05:23 +02:00
Pierre-Emmanuel Wulfman
94a3c1c3da Merge branch 'gardening/fix-ast' into 'dev'
Refactoring in the ast

See merge request ligolang/ligo!665
2020-06-08 13:32:52 +00:00
Sander Spies
a688a1afe4 ReasonLIGO improvements. 2020-06-08 15:24:36 +02:00
Sander Spies
cee9cc841e More fixes for PascaLIGO. 2020-06-08 15:07:20 +02:00
Sander Spies
a58dca7097 Add PascaLIGO pretty printer tests. 2020-06-08 15:00:44 +02:00
Sander Spies
d7b4a97731 PascaLIGO fixes. 2020-06-08 15:00:10 +02:00
046f31f7c1
Nix: apply gitignore on sources 2020-06-08 14:50:51 +03:00
Sander Spies
aee524ffc4 Use correct file input for idempotent testing of CameLIGO contracts. 2020-06-08 13:48:54 +02:00
cb11295405
Add nix artifacts to gitignore 2020-06-08 14:41:23 +03:00
Sander Spies
4382c3c042 Merge fixes. 2020-06-08 13:27:24 +02:00
Sander Spies
c770aa3541 Merge branch 'rinderknecht@pprint' of https://gitlab.com/ligolang/ligo into reasonligo-pretty-printer 2020-06-08 13:23:03 +02:00
Sander Spies
eea9d8f627 Move types to toplevel. 2020-06-08 13:12:42 +02:00
Christian Rinderknecht
838fdf6a5f Fixed build. 2020-06-08 12:40:14 +02:00
Christian Rinderknecht
2d65ba638e Updated syntax error messages. 2020-06-08 12:06:19 +02:00
Christian Rinderknecht
8d291b2d2e Finished v1 of PascaLIGO pretty-printer. 2020-06-08 11:59:58 +02:00
Sander Spies
b76d44e9f2 Change loops to iteration and hide bounded loops section for CameLIGO and ReasonLIGO 2020-06-08 11:58:46 +02:00
Sander Spies
d99d1bbe66 Improve failwith description. 2020-06-08 11:58:23 +02:00
Christian Rinderknecht
534447dc9e More printers. 2020-06-08 00:19:05 +02:00
Christian Rinderknecht
bfac7f3b0a * Fixed AST node for_int (step clause)
* Fixed Parser and ParserLog (step clause missing).
  * Added more printers.
2020-06-06 20:47:31 +02:00
Christian Rinderknecht
77920a1c58 Fixed parsing of lambdas (cannot be recursive) in PascaLIGO.
Added more to the pretty-printing of PascaLIGO.
Improved pretty-printing of CameLIGO.
2020-06-05 23:24:49 +02:00
Pierre-Emmanuel Wulfman
574903ed2f fix name 2020-06-05 18:20:43 +02:00
Pierre-Emmanuel Wulfman
be9478bec1 Refactor updates and accessors 2020-06-05 18:17:17 +02:00
Sander Spies
cb39217c8c Improve ReasonLIGO pretty printer output. 2020-06-05 16:20:31 +02:00
Sander Spies
63086db0f1 More ReasonLIGO pretty printer improvements. 2020-06-05 16:01:18 +02:00
Sander Spies
db0fdf4abd Improve ReasonLIGO output. 2020-06-05 14:26:32 +02:00
Sander Spies
49d2c870ae Change names. 2020-06-05 13:02:23 +02:00
Sander Spies
623e6f1251 Add tests for CameLIGO. 2020-06-05 12:51:37 +02:00
Sander Spies
54cefddd51 Merge 2020-06-05 12:27:06 +02:00
Sander Spies
9495901b75 Merge 2020-06-05 12:23:32 +02:00
Sander Spies
3dd4568a3d Cleanup. 2020-06-05 12:21:40 +02:00
Sander Spies
4c2a271898 Fix small printing bug. 2020-06-05 11:32:30 +02:00
Sander Spies
a952cc496d Fix not properly handling function types as arguments. 2020-06-05 10:47:23 +02:00
Sander Spies
57caa4ea85 More testing and fine tuning. 2020-06-04 21:36:12 +02:00
Christian Rinderknecht
6f56b297f2 Improved the pretty-printers. 2020-06-04 19:01:31 +02:00
Pierre-Emmanuel Wulfman
5896b2a63a Add new matching cases and fix compilation of match_tuples 2020-06-04 16:37:18 +02:00
Christian Rinderknecht
a6972bf28b Putting back .links. 2020-06-04 14:59:15 +02:00
Christian Rinderknecht
8606528ddb More pretty-printing. 2020-06-04 14:55:40 +02:00
Christian Rinderknecht
3bec051115 Added back test LIGO input. 2020-06-04 13:32:35 +02:00
Christian Rinderknecht
c67fc4aa34 Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@pprint 2020-06-04 13:26:29 +02:00
Christian Rinderknecht
adee60c444 Improved example for testing the pretty-printer. 2020-06-04 13:26:03 +02:00
Sander Spies
64076d882b Merge 2020-06-04 10:27:19 +02:00
Sander Spies
fbc854f4d1 Improve ReasonLIGO pretty printing output. 2020-06-04 10:05:33 +02:00
Sander Spies
c30ade3b85 Contracts now compile. 2020-06-04 09:54:25 +02:00
Francis Brunelle
5cfe6e893c Merge branch 'website-changes' into 'dev'
Update the Contact page and other minor improvements to the website

See merge request ligolang/ligo!607
2020-06-03 22:30:39 +00:00
Francis Brunelle
10b373e8fc
Update the Contact page and other minor improvements to the website 2020-06-03 18:18:40 -04:00
Jev Björsell
f7069de52d Merge branch 'webide/update-example-names' into 'dev'
webide/update to shorten example names in webide

See merge request ligolang/ligo!660
2020-06-03 17:41:03 +00:00
Edmond Lee
18bf6f92e4 update to shorten example names in webide 2020-06-03 09:55:37 -07:00
Jev Björsell
ac124b0c4d Merge branch 'webide/update-example-names' into 'dev'
webide/update webide example names for consistency

See merge request ligolang/ligo!659
2020-06-03 16:14:48 +00:00
Edmond Lee
7d65000e2a add comment to development example list 2020-06-03 09:01:55 -07:00
Edmond Lee
2b0f3ce969 update webide example names for consistency 2020-06-03 08:46:09 -07:00
Jev Björsell
2032485b60 Merge branch 'feature/use-wallet-api-for-contract-origination' into 'dev'
Update Ligo IDE to use new Wallet API

See merge request ligolang/ligo!654
2020-06-03 14:31:01 +00:00
Pierre-Emmanuel Wulfman
c380729785 Merge branch 'gardening/fix-ast' into 'dev'
Change T_operator in the AST and Reorder folder

See merge request ligolang/ligo!656
2020-06-03 12:54:24 +00:00
Pierre-Emmanuel Wulfman
8f529a059a reorder folder 2020-06-03 14:47:36 +02:00
Pierre-Emmanuel Wulfman
cc615f1c9f Change type_operator 2020-06-03 14:29:46 +02:00
Pierre-Emmanuel Wulfman
b29c667901 Merge branch 'feature-cleanup-typer-13' into 'dev'
Cleanup of the solver, use a list of heuristics instead of hardcoding them

See merge request ligolang/ligo!657
2020-06-03 12:28:36 +00:00
Suzanne Dupéron
81358db582 Cleanup of solver.ml, separated the heuristic's definition from its state in the solver (propagator_heuristic vs. propagator_state) 2020-06-03 13:07:48 +01:00
Suzanne Dupéron
7257aaaff4 Solver: use a list of heuristics instead of hardcoding them. 2020-06-03 13:07:48 +01:00
Suzanne Dupéron
861ab57a43 move solver_types to typesystem/ (because of dependencies. It should be merged with the AST really) 2020-06-03 13:07:41 +01:00
Sander Spies
c8ed8c38cc ReasonLIGO pretty printing testing. 2020-06-03 12:41:26 +02:00
Roxane Letourneau
4c56515d6b Add missing update to lock file 2020-06-02 21:08:26 -07:00
Jev Björsell
dc17676447 Merge branch 'webide/generate-deploy-script' into 'dev'
webide / generate deploy script updates

See merge request ligolang/ligo!653
2020-06-02 22:10:06 +00:00
Edmond Lee
d18837a6a6 add generate deploy script default values to id cameligo example 2020-06-02 14:51:16 -07:00
Roxane Letourneau
a28b81379f Update Ligo IDE to use new Wallet API 2020-06-02 14:37:33 -07:00
Christian Rinderknecht
562f08dabc Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@pprint 2020-06-02 22:14:14 +02:00
Christian Rinderknecht
62fe3b793a More cases. 2020-06-02 22:14:06 +02:00
Edmond Lee
c82e3ffa6a add generate deploy script default values to id reasonligo example 2020-06-02 12:53:03 -07:00
Edmond Lee
7fbac4dc1b add generate deploy script default values to id pascaligo example 2020-06-02 12:27:41 -07:00
Edmond Lee
08ee216f1b Merge branch 'dev' of gitlab.com:edmondlee/ligo into webide/generate-deploy-script 2020-06-02 10:29:06 -07:00
Jev Björsell
13eae4be18 Merge branch 'webide/id-example' into 'dev'
[LIGO-499] Add ID layer contract to web IDE examples

See merge request ligolang/ligo!451
2020-06-02 16:45:29 +00:00
Pierre-Emmanuel Wulfman
267e282174 rebase 2020-06-02 17:02:16 +02:00
Jev Björsell
9d0da34f96 Improve formatting of default webide values 2020-06-02 16:56:10 +02:00
technomad21c
a5419d0158 add default parameters for deploy and modify the hashvalue for share-link test 2020-06-02 16:54:47 +02:00
technomad21c
f29cf5a612 add the ID Contract example for cameligo and reasonligo 2020-06-02 16:54:47 +02:00
technomad21c
5b398b47c2 add an ID Contract example 2020-06-02 16:54:47 +02:00
Jev Björsell
fa1185c20e Add new ID example contracts to dev initial state
Remove duplicate def of CURATED_EXAMPLES
2020-06-02 16:54:47 +02:00
Pierre-Emmanuel Wulfman
4d51aa62cb removing wrong dryRun and evaluateFunction in ide examples 2020-06-02 16:54:47 +02:00
Pierre-Emmanuel Wulfman
0c9aeeeb64 checking contracts 2020-06-02 16:54:47 +02:00
Pierre-Emmanuel Wulfman
74dab76fb4 optimizing contract 2020-06-02 16:54:47 +02:00
John David Pressman
e42e79eff3 Add ID contract examples to web ide without command defaults 2020-06-02 16:54:47 +02:00
John David Pressman
37a3fde6fd Add ReasonLIGO version of ID layer contract
Change CameLIGO version tests to say they're for CameLIGO in test suite
2020-06-02 16:54:47 +02:00
John David Pressman
4d16b006c6 Fix PascaLIGO ID contract to pass tests 2020-06-02 16:54:47 +02:00
John David Pressman
4e984850c1 Add syntactically passing PascaLIGO ID contract that does not typecheck 2020-06-02 16:54:47 +02:00
John David Pressman
8d781eebca Refactor id layer contract to use records instead of tuples 2020-06-02 16:54:45 +02:00
Suzanne Dupéron
2112e5dee7 Merge branch 'feature-cleanup-typer-12' into 'dev'
Split the solver into separate files, no meaningful changes to the code

See merge request ligolang/ligo!647
2020-06-02 12:36:24 +00:00
Christian Rinderknecht
b12e9a5baa Aligned printing of tuples of expressions on CameLIGO. 2020-06-01 19:17:59 +02:00
Christian Rinderknecht
db3533bcd4 Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@pprint 2020-06-01 18:47:59 +02:00
Christian Rinderknecht
c376650ee5 More to the PascaLIGO pretty-printer. 2020-06-01 18:47:42 +02:00
Suzanne Dupéron
435716fb34 Merge branch 'revert-1681b33b' into 'dev'
Revert "Merge branch 'ast/tuple_destruct' into 'dev'"

See merge request ligolang/ligo!652
2020-05-31 17:32:47 +00:00
Suzanne Dupéron
2d43f67893 Revert "Merge branch 'ast/tuple_destruct' into 'dev'"
This reverts merge request !650
2020-05-31 17:25:40 +00:00
Suzanne Dupéron
1681b33b12 Merge branch 'ast/tuple_destruct' into 'dev'
Add a sugar operation : Tuple Destructuring

See merge request ligolang/ligo!650
2020-05-31 16:52:56 +00:00
Christian Rinderknecht
2d74681c96 Added more to the PascaLIGO pretty-printer.
Improved the AST of PascaLIGO to better capture the struture.
2020-05-30 20:24:47 +02:00
Christian Rinderknecht
3264277310 Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@pprint 2020-05-30 13:50:43 +02:00
Suzanne Dupéron
6cab827f17 Merge branch 'bugfix-typer-11' into 'dev'
Bugfixes for new typer, volume 11

See merge request ligolang/ligo!640
2020-05-29 19:37:50 +00:00
Suzanne Dupéron
e2bf0f6466 Split the solver into separate files, no meaningful changes to the code. 2020-05-29 21:23:11 +02:00
Suzanne Dupéron
4a860830b9 bugfix: replace very bogus implementation of add_list with a clean one 2020-05-29 21:23:11 +02:00
Suzanne Dupéron
d5a6f46452 Fix indentation of one function (only whitespace change) 2020-05-29 21:23:11 +02:00
Suzanne Dupéron
b2ee003577 bugfix: new typer did not keep the state between the program and the test case's function call 2020-05-29 21:23:08 +02:00
Suzanne Dupéron
4cb34a1d7e bugfix: new typer did not check a lambda's result' type against its annotation. 2020-05-29 21:18:57 +02:00
Suzanne Dupéron
2633d732a3 bugfix: Use Var.equal 2020-05-29 21:18:57 +02:00
Suzanne Dupéron
36e4c426c9 assert that the selectors of rules elected constraints that match the propagator's expecations 2020-05-29 21:18:57 +02:00
Suzanne Dupéron
69a007cca9 Describe the reason why a constraint or type was produced for more typer internals 2020-05-29 21:18:57 +02:00
Suzanne Dupéron
6dd296260e Merge branch 'balsoft/show-coverage-reports' into 'dev'
Always show coverage reports&disable webide e2e test

See merge request ligolang/ligo!641
2020-05-29 17:16:15 +00:00
Sander Spies
e9f5c3e1ae Initial work for the ReasonLIGO pretty printer. 2020-05-29 19:07:44 +02:00
Pierre-Emmanuel Wulfman
d644872729 version 2 2020-05-29 17:50:32 +02:00
Pierre-Emmanuel Wulfman
612f8aaf5e vesion 1 2020-05-29 17:50:32 +02:00
Pierre-Emmanuel Wulfman
d5983de522 Merge branch 'gardening/clean-up' into 'dev'
Remove misc module from AST-imperative and AST-sugar

See merge request ligolang/ligo!649
2020-05-29 14:10:22 +00:00
Pierre-Emmanuel Wulfman
b7da8e3fd4 remove unecessary files 2020-05-29 15:30:03 +02:00
Gabriel Alfour
54a0fb63d8 Merge branch 'opt-strip-annots' into 'dev'
Strip type annotations from some instructions

See merge request ligolang/ligo!638
2020-05-28 15:30:29 +00:00
Christian Rinderknecht
4779d12295 Merge branch 'rinderknecht@pprint' of gitlab.com:ligolang/ligo into rinderknecht@pprint 2020-05-28 12:57:06 +02:00
Christian Rinderknecht
96f9c032c0 Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@pprint 2020-05-28 12:52:15 +02:00
Pierre-Emmanuel Wulfman
daf6971fd1 Merge branch 'refactor/remove-environments' into 'dev'
Remove environments from the AST

See merge request ligolang/ligo!646
2020-05-28 09:03:40 +00:00
Pierre-Emmanuel Wulfman
e661416056 review 1 2020-05-28 10:53:54 +02:00
fcfa2944c6
Disable webide-e2e tests 2020-05-28 00:21:00 +03:00
Gabriel ALFOUR
294e048aff remove environments from the ast 2020-05-27 23:01:07 +02:00
Jev Björsell
c19c34d5d3 Merge branch 'website/records_docs' into 'dev'
Website/records docs

See merge request ligolang/ligo!644
2020-05-27 14:58:11 +00:00
Jev Björsell
d53d4829b5 Website/records docs 2020-05-27 14:58:10 +00:00
Edmond Lee
9eb603a1e8 change generate deploy script tool back to hard code of tezos-client 2020-05-26 12:56:38 -07:00
Edmond Lee
78166c13d3 update generate deploy script from hardcoded tezos-client tool to dynamic tool 2020-05-26 11:47:30 -07:00
Edmond Lee
6d6556107a fix merge conflict 2020-05-26 11:35:19 -07:00
Edmond Lee
8e2a889b1d fix merge conflict 2020-05-26 11:28:12 -07:00
Edmond Lee
b816a2e529 update examples to remove command from the generate-deploy-script default configurations 2020-05-26 11:15:17 -07:00
Edmond Lee
dba6335bfc remove the use of toolcommand from generate-deploy-script 2020-05-26 11:14:47 -07:00
1fe9b29732
Always show coverage reports 2020-05-26 20:29:11 +03:00
Edmond Lee
a4831a05e7 remove extra setting for evaluatefunction in pascaligo example 2020-05-26 09:28:52 -07:00
Rémi Lesenechal
bc2d95d6f6 Merge branch 'bug_fix/old_cases_in_transpiler' into 'dev'
bug-fix : remove old code in transpiler& fix env recomputing

See merge request ligolang/ligo!636
2020-05-26 13:51:10 +00:00
Lesenechal Remi
66c1e51cb2 updating tests 2020-05-26 15:39:06 +02:00
Lesenechal Remi
f455fa2376 add a test case for double fold env recomputing 2020-05-26 15:39:06 +02:00
Lesenechal Remi
2de18b8727 solve bug in environment recomputing 2020-05-26 15:39:06 +02:00
Lesenechal Remi
705c29aeed remove old cases in transpiler 2020-05-26 15:39:06 +02:00
Christian Rinderknecht
d4801d942a Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@pprint 2020-05-26 14:53:41 +02:00
Sander Spies
cade57a47c Fix expect help tests. 2020-05-26 12:41:42 +02:00
Sander Spies
88c652a25f Fix issue caused by addition of PPar. 2020-05-26 12:33:32 +02:00
Sander Spies
a4128d037b Add PPar around PTyped for proper pretty printing and CST equality with CameLIGO. 2020-05-26 11:06:38 +02:00
Edmond Lee
a0c6048633 Merge branch 'webide/generate-deploy-script' of gitlab.com:edmondlee/ligo into webide/generate-deploy-script 2020-05-25 16:43:37 -07:00
Edmond Lee
b88348ce60 update ligo examples to add generate-deploy-script tool and command defaults 2020-05-25 16:43:10 -07:00
Suzanne Dupéron
d44b5a7af0 Merge branch 'feature/adt-generator-8-split-modules-and-add-output-module' into 'dev'
ADT generator: split into separate modules and add output module "O"

Closes LIGO-656

See merge request ligolang/ligo!629
2020-05-25 23:23:37 +00:00
Tom Jack
daa1c18573 Strip type annotations from some instructions 2020-05-25 17:42:31 -05:00
Suzanne Dupéron
851132528d auto-generated folds: have a distinct input and output type for the state 2020-05-25 21:49:00 +01:00
Suzanne Dupéron
ee5e484bf4 Use the auto-generated comparators as the implementations for the typeclass-like requirements for comparison functions 2020-05-25 20:42:16 +01:00
Suzanne Dupéron
008f228ed7 Hide the intermediate functions from PP_generic's signature 2020-05-25 20:42:16 +01:00
Suzanne Dupéron
92069077df Auto-generated comparator for AST_typed 2020-05-25 20:42:16 +01:00
Suzanne Dupéron
9a017e5f63 ADT generator: Fixes LIGO-656 Generated fold_maps are unusable because some collection types need extra info (e.g. sets need a comparison operator for their elements) 2020-05-25 20:42:16 +01:00
Suzanne Dupéron
b2d80e0154 Rename src/stages/4-ast_typed/types.ml (part 1: does not build) 2020-05-25 20:42:16 +01:00
Jev Björsell
413dc7cc1b Merge branch 'webide/generate-deploy-script' into 'dev'
Webide/generate deploy script

See merge request ligolang/ligo!637
2020-05-25 18:47:51 +00:00
Jev Björsell
7db2c24bd3 update example.ts, generate-deploy-script.ts, and load-state.ts to support default generateDeployScript values for examples 2020-05-25 18:47:50 +00:00
Jev Björsell
0289565025
fix(types) error are optional 2020-05-25 11:35:09 -07:00
Christian Rinderknecht
b97d2d4000 Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@pprint 2020-05-25 20:31:19 +02:00
Christian Rinderknecht
320e31cb41 * [ligo pretty-print foo.mligo] works.
* [ligo pretty-print foo.religo] is a transpiler (for now) and needs
    more work.

  * Renamed functions *_ast into *_cst. One day, module AST should be
    renamed CST for clarity and consistency.
2020-05-25 20:29:48 +02:00
Edmond Lee
5ae429c4ef Merge branch 'webide/generate-deploy-script' of gitlab.com:edmondlee/ligo into webide/generate-deploy-script 2020-05-25 11:24:06 -07:00
Edmond Lee
5293b2951f update handler errors to optional 2020-05-25 11:22:39 -07:00
Jev Björsell
42989944b3
chore(lock): Freshen lock files 2020-05-25 10:36:43 -07:00
Edmond Lee
85c08d8ad3
update GenerateDeployScript back to GenerateDeployScriptAction in generate-deploy-script.ts 2020-05-25 10:12:41 -07:00
Edmond Lee
22b0c9ec46
add default values generateDeployScript values to example contracts 2020-05-25 10:12:41 -07:00
Edmond Lee
11f1cf01ee
update example.ts, generate-deploy-script.ts, and load-state.ts to support default generateDeployScript values for examples 2020-05-25 10:12:40 -07:00
Edmond Lee
b9ee504dd6
updating generate command to generate deploy script 2020-05-25 10:12:40 -07:00
Edmond Lee
2bf34e9ff5
updating generate command to generate deploy script 2020-05-25 10:12:40 -07:00
Edmond Lee
417bd0f5f8
updating generate command to generate deploy script 2020-05-25 10:12:39 -07:00
Jev Björsell
8041ce5ddb Merge branch 'fix-webide' into 'dev'
Fix webide docker container

See merge request ligolang/ligo!635
2020-05-25 16:00:58 +00:00
76715ebee3
Fix webide docker container 2020-05-25 18:47:40 +03:00
Pierre-Emmanuel Wulfman
2a9a628861 Merge branch 'fix/another-loc' into 'dev'
Fix 2 missing loc in cameligo simplifier EProj et ETuple

See merge request ligolang/ligo!634
2020-05-25 14:08:39 +00:00
Christian Rinderknecht
041a48bc7b [PascaLIGO] Fixed the build of ParserMain.exe. 2020-05-25 16:04:35 +02:00
Sander
1a0db2fc87 Merge branch 'trigger-ci' into 'dev'
Trigger CI

See merge request ligolang/ligo!633
2020-05-25 13:53:18 +00:00
Pierre-Emmanuel Wulfman
41d1f5e1b0 fix 2 missing loc in cameligo simplifier EProj et ETuple 2020-05-25 15:43:57 +02:00
Sander Spies
9163caf3da Trigger CI 2020-05-25 15:41:38 +02:00
Christian Rinderknecht
2d88d2145e Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@pprint 2020-05-25 15:15:27 +02:00
Christian Rinderknecht
7992a4e507 Added cased to test the pretty-printer. 2020-05-25 12:42:19 +02:00
Christian Rinderknecht
6a3dab69a2 Exported pretty-printing function for CameLIGO and ReasonLIGO (transpiler). 2020-05-25 12:37:30 +02:00
Suzanne Dupéron
07320d181d Merge branch 'update-documentation' into 'dev'
Nix fixes

See merge request ligolang/ligo!631
2020-05-22 18:54:19 +00:00
Suzanne Dupéron
a3e330da12 Update installation.md (punctuation) 2020-05-22 18:36:00 +00:00
Suzanne Dupéron
5ef842298d Update installation.md (changed my mind about the wording) 2020-05-22 18:34:14 +00:00
Suzanne Dupéron
ecebfb37cc Update installation.md (grammar) 2020-05-22 18:33:18 +00:00
Edmond Lee
5e14528a9a update GenerateDeployScript back to GenerateDeployScriptAction in generate-deploy-script.ts 2020-05-22 10:56:27 -07:00
Edmond Lee
a7c6eaf910 add default values generateDeployScript values to example contracts 2020-05-21 16:54:40 -07:00
Edmond Lee
8b7594c2d1 update example.ts, generate-deploy-script.ts, and load-state.ts to support default generateDeployScript values for examples 2020-05-21 16:54:17 -07:00
Edmond Lee
0e48b5bb54 updating generate command to generate deploy script 2020-05-21 16:22:33 -07:00
Edmond Lee
b871b7d64f updating generate command to generate deploy script 2020-05-21 15:50:10 -07:00
Edmond Lee
c8b1ff0e9e updating generate command to generate deploy script 2020-05-21 15:27:34 -07:00
b5d1cd6b5b
Run webide e2e tests on merge requests 2020-05-21 19:31:48 +03:00
3d78114b25
Pass COMMIT_DATE to the build 2020-05-21 19:14:41 +03:00
a14bf15e77
Run webide e2e tests 2020-05-21 19:13:11 +03:00
b522e50ce2
Fix webide deploy handoff 2020-05-21 19:03:15 +03:00
91f31f2914
Update install documentation to reflect packaging updates 2020-05-21 18:56:44 +03:00
Suzanne Dupéron
d5089bfa13 Merge branch 'nix-run-dev' into 'dev'
Switch to nix pipelines

See merge request ligolang/ligo!628
2020-05-21 15:26:04 +00:00
b6aa71d6ac
Remove /tmp from docker container 2020-05-21 18:09:35 +03:00
340622350d
Clarify the nix docs by pointing out the location of build results 2020-05-21 18:09:33 +03:00
Suzanne Dupéron
16bcee1aad
Fixes from MR review
- Fix quoting issues in nix/README.md
- Clarify about nix flakes
2020-05-21 18:09:02 +03:00
5c2b9646ec
Update nix-npm-buildpackage 2020-05-21 18:08:25 +03:00
85c7429f0c
Add documentation for nix expressions 2020-05-21 18:08:25 +03:00
f970a9a536
Use extends instead of anchors in gitlab-ci.yml 2020-05-21 18:08:24 +03:00
e8a69cb498
Switch to nix pipelines
- Remove old pipelines
- Run nix pipelines on a private runner
2020-05-21 18:08:22 +03:00
Jev Björsell
a72d95d9a1 Merge branch 'webide-share-logo-fix' into 'dev'
update logo src

See merge request ligolang/ligo!624
2020-05-20 22:59:02 +00:00
Sander
bd9b3cb012 Merge branch 'rinderknecht@sequences' into 'dev'
Fixing the parsing of sequences in CameLIGO and ReasonLIGO

See merge request ligolang/ligo!605
2020-05-20 16:36:45 +00:00
Christian Rinderknecht
36cecfb019 * Renamed AST.TStringLiteral into AST.TString
* Fixed parsing of "begin let x = e1 in e2; e3 end"
2020-05-20 16:36:44 +00:00
Gabriel Alfour
dd970385e4 Merge branch 'galfour@minor-optim' into 'dev'
Minor optimization

See merge request ligolang/ligo!613
2020-05-19 23:21:25 +00:00
galfour
0199f3e448 produce I_LAMBDA instead of I_PUSH directly for functions 2020-05-19 23:53:55 +02:00
Pierre-Emmanuel Wulfman
ea306bf685 Merge branch 'fix/srcloc_different_constructor' into 'dev'
FIX/Solve two bug with location

See merge request ligolang/ligo!627
2020-05-19 21:49:23 +00:00
Pierre-Emmanuel Wulfman
e04918047c Merge branch 'fix/srloc_in_mini-c' into 'dev'
fix/Add srcloc in mini-c

See merge request ligolang/ligo!582
2020-05-19 21:37:40 +00:00
Pierre-Emmanuel Wulfman
85dc95dc7b solve to bug with location 2020-05-19 18:53:20 +02:00
Sander
7f32937d6d Merge branch 'interop-doc' into 'dev'
Interop docs

See merge request ligolang/ligo!537
2020-05-19 15:49:09 +00:00
Sander
a0f8bd941e Interop docs 2020-05-19 15:49:09 +00:00
Jev Björsell
e6e1bc5876 Merge branch 'contract/F1.2_example' into 'dev'
TZIP-12: FA1.2 example contract

See merge request ligolang/ligo!600
2020-05-19 15:28:02 +00:00
Pierre-Emmanuel Wulfman
0f7fde19f5 Merge branch 'fix/region_simplifier' into 'dev'
fix/keep region information in the cameligo simplifier

See merge request ligolang/ligo!617
2020-05-18 14:32:42 +00:00
Pierre-Emmanuel Wulfman
fdb7697806 Merge branch 'fix/comparable-pair' into 'dev'
Allow comparison of "comparable pair"

See merge request ligolang/ligo!616
2020-05-18 14:32:36 +00:00
Pierre-Emmanuel Wulfman
551bf176fe add srcloc in mini-c 2020-05-18 15:47:59 +02:00
Christian Rinderknecht
114a309aed Merge branch 'feature/Varbatim_string' into 'dev'
Add Verbatim string in the compiler

See merge request ligolang/ligo!592
2020-05-18 13:29:00 +00:00
Pierre-Emmanuel Wulfman
6c8b76b3de add verbatim in lexer and parser 2020-05-18 13:28:31 +02:00
Pierre-Emmanuel Wulfman
f6ff6b85c4 add ligo_string in simple_utils 2020-05-18 12:56:47 +02:00
Christian Rinderknecht
281477bbaf Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@pprint 2020-05-18 11:01:54 +02:00
Christian Rinderknecht
2db55ae965 Merge branch 'rinderknecht@fix_endif' into 'dev'
[Preprocessor] Missing scanning rules for eof and newline and changing the semantics of conditionals

See merge request ligolang/ligo!621
2020-05-16 18:23:25 +00:00
Christian Rinderknecht
255e381e01 Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@fix_endif 2020-05-16 18:55:02 +02:00
Edmond Lee
ae3a555c91 update logo src 2020-05-15 17:32:49 -07:00
Jev Björsell
9ead5f2f24 Merge branch 'patch-2' into 'dev'
fix wrong source code path and missing opening quote

See merge request ligolang/ligo!622
2020-05-15 22:43:28 +00:00
Brandon Jeong
2934e49f93 fix wrong source code path and missing opening quote 2020-05-15 19:58:34 +00:00
Christian Rinderknecht
1c9240703c Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@fix_endif 2020-05-15 21:24:57 +02:00
Christian Rinderknecht
34b9ee14da [Bug fix] Case #include followed by newline or eof.
I added cases for scanning eof (followed by a rollback).
2020-05-15 21:23:49 +02:00
Christian Rinderknecht
c021254cd4 Merge branch 'rinderknecht@fix_preprocessor' into 'dev'
[Bug] I forgot the check whether to perform #include or not.

See merge request ligolang/ligo!619
2020-05-15 18:07:31 +00:00
Ligo Lang
57f0106fd4 Merge branch 'versioning/tests' into 'dev'
Versioning/tests

See merge request ligolang/ligo!618
2020-05-15 17:43:04 +00:00
f7a2bffd77 Merge branch 'balsoft/nix-update' into 'dev'
Fix website build by updating package-lock.json

See merge request ligolang/ligo!614
2020-05-15 17:18:45 +00:00
Christian Rinderknecht
b44da17ee0 [Bug] I forgot the check whether to perform #include or not. 2020-05-15 18:31:01 +02:00
Pierre-Emmanuel Wulfman
7244b91c45 fix/keep region information in the simplifier 2020-05-15 18:28:24 +02:00
Lesenechal Remi
41eded82f4 versioning stage in gitlab-ci.yml 2020-05-15 17:57:22 +02:00
Lesenechal Remi
9e81aaa1f8 script tagging branch 2020-05-15 17:56:00 +02:00
Pierre-Emmanuel Wulfman
0ccc637c9b Allow comparison of "comparable pair" (left is a simple comparable type, right is a comparable type) 2020-05-15 17:25:23 +02:00
Christian Rinderknecht
937bc99738 Finished second version based on test contracts. 2020-05-15 16:32:30 +02:00
Christian Rinderknecht
f3ed135926 More fixes to the pretty-printer. 2020-05-15 00:44:15 +02:00
Christian Rinderknecht
ec0a0dbd01 More pretty-printing. 2020-05-14 21:09:14 +02:00
a2557d7893
Fix website build by updating package-lock.json 2020-05-14 15:13:50 +03:00
Christian Rinderknecht
44c85daee4 Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@pprint 2020-05-13 21:02:17 +02:00
Christian Rinderknecht
85aa1a21d1 Some expressions remain to be pretty-printed.
Fixed a bug in the semantic action of the parser for record updates.
2020-05-13 21:01:27 +02:00
Pierre-Emmanuel Wulfman
7bcf46d3bc Merge branch 'refactoring_mini-c_type' into 'dev'
Refactor Mini-c types for conformity with the other stage

See merge request ligolang/ligo!598
2020-05-13 11:01:20 +00:00
Christian Rinderknecht
262f34f214 Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@pprint 2020-05-12 19:25:30 +02:00
Christian Rinderknecht
8c0275b42c Tuples of types are pretty-printed now. 2020-05-12 19:25:02 +02:00
Suzanne Dupéron
599944343d Merge branch 'bugfix@recompute-environment' into 'dev'
add a pass to recompute environments

See merge request ligolang/ligo!612
2020-05-09 22:30:25 +00:00
Suzanne Dupéron
673fb67c1c Added test case from GitLab issue 2020-05-09 22:05:54 +01:00
Gabriel Alfour
da5b9c1612 Remove erroneous comment 2020-05-09 20:15:33 +00:00
galfour
98d49959b7
add a pass to recompute environments 2020-05-09 13:21:19 +02:00
Christian Rinderknecht
546856e14a Fixed ParserLog. First complete version of the pretty-printer. 2020-05-08 19:01:51 +02:00
Christian Rinderknecht
2b96bbbdc3 Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@pprint 2020-05-08 19:00:57 +02:00
Tom Jack
c307f251c8 Merge branch 'docker-version-info' into 'dev'
Export COMMIT_DATE also in build_binary

See merge request ligolang/ligo!606
2020-05-08 15:50:25 +00:00
Christian Rinderknecht
f1c444da22 A bit more nodes added. 2020-05-07 20:26:47 +02:00
Jev Björsell
0160c1b7ef Merge branch 'unblock_pages_ci' into 'dev'
remove compact-ligo-ide import and implementation

See merge request ligolang/ligo!609
2020-05-07 17:32:31 +00:00
Edmond Lee
eb098d12e3 remove compact-ligo-ide import and implementation 2020-05-07 17:32:31 +00:00
Rémi Lesenechal
19866476d7 Merge branch 'cleanup/environment' into 'dev'
some environment cleanup

See merge request ligolang/ligo!608
2020-05-07 15:53:09 +00:00
Lesenechal Remi
9eeac11628 some environment cleanup 2020-05-07 16:30:06 +02:00
Christian Rinderknecht
736860611f Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@pprint 2020-05-07 15:41:33 +02:00
Christian Rinderknecht
a1c5b471fe More cases added. 2020-05-07 11:11:16 +02:00
Tom Jack
5d06630b2c Export COMMIT_DATE also in build_binary 2020-05-06 06:06:16 -05:00
Tom Jack
e93e3ccbdd Merge branch 'docker-version-info' into 'dev'
Pass version info through to docker

See merge request ligolang/ligo!604
2020-05-05 20:25:46 +00:00
Tom Jack
ec99230c63 Pass version info through to docker 2020-05-05 20:25:46 +00:00
Pierre-Emmanuel Wulfman
288e6646eb Merge branch 'bugfix/default_env_for_interpret_and_expression' into 'dev'
Bugfix/default env for interpret and expression

See merge request ligolang/ligo!603
2020-05-05 16:56:33 +00:00
Pierre-Emmanuel Wulfman
e0be6fc36f done 2020-05-05 17:24:03 +02:00
Rémi Lesenechal
77b5e15088 Merge branch 'feature/fix-michelson-pair-detection' into 'dev'
now check the label to detect michelson pairs

Closes #183

See merge request ligolang/ligo!602
2020-05-05 14:47:09 +00:00
Lesenechal Remi
c54d650a2a now check the label to detect michelson pairs 2020-05-05 15:21:28 +02:00
Rémi Lesenechal
cadd0d66a9 Merge branch 'feature/quickfix-uncapitalize-michelson-or' into 'dev'
uncapitalize micheslon_or's %-annotations

See merge request ligolang/ligo!601
2020-05-05 12:40:00 +00:00
Lesenechal Remi
7bbfa9ff97 uncapitalize micheslon_or's %-annotations 2020-05-04 18:22:39 +02:00
Suzanne Dupéron
38af497cc3 Merge branch 'feature/adt-generator-promote-until-clean' into 'dev'
Adt generator : promote until-clean

See merge request ligolang/ligo!597
2020-05-04 15:19:05 +00:00
Rémi Lesenechal
29de1278b4 Merge branch 'feature/converter-generation' into 'dev'
michelson layout converters

Closes #74

See merge request ligolang/ligo!585
2020-05-04 13:45:26 +00:00
Pierre-Emmanuel Wulfman
ddb2eac6ca add test 2020-05-04 15:14:56 +02:00
Pierre-Emmanuel Wulfman
426a1b6620 adding ReasonLigo contract 2020-05-04 15:12:44 +02:00
Rémi Lesenechal
51c043b7cb Merge branch 'feature/new-typer-3' into 'dev'
Add a reason string explaining why constraints are added by the typer

See merge request ligolang/ligo!596
2020-05-04 13:08:00 +00:00
Lesenechal Remi
5891a6f4cc 'convert_from_left_comb' and 'convert_from_right_comb' for sum types 2020-05-04 14:19:04 +02:00
Pierre-Emmanuel Wulfman
059a566d4b add PascaLigo contract 2020-05-04 13:39:44 +02:00
Christian Rinderknecht
66aea1b8d1 Added more cases. 2020-05-04 12:34:42 +02:00
Christian Rinderknecht
0aa69ed35b Fixed last commit (renaming of TStringLiteral, adding --pretty) 2020-05-03 10:40:11 +02:00
Lesenechal Remi
8fdf9a8b95 fix weird bug in matching cases 2020-05-02 15:41:50 +02:00
Lesenechal Remi
0a44a22cac 'michelson_or_right_comb' and 'michelson_or_left_comb' type operators 2020-05-02 15:41:02 +02:00
Lesenechal Remi
8e3230bf29 'Layout.convert_to_right_comb' and 'Layout.convert_to_left_comb' for sum types 2020-05-02 15:38:58 +02:00
Lesenechal Remi
b54bcb8db7 rename 'michelson_right/left_comb' to 'michelson_pair_right/left_comb' 2020-05-02 15:38:58 +02:00
Lesenechal Remi
fb2f3e89e7 replace field name 'decl_position' by 'field_decl_pos' 2020-05-02 15:35:50 +02:00
Lesenechal Remi
1f6bc4fc6b convert_from for pairs/record 2020-05-02 15:35:50 +02:00
Lesenechal Remi
9d200a1b56 michelson_right_comb and michelson_left_comb type operators 2020-05-02 15:35:50 +02:00
Lesenechal Remi
3333742037 Converters for michelson types 2020-05-02 15:30:10 +02:00
Christian Rinderknecht
f4b9261104 Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@pprint 2020-05-01 20:34:34 +02:00
Christian Rinderknecht
2667c10990 * Renamed [TStringLiteral] as [TString].
* LexToken.mll for CameLIGO: Fixed printing of "Str"
    into "String".
  * Added CLI option --pretty to call the pretty-printer from
    ParserMain.
  * Use the package Terminal_size to try to determine the width
    of the terminal where the source is pretty-printed.
2020-05-01 20:32:48 +02:00
Pierre-Emmanuel Wulfman
716751553e add cameligo contract 2020-04-30 18:52:32 +02:00
Christian Rinderknecht
82b3d634c1 Merge branch 'parser-promote-generated-error-files' into 'dev'
Promote generated error files by dune.

See merge request ligolang/ligo!427
2020-04-30 09:48:23 +00:00
Pierre-Emmanuel Wulfman
62f97e2f7f replace type_value by type_expresion end expression' by
expression_content for conformity
2020-04-30 11:22:56 +02:00
Pierre-Emmanuel Wulfman
b0998f417a Merge branch 'ast/remove-match-bool' into 'dev'
Remove match_bool from the AST

See merge request ligolang/ligo!589
2020-04-30 09:05:58 +00:00
Pierre-Emmanuel Wulfman
8d59389f7d review 2020-04-30 09:39:49 +02:00
Pierre-Emmanuel Wulfman
2c62f9d32e remove match_bool from the ast 2020-04-30 09:39:49 +02:00
Suzanne Dupéron
f4deb32561 Merge branch 'bugfix/new-typer-2' into 'dev'
Fix in new typer: propagator for break_ctor was too permissive

See merge request ligolang/ligo!595
2020-04-30 04:30:46 +00:00
Suzanne Dupéron
71e0509910 Merge branch 'bugfix/new-typer' into 'dev'
Solve T_arrow vs. TC_arrow bug in new typer

See merge request ligolang/ligo!593
2020-04-30 03:37:45 +00:00
Suzanne Dupéron
61ef304a46 Merge branch 'feature/typer-print-internal-state-1' into 'dev'
Typer: print internal state

See merge request ligolang/ligo!587
2020-04-29 22:27:05 +00:00
Suzanne Dupéron
2372f30ed3 ADT generator: promote until-clean 2020-04-29 21:36:55 +01:00
Suzanne Dupéron
057bd19ca7 Add a reason string explaining why constraints are added by the typer 2020-04-29 21:36:50 +01:00
Suzanne Dupéron
4587862da7 Fix in new typer: propagator for break_ctor was too permissive 2020-04-29 21:33:07 +01:00
Suzanne Dupéron
cf492f03cb Solve T_arrow vs. TC_arrow bug by removing TC_arrow 2020-04-29 21:33:07 +01:00
Suzanne Dupéron
9b1e66622a Functor for applying a fold over any ADT node (e.g. generate all print
functions in one go)
2020-04-29 21:33:07 +01:00
Suzanne Dupéron
94b9404d1b Union-Find: function to extract the list of partitions 2020-04-29 21:33:07 +01:00
Suzanne Dupéron
dfb82aa479 improve printer: constructors with no arguments 2020-04-29 21:33:07 +01:00
Suzanne Dupéron
40474dcc68 printer: use boxes 2020-04-29 21:33:07 +01:00
Suzanne Dupéron
c8f3bb4f04 improve printer: Var name 2020-04-29 21:33:07 +01:00
Suzanne Dupéron
164a32a9b2 ADT generator: missing dependency 2020-04-29 21:33:07 +01:00
Suzanne Dupéron
8e9ee21cd4 Fix Not_found bug (remove redeclaration of the exception) 2020-04-29 21:33:07 +01:00
Suzanne Dupéron
0580f21896 moved core and solver types to the AST, removed functor hell (Map, Set, UnionFind) 2020-04-29 21:32:50 +01:00
Suzanne Dupéron
12cbc9ca07 Prepare ADT generator for new error monad 2020-04-29 21:07:40 +01:00
Suzanne Dupéron
a0b450a34d Merge branch 'balsoft/nix' into 'dev'
Add nix as a build system

See merge request ligolang/ligo!535
2020-04-29 20:05:07 +00:00
Pierre-Emmanuel Wulfman
31858a7a24 Merge branch 'feature/default-environment' into 'dev'
Default environment with just "bool"

See merge request ligolang/ligo!586
2020-04-29 18:40:12 +00:00
edb3fce642 Add nix as a build system
* Dynamically linked executables (ligo-bin)
* Statically linked executables (ligo-static)
* Docker (ligo-docker)
* deb package (ligo-deb)
* webide (ligo-editor)
* webide docker (ligo-editor-docker)
* website (ligo-website)
2020-04-29 19:40:04 +01:00
Pierre-Emmanuel Wulfman
e467642f14 review 2020-04-29 19:31:38 +02:00
Pierre-Emmanuel Wulfman
92d741f5f8 Add bool in default environment 2020-04-29 19:31:37 +02:00
Pierre-Emmanuel Wulfman
7bcf706fcc wip 2020-04-29 19:27:17 +02:00
Sander
d0d495ccce Merge branch 'rinderknecht@michelson' into 'dev'
Refactoring of the lexer and preprocessor

See merge request ligolang/ligo!591
2020-04-29 14:19:29 +00:00
Christian Rinderknecht
6ce6ebfec3 Simplified the interface of the lexer by not exporting the scanner
[init] (which reads the BOM, if any).
2020-04-28 21:17:34 +02:00
Christian Rinderknecht
de7864a500 Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@michelson 2020-04-28 19:26:39 +02:00
Christian Rinderknecht
005b7fd69b Finished refactoring of lexer. 2020-04-28 19:26:31 +02:00
Pierre-Emmanuel Wulfman
5c61bfaa95 Merge branch 'fix/arbitrary_procesion_for_numerals' into 'dev'
Arbitrary Precission for numerals in Ligo

See merge request ligolang/ligo!594
2020-04-28 15:12:38 +00:00
Pierre-Emmanuel Wulfman
877c86b6e4 Merge branch 'less-dippy' into 'dev'
Less dippy compiler

See merge request ligolang/ligo!528
2020-04-28 11:07:18 +00:00
Tom Jack
56fe3b6021 Don't dip for the second var either 2020-04-28 12:00:54 +02:00
Tom Jack
94c35e15dd Don't dip for vars after the second 2020-04-28 12:00:08 +02:00
Tom Jack
b05e7ef613 Less dippy fold 2020-04-28 11:59:32 +02:00
Tom Jack
710f1699a6 Less dippy constants 2020-04-28 11:58:47 +02:00
Tom Jack
0895467f74 Less dippy application 2020-04-28 11:57:47 +02:00
Pierre-Emmanuel Wulfman
6b00a60986 done 2020-04-27 16:41:24 +02:00
Christian Rinderknecht
9618a48848 Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@michelson 2020-04-25 20:51:33 +02:00
Sander
8e34c4a678 Merge branch 'compact-ide' into 'dev'
Added compact IDE component

See merge request ligolang/ligo!516
2020-04-25 10:51:01 +00:00
Maksym Bykovskyy
7dd63652cf Added compact IDE component 2020-04-25 10:51:01 +00:00
Christian Rinderknecht
f3777b4af8 The preprocessor library depends now on the kinds of comments
instead of a closed set of languages. I also removed the offsets:
I simply use the current region to determine whether the
preprocessing directie starts at the beginning of a line. I also
removed scanning line indicators, to make the lexer simpler.

LexToken.mll: Moved the function [check_right_context] that
checks stylistic constraints from Lexer.mll to
LexToken.mll. While this triplicates code (as CameLIGO, PascaLIGO
and ReasonLIGO share the same constraints), the benefit is that
Lexer.mll becomes more generic and the signature for the TOKEN
module is simpler (no more exporting predicates, except for
EOF). In accordance with the change of the preprocessor, the
lexers and parsers for LIGO now depend on the kind of comments,
not a fixed set of syntaxes. This gives more versatility when
adding a new language: only the kinds of its comments are needed,
although Lexer.mll and Preproc.mll may have to be modified if
they do not already know the comment delimiters, for example line
comments starting with #.

****************************************************************
BUG: The exceptions coming from LexToken.mll when a stylistic
constraint is broken in [LexToken.check_right_context] are not
caught yet.
****************************************************************

Lexer.mll: I moved out as much as I could from the header into a
new module LexerLib. The aim is to make it easy to reuse as much
as possible of the lexer machinerie, when it cannot be used as
is.
2020-04-24 21:06:18 +02:00
Christian Rinderknecht
ce5464f9af The preprocessor library depends now on the kinds of comments
instead of a closed set of languages. I also removed the offsets:
I simply use the current region to determine whether the
preprocessing directie starts at the beginning of a line. I also
removed scanning line indicators, to make the lexer simpler.
2020-04-24 20:54:13 +02:00
Jev Björsell
51eb1a2855 Merge branch 'update-logo' into 'dev'
Updated logo and favicon

See merge request ligolang/ligo!517
2020-04-24 16:50:20 +00:00
Pierre-Emmanuel Wulfman
b62dfa1920 Merge branch 'gardening/e_cond_and_loop' into 'dev'
Fix ECond in simplifier and clean up detect free variable

See merge request ligolang/ligo!590
2020-04-23 18:11:05 +00:00
Jev Björsell
2d3b68f57b Merge branch 'webide-add-build-info-metrics' into 'dev'
Add build info to ide metrics and state

See merge request ligolang/ligo!588
2020-04-23 16:46:23 +00:00
Maksym Bykovskyy
9de281e7ef Add build info to ide metrics and state
- Add ligo_webide_build_info metric that surface revision and branch from CI
- Add  a version sub state which contains the current revision and branch of frontend

- Added back express-prometheus-middleware
2020-04-23 16:46:23 +00:00
Pierre-Emmanuel Wulfman
8dfc8a0469 reorder generated variable in for_each 2020-04-23 18:01:07 +02:00
Pierre-Emmanuel Wulfman
30f2581f8b done 2020-04-23 17:53:10 +02:00
Pierre-Emmanuel Wulfman
ca3549bdee Merge branch 'optim/nested_record_update' into 'dev'
Optimize transpilation of nested record update

See merge request ligolang/ligo!510
2020-04-23 10:01:47 +00:00
Christian Rinderknecht
0e452ffbf1 Merge branch 'small-reasonligo-record-punning-improvement' into 'dev'
Make it possible to pun the first argument of a record.

See merge request ligolang/ligo!570
2020-04-22 17:13:01 +00:00
Tom Jack
c58e3220a7 fix bad sed 2020-04-22 12:04:21 -05:00
Tom Jack
b47b5b1c37 s/expression_eq/equal_variables/ to match the behavior 2020-04-22 11:44:57 -05:00
Pierre-Emmanuel Wulfman
2a8edb53da reduce expression_eq to equal variable 2020-04-22 11:42:53 -05:00
Pierre-Emmanuel Wulfman
1cbadbc7cf add expression_eq in ast_typed 2020-04-22 11:42:52 -05:00
Pierre-Emmanuel Wulfman
79f2df2314 optim for record 2020-04-22 11:41:33 -05:00
Tom Jack
1fbbc09313 promote (until-clean) (only *) ? 2020-04-22 11:38:40 -05:00
Pierre-Emmanuel Wulfman
d659b32169 Merge branch 'fix/order-of-sequence' into 'dev'
BUGFIX : order of sequence in Cameligo and `imperative-to-sugar`

See merge request ligolang/ligo!558
2020-04-22 14:13:02 +00:00
Pierre-Emmanuel Wulfman
3cb72f8ec2 add test 2020-04-22 15:05:33 +02:00
Pierre-Emmanuel Wulfman
c46210b656 fix order 2020-04-22 15:04:12 +02:00
Sander Spies
eafbe83151 Also promote ParErr.ml 2020-04-22 11:50:46 +02:00
Sander Spies
bd8cf09f9e Promote generated error files by dune. 2020-04-22 11:50:46 +02:00
Pierre-Emmanuel Wulfman
e6cba7c34f Merge branch 'feature/env-impurity' into 'dev'
Treat transaction environment operators as impure

See merge request ligolang/ligo!346
2020-04-22 09:35:51 +00:00
Tom Jack
f67bd010c4 Treat transaction environment operators as impure 2020-04-22 10:30:57 +02:00
Pierre-Emmanuel Wulfman
3788dac613 Merge branch 'bugfix/reset_var_counter_between_expect_test' into 'dev'
Bugfix: reset Var counter at the begening of run_ligo

See merge request ligolang/ligo!584
2020-04-22 08:02:23 +00:00
Pierre-Emmanuel Wulfman
54dadc33d6 move Var.reset_counter () to run_ligo 2020-04-21 18:06:19 +02:00
Pierre-Emmanuel Wulfman
0bf6d09e85 reset Var counter at the begening of cli run 2020-04-21 18:06:17 +02:00
Pierre-Emmanuel Wulfman
79270d6022 Merge branch 'failwith-int' into 'dev'
Allow to failwith an int (or nat)

See merge request ligolang/ligo!574
2020-04-21 15:35:41 +00:00
Tom Jack
8066e4df26 Allow to failwith an int (or nat) 2020-04-21 15:35:41 +00:00
Rémi Lesenechal
16ecd532b9 Merge branch 'print-optimized-mini-c' into 'dev'
Add `print-mini-c --optimize=entrypoint` to print optimized mini_c

See merge request ligolang/ligo!515
2020-04-21 13:28:39 +00:00
Tom Jack
5df005f4b7 Add print-mini-c --optimize=entrypoint to print optimized mini_c 2020-04-21 13:28:39 +00:00
Gabriel Alfour
c302a1a9d5 Merge branch '181-cannot-declare-michelson_or-michelson_pair-element-w-o-annotation' into 'dev'
Resolve "Cannot declare michelson_or/michelson_pair element w/o annotation"

Closes #181

See merge request ligolang/ligo!583
2020-04-20 21:15:08 +00:00
Lesenechal Remi
5323475097 empty string singleton is not annotated anymore 2020-04-20 20:21:49 +02:00
Christian Rinderknecht
40f2d41b13 Merge branch 'fix/code_smell_in_operators' into 'dev'
Gardening/Fix code smell in operators.ml

See merge request ligolang/ligo!581
2020-04-20 17:36:56 +00:00
Pierre-Emmanuel Wulfman
173a0c4031 Replace function that returns result by function that returns option 2020-04-20 17:39:36 +02:00
Rémi Lesenechal
85222c1d65 Merge branch 'feature/michelson_type_layout' into 'dev'
Feature/michelson type layout

See merge request ligolang/ligo!577
2020-04-19 20:56:25 +00:00
Gabriel Alfour
c892c469f4 Merge branch 'ubuntu-eoan' into 'dev'
Build Ubuntu 19.10 instead of 19.04

See merge request ligolang/ligo!578
2020-04-19 13:46:07 +00:00
Lesenechal Remi
5622b52a36 updating tests 2020-04-19 15:20:02 +02:00
Lesenechal Remi
5bed9dadef WIP: michelson_pair 2020-04-19 15:18:46 +02:00
Lesenechal Remi
e94f445a51 michelson_or custom layout and annotations 2020-04-19 15:18:46 +02:00
Lesenechal Remi
5d35aaec58 add fold for ast_core 2020-04-19 15:18:46 +02:00
Tom Jack
2d7e177ba7 Build Ubuntu 19.10 instead of 19.04
19.04 reached End of Life in January and it appears the package repos
have now dropped it. 19.10 is not LTS but EOL is in July. Soon there
will be 20.04 LTS.
2020-04-16 18:04:42 -05:00
Tom Jack
53cf214f80 Merge branch 'eta' into 'dev'
Perform eta contraction for pairs in Self_mini_c

See merge request ligolang/ligo!564
2020-04-16 20:27:09 +00:00
Tom Jack
f2a23029bd Always inline variable-for-variable lets in Self_mini_c 2020-04-16 14:18:35 -05:00
Tom Jack
6acf91a3f2 Perform basic eta contraction in Self_mini_c 2020-04-16 14:17:30 -05:00
Sander
11f4e6e3a6 Merge branch 'rinderknecht@preproc' into 'dev'
Bug fix: the environment has to be threaded through #include

See merge request ligolang/ligo!576
2020-04-16 16:07:25 +00:00
Christian Rinderknecht
f27bbb317e Bug fix: the environment has to be threaded through #include 2020-04-16 16:56:11 +02:00
Suzanne Dupéron
8848226b85 Merge branch 'bugfix-url-errors' into 'dev'
Fix link to docs in error message, closes LIGO-547

Closes LIGO-547

See merge request ligolang/ligo!573
2020-04-15 17:22:32 +00:00
Pierre-Emmanuel Wulfman
7a18cbd8fc Merge branch 'srcloc_for_types' into 'dev'
Add srcloc for Types

See merge request ligolang/ligo!562
2020-04-15 16:41:27 +00:00
Pierre-Emmanuel Wulfman
c5c1e4d657 Merge branch 'feature/add_step_to_for_loop' into 'dev'
Optional step parameter for `For loop`

See merge request ligolang/ligo!563
2020-04-15 16:29:14 +00:00
Suzanne Dupéron
f547caa80f Fix link to docs in error message, closes LIGO-547 2020-04-15 18:04:43 +02:00
Pierre-Emmanuel Wulfman
7b5acbcef0 Merge branch 'rinderknecht@gcc' into 'dev'
Forgot to remove gcc as a dependency so the docker image is smaller.

See merge request ligolang/ligo!567
2020-04-15 15:56:45 +00:00
Pierre-Emmanuel Wulfman
7c29b075bb add srcloc for types 2020-04-15 17:38:42 +02:00
Sander Spies
2a24290ed0 Fix error messages. 2020-04-15 17:25:32 +02:00
Pierre-Emmanuel Wulfman
9796cd2e8f for loop have a optional step parameter 2020-04-15 17:25:31 +02:00
Sander
23912411e1 Merge branch 'attempt-to-fix-search' into 'dev'
Attempt to fix search.

See merge request ligolang/ligo!572
2020-04-15 11:23:24 +00:00
Sander
4e9ee0bcb2 Merge branch 'rinderknecht@doc' into 'dev'
Removed redundant constant named origin.

See merge request ligolang/ligo!571
2020-04-15 11:06:43 +00:00
Sander Spies
0680633806 Attempt to fix search. 2020-04-15 12:19:12 +02:00
Christian Rinderknecht
a2c03ad848 Removed redundant constant named origin. 2020-04-15 12:00:54 +02:00
Sander Spies
990ae0e3a8 Make it possible to pun the first argument of a record. 2020-04-14 21:15:12 +02:00
Pierre-Emmanuel Wulfman
fb7abe045f Merge branch 'bugfix/adt-generator-whitespace-eol' into 'dev'
Remove trailing whitespace while parsing in ADT generator

See merge request ligolang/ligo!568
2020-04-14 16:22:32 +00:00
Suzanne Dupéron
b7c3e77c82 Remove trailing whitespace while parsing in ADT generator 2020-04-14 17:11:50 +02:00
Sander
1f0491e367 Merge branch 'less-annotations' into 'dev'
Less annotations

See merge request ligolang/ligo!566
2020-04-14 12:19:16 +00:00
Sander
313afab565 Merge branch 'tuple-destructuring' into 'dev'
Tuple destructuring description

See merge request ligolang/ligo!545
2020-04-14 11:49:18 +00:00
Sander Spies
422623ce1e Fix build. 2020-04-14 13:13:07 +02:00
Sander Spies
3e447c40b7 Merge 2020-04-14 13:11:44 +02:00
Suzanne Dupéron
741bfcf9b4 Merge branch 'feature/new-typer-rough-cleanup' into 'dev'
Rough cleanup of the new typer

See merge request ligolang/ligo!561
2020-04-14 11:10:26 +00:00
Christian Rinderknecht
f8c16e5764 Merge branch 'reasonligo-record-improvement' into 'dev'
Add support for record expressions of only one field.

See merge request ligolang/ligo!553
2020-04-14 11:01:11 +00:00
Christian Rinderknecht
5f4c5299d8 Merge branch 'more-api' into 'dev'
More api documentation improvements

See merge request ligolang/ligo!548
2020-04-14 10:53:11 +00:00
Christian Rinderknecht
d49e856ece Forgot to remove gcc as a dependency so the docker image is smaller. 2020-04-14 11:51:24 +02:00
Sander Spies
2b82a74d93 Merge 2020-04-14 10:32:12 +02:00
Suzanne Dupéron
b9310023ad Merge branch 'feature-poly-maps-and-set-and-unionfind' into 'dev'
Polymorfic maps, sets and Union-Find

See merge request ligolang/ligo!560
2020-04-13 22:14:46 +00:00
Suzanne Dupéron
0d77cbe1c4 Gitignore ….install in vendors/Preprocessor 2020-04-13 23:16:17 +02:00
Suzanne Dupéron
3171001395 Added a polymorphic version of one of the UnionFind implementations 2020-04-13 23:10:01 +02:00
Suzanne Dupéron
9e21123de0 Generic PP: use PPF, split test for parentheses to separate fold 2020-04-13 23:10:01 +02:00
Suzanne Dupéron
22fce03844 Improve a typer print 2020-04-13 23:10:01 +02:00
Suzanne Dupéron
1f0ab67baa Moved new typer's wrap module to a separate file 2020-04-13 23:10:01 +02:00
Suzanne Dupéron
93063d8c70 More cleanup new of the typer 2020-04-13 23:10:01 +02:00
Suzanne Dupéron
1b710bd952 Very rough cleanup new of the typer 2020-04-13 23:10:01 +02:00
Suzanne Dupéron
0e699702ad Merge branch 'feature/adt-generator-8-run-dev' into 'dev'
Started using the ADT generator, and small improvements to it

See merge request ligolang/ligo!559
2020-04-13 20:54:19 +00:00
Suzanne Dupéron
ed3343cd76 Merge branch 'feature/adt-generator-7-run-dev' into 'dev'
ADT generator: auto-generate folds over ADTs

See merge request ligolang/ligo!480
2020-04-13 19:32:14 +00:00
Suzanne Dupéron
4a7edafcb7 Dunification of the Red-Black_Trees library 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
e001154714 with_xxx shorthands for fold configurations 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
08aefa4580 Use unique field names in generic.ml and re-enable warning 30 there 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
0704676724 Imported Christian Rinderknecht's polymorphic Red-Black_Trees library from commit 98b1131281 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
b536d3f591 Remove early Perl 5 and Python versions of the ADT generator 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
12aec6edd0 Generic fold example: OCaml printer for an arbitrary ADT 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
ded76b41d6 Adt generator: split structure into smaller structures; use the monad; reordered function, state and value arguments to match the order of List.fold_left. 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
a49f0806c0 ADT generator: produce info for metaprogramming 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
1e1728e5dd [WIP, does not build] Remove some polymorphism : customized visitors must be specific to their accumulator type 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
be38b5269c ADT generator: Stop promoting the generated file, because it breaks the build on the CI (why?) 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
642c947ee4 [WIP, does not build] adt_generator move polymorphism into the fields, start getting rid of the large let rec 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
ab8274eae2 Install perl6 instead of the painful-to-install python3+fstrings 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
253da1e9f5 Break down the large fold_config structure into smaller structures 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
20a51381bc ADT generator: Parser for OCaml ADTs, WIP on adding info 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
2991e48ce6 Implemented folds for the collections (lists and maps) 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
e92ba202cf Added Perl 5 and Raku (A.K.A. Perl 6) translations of the ADT generator. Their outputs are identical. 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
9639c2f775 WIP on making the AST compatibile with the ADT generator 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
6585ce3a09 Install future-fstrings to get f-strings in Python 3.5 and earlier. 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
ba9441a134 moved adt_generator tests to a separate folder 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
2cbc8bbf0c Revert "Revert "Merge branch 'feature/adt-generator-poly-3' into 'dev'""
This reverts commit 8b83e375bd.
2020-04-13 19:23:12 +02:00
Suzanne Dupéron
9d25773d61 Records in ast_typed for match_variant and declaration_constant 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
fcbcea9382 Turned some of the mathcing_content tuples into records 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
79593e6f3e Turned some of the tuples into records 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
58fc08b6a7 ADT generator: add support for open and include 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
516a3a85ff Inlined stage common in ast_typed (fix OCaml type errors) 2020-04-13 19:23:12 +02:00
Suzanne Dupéron
b3b8fab26d [does not build] Inlined stage common in ast_typed 2020-04-13 19:23:12 +02:00
Christian Rinderknecht
f524692370 Merge branch 'rinderknecht@preproc' into 'dev'
Replacing CPP

See merge request ligolang/ligo!512
2020-04-13 16:07:09 +00:00
Christian Rinderknecht
bdb8c5a612 Removed cpp as a dependency in the dockerfile. 2020-04-13 17:08:39 +02:00
Christian Rinderknecht
1ccf6f247d Fixed format of syntax error messages. 2020-04-13 16:31:56 +02:00
Christian Rinderknecht
ffb3d05864 Changed a bit how syntax error messages are formulated.
Resolved a warning.
2020-04-13 14:19:56 +02:00
Christian Rinderknecht
af48efe195 Fix by Sander. 2020-04-13 14:03:30 +02:00
Christian Rinderknecht
f7b0c4fe6b Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@preproc 2020-04-13 14:01:41 +02:00
Sander Spies
d9148699cc Fix contract tests 2020-04-13 13:58:58 +02:00
Sander Spies
6a6c8468a6 Remove annotations from michelson or. 2020-04-13 10:59:36 +02:00
Sander Spies
42b05c0437 Test tuples without annotations. 2020-04-13 10:31:09 +02:00
Sander Spies
a4a8e9d2bc Remove tuple annotation. 2020-04-13 10:24:40 +02:00
Sander
ce1b55e548 Merge branch 'fix-wrong-wild-call' into 'dev'
Ensure that the right error is called when using the wild pattern incorrectly.

See merge request ligolang/ligo!565
2020-04-12 13:54:18 +00:00
Christian Rinderknecht
b23b2d1dbb Plugged the preprocessor into the compiler's CLI. 2020-04-12 15:26:47 +02:00
Sander Spies
6f0fb02bf6 Ensure that the right error is called when using the wild pattern incorrectly. 2020-04-12 14:57:39 +02:00
Christian Rinderknecht
6c02482bf9 Fixed the #include directive. 2020-04-09 18:41:55 +02:00
Christian Rinderknecht
3ed303f60d In EvalOpt modules, the CLI input ["-"] is becomes now [None],
like the absence of an input filename. (This simplifies all the
clients codes.) Fixed the dune file for the preprocessor. Fixed
the build of PreprocMain.exe and PreprocMain.byte. Restricted
preprocessing errors [Preproc.Newline_in_string] and
[Preproc.Open_string] to the argument of the #include
directive (instead of general strings: this is for the LIGO lexer
to report the error). I removed the error [Preproc.Open_comment]
as this is for the LIGO lexer to report. The preprocessor scanner
[Preproc.lex] does not take a parameter [is_file:bool] now: the
source file (if any) is determined from the lexing
buffer. Accordingly, the field [is_file] of the state of the
preprocessing lexer has been removed: the lexing buffer becomes
now the reference for the input source (bug fix and interface
improvement). Fixed the comments of the test contract
pledge.religo. I removed the data constructor [Lexer.Stdin], as
redundant with [Lexer.Channel].
2020-04-09 16:18:26 +02:00
Christian Rinderknecht
46eecb4027 Marked the errors that should be skipped (because catched by the
LIGO lexer later). Added field [is_file] to the state of the
lexer to know if the input is a file or not (insert or not a
first line directive). Fixed ReasonLIGO comments in
entrypoints-contracts.md and website2.religo. WIP on the LIGO
lexer to properly handle comments for all the syntaxes.
2020-04-08 20:24:34 +02:00
Christian Rinderknecht
79967be726 Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@preproc 2020-04-08 17:40:13 +02:00
Sander
3359848565 Merge branch 'ediv-doc' into 'dev'
Add ediv description

See merge request ligolang/ligo!557
2020-04-08 09:55:03 +00:00
Sander Spies
a12febe08b Merge 2020-04-08 10:58:06 +02:00
Sander Spies
432877f954 Merge branch 'dev' of https://gitlab.com/ligolang/ligo into ediv-doc 2020-04-08 10:56:54 +02:00
Gabriel Alfour
1f0519c8ee Merge branch 'feature/michelson-or-type' into 'dev'
michelson or type

See merge request ligolang/ligo!530
2020-04-07 22:35:57 +00:00
Tom Jack
6613883296 Fix description 2020-04-07 17:33:20 -05:00
Tom Jack
b15694b5bc Fix some types, describe more details 2020-04-07 17:11:19 -05:00
Lesenechal Remi
f9d1928d8e michelson_or tests and changelog 2020-04-07 21:38:12 +02:00
Lesenechal Remi
be5ad35fb9 Force annotation for michelson_or 2020-04-07 21:36:59 +02:00
Lesenechal Remi
4af42cb1bd michelson_or types are transformed into variant types 2020-04-07 21:36:59 +02:00
Christian Rinderknecht
951348feb9 Deletion of Parser.msg 2020-04-07 19:56:52 +02:00
Sander Spies
e983ef4c94 Add ediv description 2020-04-07 19:45:06 +02:00
Christian Rinderknecht
53223e9d8e Cosmetics. 2020-04-07 18:57:43 +02:00
Christian Rinderknecht
a343989a6b Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@preproc 2020-04-07 18:57:10 +02:00
Christian Rinderknecht
c0ee726fb2 Simple_utils is now used as a library by the local builds.
Preprocessor is now a library installed by opam.
Replaced ligolang@gmail.com by contact@ligolang.org in opam files.
Reformatted some opam files.
Removed #line directive from preprocessor.
Added to the interface of ParserUnit.
Script messages.sh now checks the identity of .msg and .msg.old
to avoid undue warning about possibly different LR items.
2020-04-07 18:33:46 +02:00
Pierre-Emmanuel Wulfman
96b3ecf248 Merge branch 'feature/EDIV' into 'dev'
Add michelson's EDIV

See merge request ligolang/ligo!556
2020-04-07 13:50:25 +00:00
Sander
a021038991 Merge branch 'fix-bitwise-reasonligo-arrow' into 'dev'
-> to =>

See merge request ligolang/ligo!555
2020-04-06 17:07:27 +00:00
Pierre-Emmanuel Wulfman
79540f9a40 ediv implemented and tested; parser gives error 2020-04-06 18:23:26 +02:00
Sander Spies
4770a6e0d5 -> to => 2020-04-06 18:09:23 +02:00
Sander
f1274497bd Merge branch 'sitemap-deployment' into 'dev'
Deploy sitemap.xml to actual website

See merge request ligolang/ligo!554
2020-04-06 15:13:58 +00:00
Sander Spies
954558da60 Deploy sitemap.xml to actual website 2020-04-06 16:16:34 +02:00
Sander Spies
38edf5ce74 Add support for record expressions of only one field. 2020-04-06 16:09:38 +02:00
Sander
edb5d4b6bf Merge branch 'add-sitemap-xml' into 'dev'
Add sitemap xml

See merge request ligolang/ligo!552
2020-04-06 10:52:34 +00:00
Sander
4f61c75799 Merge branch 'contact-page-change' into 'dev'
Contact page change

See merge request ligolang/ligo!549
2020-04-06 10:32:38 +00:00
Sander Spies
2ed7ea4112 Add sitemap 2020-04-06 11:53:21 +02:00
Christian Rinderknecht
1941f9ae4b Shared more code in ParserUnit.ml
Rewrite of the integration of the preprocessor.
Compiles bt DOES NOT PASS THE CI.
2020-04-03 19:08:14 +02:00
Christian Rinderknecht
6c1a1f91e2 Removed error "Invalid directive" as PascaLIGO has the operator #. 2020-04-03 19:06:35 +02:00
Pierre-Emmanuel Wulfman
5a8dd7233b Merge branch 'gardening/combinators' into 'dev'
Clean-up combinators

See merge request ligolang/ligo!550
2020-04-03 16:41:41 +00:00
Pierre-Emmanuel Wulfman
b41a59d2cf ast-imperative 2020-04-03 17:40:35 +02:00
Pierre-Emmanuel Wulfman
1f118f7233 ast-sugar 2020-04-03 17:40:35 +02:00
Pierre-Emmanuel Wulfman
bc7df6a5b4 ast_core 2020-04-03 17:40:35 +02:00
Pierre-Emmanuel Wulfman
2b09906a37 remove unwanted files at root 2020-04-03 17:40:35 +02:00
Sander Spies
588306ecd3 Modify contact page 2020-04-03 15:39:46 +02:00
Sander Spies
d0ccaabf3e Documentation 2020-04-03 14:58:20 +02:00
Sander
82c60cbdd1 Merge branch 'fix-toplevel2' into 'dev'
Another toplevel fix.

See merge request ligolang/ligo!547
2020-04-03 09:10:53 +00:00
Sander Spies
d09205aebc Another toplevel fix. 2020-04-03 10:14:12 +02:00
Sander Spies
16bf367ea7 Merge 2020-04-02 17:46:27 +02:00
Sander
13799b3181 Merge branch 'fix-toplevel-error' into 'dev'
Fix wrong closing element.

See merge request ligolang/ligo!546
2020-04-02 14:11:20 +00:00
Sander Spies
d449231421 Fix wrong closing element. 2020-04-02 15:14:07 +02:00
Sander
cbf2c7680e Merge branch 'wild-args-reasonligo' into 'dev'
ReasonLIGO: Add support for _ as an argument

See merge request ligolang/ligo!527
2020-04-02 11:57:32 +00:00
Christian Rinderknecht
2e528e3e49 Merge branch 'toplevel-doc' into 'dev'
Add toplevel page for API reference.

See merge request ligolang/ligo!543
2020-04-02 11:36:24 +00:00
Sander
c4199a9708 Merge branch 'inline-doc' into 'dev'
Inline attribute documentation

See merge request ligolang/ligo!538
2020-04-02 11:29:08 +00:00
Christian Rinderknecht
221359ca64 Merge branch 'boolean-operations' into 'dev'
Add list of boolean operations

See merge request ligolang/ligo!541
2020-04-02 11:29:04 +00:00
Sander Spies
3d1ee50685 Tuple destructuring description 2020-04-02 13:28:48 +02:00
Christian Rinderknecht
e543c2cf9a Merge branch 'tutorial-tezos-prefixes' into 'dev'
Use Tezos. prefix in Tutorial.

See merge request ligolang/ligo!539
2020-04-02 11:23:57 +00:00
Sander Spies
a7d4f6691b Forgot a word. 2020-04-02 13:02:44 +02:00
Sander Spies
d0094addd2 Add markdown files to md_file_tests 2020-04-02 12:40:55 +02:00
Sander Spies
5c453354fc Merge. 2020-04-02 12:38:25 +02:00
Sander Spies
7e2a09e81e Improve inline attribute description. 2020-04-02 12:29:32 +02:00
Sander Spies
951235d105 Merge 2020-04-02 10:31:52 +02:00
Tom Jack
fdb53381d1 Merge branch 'delete-deploy-flake' into 'dev'
Delete flaky webide test (for now)

See merge request ligolang/ligo!523
2020-04-01 23:10:53 +00:00
Tom Jack
d756f94c0c Merge branch 'better-pp' into 'dev'
Somewhat better PP for ast_core and mini_c

See merge request ligolang/ligo!514
2020-04-01 20:43:21 +00:00
Tom Jack
803222f646 Merge branch 'no-dexter' into 'dev'
Remove dexter.ligo

See merge request ligolang/ligo!544
2020-04-01 20:20:28 +00:00
Tom Jack
6fed8998bb Somewhat better PP for ast_core and mini_c 2020-04-01 14:32:52 -05:00
Tom Jack
57fc351907 Remove dexter.ligo 2020-04-01 14:22:05 -05:00
Christian Rinderknecht
f5e0dad979 Added # line directive at the start to recover the file name. Continued integration. 2020-04-01 19:22:46 +02:00
Sander Spies
3e46e226c0 Add toplevel page for API reference. 2020-04-01 19:00:39 +02:00
Sander Spies
86de9d27e7 Add errors for properly handling let x = _ cases. 2020-04-01 18:08:31 +02:00
Sander
60070cc8d0 Merge branch 'syntax-switch-fix' into 'dev'
Add background-color to options of Syntax Switch.

See merge request ligolang/ligo!542
2020-04-01 14:41:47 +00:00
Sander Spies
ec7c6e8ad9 Error message shows up again. 2020-04-01 16:34:36 +02:00
Sander Spies
c764f89881 Merge 2020-04-01 15:50:59 +02:00
Sander Spies
3d3da33e3e Add background-color to options of Syntax Switch. 2020-04-01 15:44:53 +02:00
Pierre-Emmanuel Wulfman
037c1cb302 Merge branch 'ast/e_cond_sugar' into 'dev'
Add E_cond as sugar (if .. then .. else ..) for match_bool

See merge request ligolang/ligo!536
2020-04-01 13:12:36 +00:00
Sander Spies
1202ffc8df Add list of boolean operations 2020-04-01 14:49:56 +02:00
Pierre-Emmanuel Wulfman
9dc7e7fcb9 Add E_cond as sugar (if .. then .. else ..) for match_bool 2020-04-01 14:14:20 +02:00
Christian Rinderknecht
968e73b342 Integrated the library for preprocessing.
The build with Makefile works. Dune build to be tested.
2020-03-31 19:44:10 +02:00
Pierre-Emmanuel Wulfman
1fff3dee21 Merge branch 'ast/tuples_are_back' into 'dev'
Adding tuples in ast_sugar

See merge request ligolang/ligo!521
2020-03-31 16:04:19 +00:00
Sander
059bbc8457 Merge branch 'wrong-type-mutez' into 'dev'
API docs: change not existing mutez type to existing tez type

See merge request ligolang/ligo!540
2020-03-31 16:04:16 +00:00
Pierre-Emmanuel Wulfman
c9e509f636 review 1 2020-03-31 17:05:42 +02:00
Pierre-Emmanuel Wulfman
13e9405dee adding tuples in ast_sugar 2020-03-31 17:04:53 +02:00
Sander Spies
0d46be7425 Change not existing mutez type to existing tez type 2020-03-31 17:00:17 +02:00
Sander Spies
257821a764 Use Tezos prefix in Tutorial. 2020-03-31 14:39:26 +02:00
Sander Spies
9fc3c3f01b merge 2020-03-31 14:15:32 +02:00
Sander Spies
c8175a7550 Inline attribute documentation 2020-03-31 14:11:22 +02:00
Pierre-Emmanuel Wulfman
9cd750442a Merge branch 'ast/move_ds_to_constant' into 'dev'
Remove extra AST cases

See merge request ligolang/ligo!499
2020-03-30 16:50:56 +00:00
Pierre-Emmanuel Wulfman
aac7dd3462 review 1 2020-03-30 17:56:17 +02:00
Pierre-Emmanuel Wulfman
6a9547e910 add type map_or_big_map to solve issue of typing big_map_empty from map_add 2020-03-30 17:55:02 +02:00
Pierre-Emmanuel Wulfman
330c48e66a remove Map and BIG_Map 2020-03-30 17:55:02 +02:00
Pierre-Emmanuel Wulfman
a39c900b72 remove set and list 2020-03-30 17:55:00 +02:00
Pierre-Emmanuel Wulfman
c5d9c9ffa3 remove look_up 2020-03-30 17:54:16 +02:00
Pierre-Emmanuel Wulfman
3cbd8f0113 Merge branch 'ast/e_assing_is_back' into 'dev'
Adding E_assign to AST_imperative

See merge request ligolang/ligo!532
2020-03-30 13:37:26 +00:00
Pierre-Emmanuel Wulfman
d91753e493 remove case e_sequance (e_assing, expr) 2020-03-30 14:40:28 +02:00
Pierre-Emmanuel Wulfman
21e8298a4e add assign back 2020-03-30 14:28:31 +02:00
Christian Rinderknecht
ebff258882 The emitted line directives now have the exact same contents as with
cpp. A line made of blanks is now correctly copied out (instead of
single newline).
2020-03-27 19:30:39 +01:00
Pierre-Emmanuel Wulfman
63793ddc76 Merge branch 'ast/loop_construct_for_ast_imperative' into 'dev'
Add for, for_each, while construct in ast_imperatve

See merge request ligolang/ligo!531
2020-03-27 18:28:52 +00:00
Sander
54af2138bf Merge branch 'describe-nested-immutable-path' into 'dev'
Describe nested updates.

See merge request ligolang/ligo!526
2020-03-27 16:07:19 +00:00
Pierre-Emmanuel Wulfman
4003aa4e06 add for, for_each, while construct in ast_imperatve;\n Move the treatment of loops and handling of the assignment in imperative_to_sugar 2020-03-27 16:52:44 +01:00
Sander Spies
1ac6835726 Some changes to get around the negative test errors. 2020-03-27 16:29:50 +01:00
Sander Spies
3c65eafa7b Merge. 2020-03-27 09:18:08 +01:00
Sander Spies
62d1a77b3d ReasonLIGO: Add support for _ as an argument 2020-03-26 20:40:18 +01:00
Christian Rinderknecht
b5a3fb9367 The directive #include is now recursive. 2020-03-26 19:32:48 +01:00
Sander
c28a0f0a60 Merge branch 'remaining-460-docs' into 'dev'
Remaining doc changes of #460

See merge request ligolang/ligo!505
2020-03-26 17:08:47 +00:00
Christian Rinderknecht
9e84d29326 Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@preproc 2020-03-26 18:03:38 +01:00
Sander Spies
c4796d5695 Describe nested updates.
Put record patches section in a pascaligo syntax block.
2020-03-26 17:53:46 +01:00
Sander Spies
40fd4cc2fe Merge 2020-03-26 17:04:50 +01:00
Christian Rinderknecht
ca48e152a0 I removed exceptions for error reporting through the
interfaces ([Stdlib.result] instead).

I added --verbose=preproc to print the preprocessed text until
the error.

Fixed a bug: some whitespace in skip mode was printed out.
2020-03-26 16:51:08 +01:00
Sander
24f4364978 Merge branch 'improve-string-doc' into 'dev'
Improve String.sub api documentation.

See merge request ligolang/ligo!525
2020-03-26 11:09:21 +00:00
Sander
8f62a15f73 Merge branch 'cheat-sheet-testable' into 'dev'
Testable cheat sheet

See merge request ligolang/ligo!509
2020-03-26 11:02:18 +00:00
Sander
0220aac83e Merge branch 'error-tutorial' into 'dev'
Fix tutorial error.

See merge request ligolang/ligo!520
2020-03-26 10:58:08 +00:00
Sander
91a6affdad Merge branch 'enfore_not_allowing_big_maps' into 'dev'
Give an error when nesting a big_map inside another big_map

See merge request ligolang/ligo!518
2020-03-26 10:39:18 +00:00
Sander Spies
38a61f5cb3 Improve String.sub api documentation. 2020-03-26 11:06:52 +01:00
Sander Spies
cb54cd1210 Lambda's and keys shouldn't give errors for nesting big maps. 2020-03-26 09:23:43 +01:00
Tom Jack
84d8da97ec Delete flaky webide test (for now) 2020-03-25 14:47:41 -05:00
Christian Rinderknecht
b24f1f6b1d Added support for -I CLI option (same behaviour as CPP).
Comments are now recognised in accordance with the file extension.
2020-03-25 18:52:23 +01:00
Sander Spies
7e59312454 Merge 2020-03-25 17:18:53 +01:00
Christian Rinderknecht
ab79fe4eda Added some interfaces and removed submodules [Error]. 2020-03-24 21:05:39 +01:00
Christian Rinderknecht
9b6b13cda3 Fixed dune file. 2020-03-24 18:52:00 +01:00
Christian Rinderknecht
8ce6d00d06 Remove redundant \n in error messages. 2020-03-24 18:43:15 +01:00
Christian Rinderknecht
2a1167428f Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@preproc 2020-03-24 17:48:24 +01:00
Christian Rinderknecht
9c9321029a First working version. 2020-03-24 17:48:01 +01:00
Sander Spies
75735cd6ed Fix tutorial error. 2020-03-24 14:41:37 +01:00
Sander Spies
715c3a8eac Inform that it's not possible to nest a big map inside another big map 2020-03-24 14:01:04 +01:00
Sander Spies
d059cf991b Give an error when nesting a big_map inside another big_map 2020-03-24 13:58:18 +01:00
Maksym Bykovskyy
cb592dfd9c Updated logo and favicon 2020-03-23 16:39:11 -07:00
Christian Rinderknecht
37faf9022e [WIP] Does not compile yet. 2020-03-23 19:43:06 +01:00
Sander Spies
7896de89f3 Make cheatsheet testable. 2020-03-19 21:27:58 +01:00
Sander Spies
ebbaccd064 wip 2020-03-18 16:53:59 +01:00
Sander Spies
35ae307f6c More language-basics changes. 2020-03-17 16:05:03 +01:00
1159 changed files with 109817 additions and 42908 deletions

14
.gitignore vendored
View File

@ -3,6 +3,8 @@
*.merlin
cache/*
Version.ml
/result
/result-*
/_opam/
/*.pp.ligo
/*.pp.mligo
@ -13,3 +15,15 @@ Version.ml
*.coverage
/_coverage/
/_coverage_*/
*.gyp
# lsp-related
node_modules/
tools/lsp/squirrel/grammar/*/src
tools/lsp/squirrel/vendor/**
.stack-work
nix/result
.idea
*.iml
stale_outputs_checked
*.cabal

View File

@ -1,274 +1,156 @@
# TODO: remove this as submodules aren't used anymore.
variables:
GIT_SUBMODULE_STRATEGY: recursive
build_binary_script: "./scripts/distribution/generic/build.sh"
package_binary_script: "./scripts/distribution/generic/package.sh"
LIGO_REGISTRY_IMAGE_BASE_NAME: "${CI_PROJECT_PATH}/${CI_PROJECT_NAME}"
WEBIDE_IMAGE_NAME: "registry.gitlab.com/${CI_PROJECT_PATH}/ligo_webide"
stages:
- test
- build_and_package_binaries
- build_docker
- build_and_deploy
- ide-unit-test
- ide-build
- ide-e2e-test
- build
- push
- ide-deploy
- versioning
# TODO provide sensible CI for master
dont-merge-to-master:
stage: test
script:
- "false"
only:
- master
.build_binary: &build_binary
stage: test # To run in sequence and save CPU usage, use stage: build_and_package_binaries
script:
- $build_binary_script "$target_os_family" "$target_os" "$target_os_version"
- $package_binary_script "$target_os_family" "$target_os" "$target_os_version"
artifacts:
paths:
- dist/package/**/*
.website_build: &website_build
stage: build_and_deploy
image: node:12
dependencies:
- build-and-package-debian-9
- build-and-package-debian-10
- build-and-package-ubuntu-18-04
- build-and-package-ubuntu-19-04
before_script:
- export TERM=dumb
- scripts/install_native_dependencies.sh
- scripts/install_opam.sh # TODO: or scripts/install_build_environment.sh ?
- export PATH="/usr/local/bin${PATH:+:}${PATH:-}"
- eval $(opam config env)
- scripts/setup_switch.sh
- eval $(opam config env)
- scripts/setup_repos.sh
# install deps for internal documentation
- scripts/install_vendors_deps.sh
- opam install -y odoc
- scripts/build_ligo_local.sh
# build with odoc
- dune build @doc
# copy .deb packages into website
- find dist -name \*.deb -exec sh -c 'cp {} gitlab-pages/website/static/deb/ligo_$(basename $(dirname {})).deb' \;
# yarn
- cd gitlab-pages/website
- yarn install
script:
- yarn build
# move internal odoc documentation to the website folder
- mv ../../_build/default/_doc/_html/ build/odoc
after_script:
- cp -r gitlab-pages/website/build public
artifacts:
paths:
- public
.docker: &docker
.docker-image:
stage: push
image: docker:19.03.5
services:
- docker:19.03.5-dind
.before_script: &before_script
before_script:
# Install dependencies
# rsync is needed by opam to sync a package installed from a local directory with the copy in ~/.opam
- export TERM=dumb
- scripts/install_native_dependencies.sh
- scripts/install_opam.sh # TODO: or scripts/install_build_environment.sh ?
- export PATH="/usr/local/bin${PATH:+:}${PATH:-}"
- eval $(opam config env)
- scripts/setup_switch.sh
- eval $(opam config env)
- scripts/setup_repos.sh
local-dune-job:
<<: *before_script
stage: test
version_scheduled_job:
stage: versioning
script:
- scripts/install_vendors_deps.sh
- scripts/build_ligo_local.sh
- dune runtest
- make coverage
artifacts:
paths:
- _coverage_all
- scripts/versioning.sh
only:
- schedules
.nix:
stage: build
tags:
- nix
before_script:
- find "$CI_PROJECT_DIR" -path "$CI_PROJECT_DIR/.git" -prune -o "(" -type d -a -not -perm -u=w ")" -exec chmod --verbose u+w {} ";"
# - nix-env -f channel:nixos-unstable -iA gnutar gitMinimal
- export COMMIT_DATE="$(git show --no-patch --format=%ci)"
# The binary produced is useless by itself
binary:
extends: .nix
only:
- merge_requests
- dev
- /^.*-run-dev$/
# Run a docker build without publishing to the registry
build-current-docker-image:
stage: build_docker
dependencies:
- build-and-package-debian-10
<<: *docker
script:
- sh scripts/build_docker_image.sh next
- sh scripts/test_cli.sh
- nix-build nix -A ligo-bin
doc:
extends: .nix
only:
- merge_requests
# When a MR/PR is merged to dev
# take the previous build and publish it to Docker Hub
build-and-publish-latest-docker-image:
stage: build_and_deploy
<<: *docker
dependencies:
- build-and-package-debian-10
- dev
- /^.*-run-dev$/
script:
- sh scripts/build_docker_image.sh $(if test "$CI_COMMIT_REF_NAME" = "dev"; then echo next; else echo next-attempt; fi)
- sh scripts/test_cli.sh
- echo ${LIGO_REGISTRY_PASSWORD} | docker login -u ${LIGO_REGISTRY_USER} --password-stdin
- docker push ${LIGO_REGISTRY_IMAGE_BUILD:-ligolang/ligo}:$(if test "$CI_COMMIT_REF_NAME" = "dev"; then echo next; else echo next-attempt; fi)
- nix-build nix -A ligo-doc
- cp -Lr --no-preserve=mode,ownership,timestamps result/share/doc .
artifacts:
paths:
- doc
test:
extends: .nix
only:
- merge_requests
- dev
- /^.*-run-dev$/
script:
- nix-build nix -A ligo-coverage
- cat result/share/coverage-all
- cp -Lr --no-preserve=mode,ownership,timestamps result/share/coverage .
artifacts:
paths:
- coverage
xrefcheck:
extends: .nix
only:
- merge_requests
script:
# Should be replaced with
# nix run github:serokell/xrefcheck
# Once flakes roll out to stable
# - nix run -f https://github.com/serokell/xrefcheck/archive/v0.1.1.2.tar.gz -c 'xrefcheck local-only'
- curl -L https://github.com/serokell/xrefcheck/releases/download/v0.1.1/release.tar.gz | tar -zxf - xrefcheck/bin/xrefcheck
- xrefcheck/bin/xrefcheck
# Strange race conditions, disable for now
.webide-e2e:
extends: .nix
only:
# Disabled for now unless the branch name contains webide, because a test in this job fails randomly
- /.*webide.*/
#- merge_requests
#- dev
#- /^.*-run-dev$/
script:
- nix-build nix -A ligo-editor.e2e
docker:
extends: .nix
only:
- merge_requests
- dev
- /^.*-run-dev$/
script:
- nix-build nix -A ligo-docker
- cp -L result ligo.tar.gz
artifacts:
paths:
- ligo.tar.gz
docker-push:
extends: .docker-image
dependencies:
- docker
needs:
- docker
rules:
# Only deploy docker when from the dev branch AND on the canonical ligolang/ligo repository
- if: '$CI_COMMIT_REF_NAME =~ /^(dev|.*-run-dev)$/ && $CI_PROJECT_PATH == "ligolang/ligo"'
when: always
script:
- echo ${LIGO_REGISTRY_PASSWORD} | docker login -u ${LIGO_REGISTRY_USER} --password-stdin
- docker load -i=./ligo.tar.gz
- export LIGO_REGISTRY_FULL_NAME=${LIGO_REGISTRY_IMAGE_BUILD:-ligolang/ligo}:$(if test "$CI_COMMIT_REF_NAME" = "dev"; then echo next; else echo next-attempt; fi)
- docker tag ligo "${LIGO_REGISTRY_FULL_NAME}"
- docker push "${LIGO_REGISTRY_FULL_NAME}"
# It'd be a good idea to generate those jobs dynamically,
# based on desired targets
build-and-package-debian-9:
<<: *docker
# To run in sequence and save CPU usage, use stage: build_and_package_binaries
stage: test
variables:
target_os_family: "debian"
target_os: "debian"
target_os_version: "9"
<<: *build_binary
only:
- dev
- /^.*-run-dev$/
build-and-package-debian-10:
<<: *docker
# To run in sequence and save CPU usage, use stage: build_and_package_binaries
stage: test
variables:
target_os_family: "debian"
target_os: "debian"
target_os_version: "10"
<<: *build_binary
# this one is merge_requests and dev, because the debian 10 binary
# is used for build-current-docker-image and for
# build-and-publish-latest-docker-image
webide-docker:
extends: .nix
only:
- merge_requests
- dev
- /^.*-run-dev$/
script:
- nix-build nix -A ligo-editor-docker
- cp -L result webide.tar.gz
artifacts:
paths:
- webide.tar.gz
build-and-package-ubuntu-18-04:
<<: *docker
# To run in sequence and save CPU usage, use stage: build_and_package_binaries
stage: test
variables:
target_os_family: "debian"
target_os: "ubuntu"
target_os_version: "18.04"
<<: *build_binary
only:
- dev
- /^.*-run-dev$/
build-and-package-ubuntu-19-04:
<<: *docker
# To run in sequence and save CPU usage, use stage: build_and_package_binaries
stage: test
variables:
target_os_family: "debian"
target_os: "ubuntu"
target_os_version: "19.04"
<<: *build_binary
only:
- dev
- /^.*-run-dev$/
# Pages are deployed from dev, be careful not to override 'next'
# in case something gets merged into 'dev' while releasing.
pages:
<<: *website_build
rules:
- if: '$CI_COMMIT_REF_NAME == "dev" && $CI_PROJECT_PATH == "ligolang/ligo"'
when: always
pages-attempt:
<<: *website_build
rules:
- if: '$CI_COMMIT_REF_NAME =~ /^.*-run-dev$/ && $CI_PROJECT_PATH == "ligolang/ligo"'
when: always
# WEBIDE jobs
run-webide-unit-tests:
stage: ide-unit-test
webide-push:
extends: .docker-image
dependencies:
- build-and-package-debian-10
image: node:12-buster
script:
- mv $(realpath dist/package/debian-10/*.deb) ligo_deb10.deb
- apt-get update && apt-get -y install libev-dev perl pkg-config libgmp-dev libhidapi-dev m4 libcap-dev bubblewrap rsync
- dpkg -i ligo_deb10.deb
- cd tools/webide/packages/server
- npm ci
- export LIGO_CMD=/bin/ligo && npm run test
- webide-docker
needs:
- webide-docker
rules:
- changes:
- tools/webide/**
# Only deploy docker when from the dev branch AND on the canonical ligolang/ligo repository
- if: '$CI_COMMIT_REF_NAME =~ /^(dev|.*-run-dev)$/ && $CI_PROJECT_PATH == "ligolang/ligo"'
when: always
build-publish-ide-image:
stage: build_and_deploy
<<: *docker
script:
- ls -F
- find dist/
- find dist/package/ -name '*ligo_*deb'
- mv $(realpath dist/package/debian-10/*.deb) tools/webide/ligo_deb10.deb
- cp -r src/test/examples tools/webide/packages/client/examples
- cd tools/webide
- echo "${CI_BUILD_TOKEN}" | docker login -u gitlab-ci-token --password-stdin registry.gitlab.com
- >
docker build
-t "${WEBIDE_IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}"
--build-arg GIT_TAG="${CI_COMMIT_SHA}"
--build-arg GIT_COMMIT="${CI_COMMIT_SHORT_SHA}"
--build-arg EXAMPLES_DIR_SRC=packages/client/examples
.
- docker load -i=./webide.tar.gz
- docker tag ligo-editor "${WEBIDE_IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}"
- docker push "${WEBIDE_IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}"
rules:
- changes:
- tools/webide/**
when: always
- if: '$CI_COMMIT_REF_NAME == "dev"'
when: always
run-webide-e2e-tests:
stage: ide-e2e-test
<<: *docker
image: tmaier/docker-compose
script:
- cd tools/webide/packages/e2e
- export WEBIDE_IMAGE="${WEBIDE_IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}"
- docker-compose run e2e
rules:
- changes:
- tools/webide/**
when: always
- if: '$CI_COMMIT_REF_NAME == "dev"'
when: always
deploy-handoff:
# Handoff deployment duties to private repo
@ -280,3 +162,53 @@ deploy-handoff:
rules:
- if: '$CI_COMMIT_REF_NAME == "dev"'
when: always
static-binary:
extends: .nix
only:
- merge_requests
- dev
- /^.*-run-dev$/
script:
- nix-build nix -A ligo-static
# Check that the binary is truly static and has 0 dependencies
- test $(nix-store -q --references ./result | wc -l) -eq 0
- cp -L result/bin/ligo ligo
- chmod +rwx ligo
artifacts:
paths:
- ligo
.website:
extends: .nix
script:
- nix-build nix -A ligo-website
- cp -Lr --no-preserve=mode,ownership,timestamps result/ public
artifacts:
paths:
- public
pages:
extends: .website
rules:
- if: '$CI_COMMIT_REF_NAME == "dev" && $CI_PROJECT_PATH == "ligolang/ligo"'
when: always
pages-attempt:
extends: .website
only:
- merge_requests
- /^.*-run-dev$/
vscode-extension:
extends: .nix
only:
- merge_requests
- dev
- /^.*-run-dev$/
script:
- nix-build tools/lsp -A ligo-vscode-extension
- cp -Lr --no-preserve=mode,ownership,timestamps result/*.vsix ligo-extension.vsix
artifacts:
paths:
- ligo-extension.vsix

49
.xrefcheck.yaml Normal file
View File

@ -0,0 +1,49 @@
# SPDX-FileCopyrightText: 2019 Serokell <https://serokell.io>
#
# SPDX-License-Identifier: Unlicense
# Parameters of repository traversal.
traversal:
# Files and folders which we pretend do not exist
# (so they are neither analyzed nor can be referenced).
ignored:
# Git files
- .git
- xrefcheck
# Verification parameters.
verification:
# On 'anchor not found' error, how much similar anchors should be displayed as
# hint. Number should be between 0 and 1, larger value means stricter filter.
anchorSimilarityThreshold: 0.5
# When checking external references, how long to wait on request before
# declaring "Response timeout".
externalRefCheckTimeout: 60s
# Prefixes of files, references in which should not be analyzed.
notScanned:
# GitHub-specific files
- .github/pull_request_template.md
- .github/issue_template.md
- .github/PULL_REQUEST_TEMPLATE
- .github/ISSUE_TEMPLATE
# GitLab-specific files
- .gitlab/merge_request_templates/
- .gitlab/issue_templates/
# Glob patterns describing the files which do not physically exist in the
# repository but should be treated as existing nevertheless.
virtualFiles:
# GitHub pages
- ../../../issues
- ../../../issues/*
- ../../../pulls
- ../../../pulls/*
# GitLab pages
- ../../issues
- ../../issues/*
- ../../merge_requests
- ../../merge_requests/*

View File

@ -2,6 +2,10 @@
## [Unreleased]
## [Michelson or type] (https://gitlab.com/ligolang/ligo/-/merge_requests/530)
### Added
- New type michelson_or, will give control over or types instead of relying on LIGO variants.
## [Support for self] (https://gitlab.com/ligolang/ligo/-/merge_requests/453)
### Added
- support for `Tezos.self(%Entrypoint)`

1
debug.cmd Normal file
View File

@ -0,0 +1 @@
(echo '['; sed -ne '/###############################START_OF_JSON/,/###############################END_OF_JSON/{/^###############################.*_OF_JSON/d;p}' < '/home/suzanne/00ligopam/ligo/_build/default/src/test/_build/_tests/'*'/Integration (End to End).001.output'; echo '"end of json"]') > /tmp/js.json

View File

@ -19,7 +19,7 @@ RUN echo "Package: ligo\n\
Version: $version\n\
Architecture: all\n\
Maintainer: info@ligolang.org\n\
Depends: libev4, libgmp10, libgmpxx4ldbl, cpp\n\
Depends: libev4, libgmp10, libgmpxx4ldbl\n\
Homepage: http://ligolang.org\n\
Description: LIGO is a statically typed high-level smart-contract language that compiles down to Michelson." >> /package/DEBIAN/control

View File

@ -2,7 +2,11 @@ ARG target
FROM ocaml/opam2:${target}
ARG ci_job_id
ARG ci_commit_sha
ARG commit_date
ENV CI_JOB_ID=$ci_job_id
ENV CI_COMMIT_SHA=$ci_commit_sha
ENV COMMIT_DATE=$commit_date
RUN opam switch 4.07 && eval $(opam env)
@ -29,7 +33,7 @@ RUN opam update
# Install ligo
RUN sh scripts/install_vendors_deps.sh
RUN opam install -y .
RUN opam install -y . || (tail -n +1 ~/.opam/log/* ; false)
# Use the ligo binary as a default command
ENTRYPOINT [ "/home/opam/.opam/4.07/bin/ligo" ]

View File

@ -16,6 +16,7 @@ services:
# - ./website/versioned_sidebars:/app/website/versioned_sidebars
# - ./website/versioned_docs:/app/website/versioned_docs
- ./website/sidebars.json:/app/website/sidebars.json
- ./website/sitemap.xml:/app/website/sitemap.xml
- ./website/docusaurus.config.js:/app/website/docusaurus.config.js
# - ./website/versions.json:/app/website/versions.json
# - ./website/core/AlgoliaSearch.js:/app/website/core/AlgoliaSearch.js

View File

@ -234,7 +234,7 @@ function deny (const action : parameter; const store : storage) : return is
else ((nil : list (operation)), store)
```
> Note that `amount` is *deprecated*.
> Note that `amount` is *deprecated*. Please use `Tezos.amount`.
</Syntax>
@ -251,7 +251,7 @@ let deny (action, store : parameter * storage) : return =
else (([] : operation list), store)
```
> Note that `amount` is *deprecated*.
> Note that `amount` is *deprecated*. Please use `Tezos.amount`.
</Syntax>
<Syntax syntax="reasonligo">
@ -268,7 +268,7 @@ let deny = ((action, store): (parameter, storage)) : return => {
};
```
> Note that `amount` is *deprecated*.
> Note that `amount` is *deprecated*. Please use `Tezos.amount`.
</Syntax>
@ -289,7 +289,7 @@ function main (const action : parameter; const store : storage) : return is
else ((nil : list (operation)), store)
```
> Note that `source` is *deprecated*.
> Note that `source` is *deprecated*. Please use `Tezos.source`.
</Syntax>
<Syntax syntax="cameligo">
@ -302,7 +302,7 @@ let main (action, store: parameter * storage) : return =
else (([] : operation list), store)
```
> Note that `source` is *deprecated*.
> Note that `source` is *deprecated*. Please use `Tezos.source`.
</Syntax>
<Syntax syntax="reasonligo">
@ -316,7 +316,7 @@ let main = ((action, store) : (parameter, storage)) : return => {
};
```
> Note that `source` is *deprecated*.
> Note that `source` is *deprecated*. Please use `Tezos.source`.
</Syntax>
@ -466,8 +466,8 @@ let proxy = ((action, store): (parameter, storage)) : return => {
| Some (contract) => contract;
| None => (failwith ("Contract not found.") : contract (parameter));
};
(* Reuse the parameter in the subsequent
transaction or use another one, `mock_param`. *)
/* Reuse the parameter in the subsequent
transaction or use another one, `mock_param`. */
let mock_param : parameter = Increment (5n);
let op : operation = Tezos.transaction (action, 0tez, counter);
([op], store)

View File

@ -0,0 +1,70 @@
---
id: inline
title: Inlining
---
import Syntax from '@theme/Syntax';
When compiling a contract in LIGO, declarations will get inlined if they are
only used once and pure. Inlining often results in larger contracts and is
therefore not aggressively done.
A pure declaration is one that doesn't cause side effects like causing a
failure or operation.
In some cases you might want to override the default behaviour of LIGO and
force inlining. The declaration still needs to be pure though.
## Inline attribute
To force inlining you can use the inline attribute.
<Syntax syntax="pascaligo">
```pascaligo
function fst(const p : nat * nat) : nat is p.0; attributes ["inline"] ;
function main(const p : nat * nat; const s : nat * nat) : list(operation) * (nat * nat) is
((list end : list(operation)), (fst(p.0,p.1), fst(s.1,s.0)))
```
</Syntax>
<Syntax syntax="cameligo">
```cameligo
let fst (p: (nat * nat)) : nat = p.0 [@@inline]
let main (p : (nat * nat)) (s : (nat * nat)) : (operation list * (nat * nat)) =
(([]: operation list), (fst (p.0, p.1), fst (s.1, s.0)))
```
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo
[@inline]
let fst = (p: (nat, nat)) : nat => p[0]
let main = (p : (nat, nat), s : (nat, nat)) : (list(operation), (nat, nat)) =>
(([]: list(operation)), (fst((p[0], p[1])), fst((s[1], s[0]))))
```
</Syntax>
Now if we measure the difference between inlining and without inlining, using
`ligo measure-contract name_of_contract.ligo <entrypoint>`, we see the
following results:
<table>
<tr>
<td>With inlining</td><td>66 bytes</td>
</tr>
<tr>
<td>Without inlining</td><td>170 bytes</td>
</tr>
</table>
:::info
Note that these results can change due to ongoing work to optimize output of
the LIGO compiler.
:::

View File

@ -0,0 +1,730 @@
---
id: interop
title: Interop
---
import Syntax from '@theme/Syntax';
LIGO can work together with other smart contract languages on Tezos. However
data structures might have different representations in Michelson and not
correctly match the standard LIGO types.
## Michelson types and annotations
Michelson types consist of `or`'s and `pair`'s, combined with field annotations.
Field annotations add contraints on a Michelson type, for example a pair of
`(pair (int %foo) (string %bar))` will only work with the exact equivalence or
the same type without the field annotations.
To clarify:
```michelson
(pair (int %foo) (string %bar))
````
works with
```michelson
(pair (int %foo) (string %bar))
```
works with
```michelson
(pair int string)
```
works not with
```michelson
(pair (int %bar) (string %foo))
```
works not with
```michelson
(pair (string %bar) (int %foo))
```
:::info
In the case of annotated entrypoints - the annotated `or` tree directly under
`parameter` in a contract - you should annotations, as otherwise it would
become unclear which entrypoint you are referring to.
:::
## Entrypoints and annotations
It's possible for a contract to have multiple entrypoints, which translates in
LIGO to a `parameter` with a variant type as shown here:
<Syntax syntax="pascaligo">
```pascaligo
type storage is int
type parameter is
| Left of int
| Right of int
function main (const p: parameter; const x: storage): (list(operation) * storage) is
((nil: list(operation)), case p of
| Left(i) -> x - i
| Right(i) -> x + i
end)
```
</Syntax>
<Syntax syntax="cameligo">
```cameligo
type storage = int
type parameter =
| Left of int
| Right of int
let main ((p, x): (parameter * storage)): (operation list * storage) =
(([]: operation list), (match p with
| Left i -> x - i
| Right i -> x + i
))
```
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo
type storage = int
type parameter =
| Left(int)
| Right(int)
let main = ((p, x): (parameter, storage)): (list(operation), storage) => {
([]: list(operation), (switch(p) {
| Left(i) => x - i
| Right(i) => x + i
}))
};
```
</Syntax>
This contract can be called by another contract, like this one:
<Syntax syntax="pascaligo">
```pascaligo group=get_entrypoint_opt
type storage is int
type parameter is int
type x is Left of int
function main (const p: parameter; const s: storage): (list(operation) * storage) is block {
const contract: contract(x) =
case (Tezos.get_entrypoint_opt("%left", ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx":address)): option(contract(x))) of
| Some (c) -> c
| None -> (failwith("not a correct contract") : contract(x))
end;
const result: (list(operation) * storage) = ((list [Tezos.transaction(Left(2), 2mutez, contract)]: list(operation)), s)
} with result
```
</Syntax>
<Syntax syntax="cameligo">
```cameligo group=get_entrypoint_opt
type storage = int
type parameter = int
type x = Left of int
let main (p, s: parameter * storage): operation list * storage = (
let contract: x contract =
match ((Tezos.get_entrypoint_opt "%left" ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx": address)): x contract option) with
| Some c -> c
| None -> (failwith "contract does not match": x contract)
in
(([
Tezos.transaction (Left 2) 2mutez contract;
]: operation list), s)
)
```
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo group=get_entrypoint_opt
type storage = int;
type parameter = int;
type x = Left(int);
let main = ((p, s): (parameter, storage)): (list(operation), storage) => {
let contract: contract(x) =
switch (Tezos.get_entrypoint_opt("%left", ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx": address)): option(contract(x))) {
| Some c => c
| None => (failwith ("contract does not match"): contract(x))
};
([
Tezos.transaction(Left(2), 2mutez, contract)
]: list(operation), s);
};
```
</Syntax>
Notice how we directly use the `%left` entrypoint without mentioning the
`%right` entrypoint. This is done with the help of annotations. Without
annotations it wouldn't be clear what our `int` would be referring to.
This currently only works for `or`'s or variant types in LIGO.
## Interop with Michelson
To interop with existing Michelson code or for compatibility with certain
development tooling, LIGO has two special interop types: `michelson_or` and
`michelson_pair`. These types give the flexibility to model the exact Michelson
output, including field annotations.
Take for example the following Michelson type that we want to interop with:
```michelson
(or
(unit %z)
(or %other
(unit %y)
(pair %other
(string %x)
(pair %other
(int %w)
(nat %v)))))
```
To reproduce this type we can use the following LIGO code:
<Syntax syntax="pascaligo">
```pascaligo
type w_and_v is michelson_pair(int, "w", nat, "v")
type x_and is michelson_pair(string, "x", w_and_v, "other")
type y_or is michelson_or(unit, "y", x_and, "other")
type z_or is michelson_or(unit, "z", y_or, "other")
```
</Syntax>
<Syntax syntax="cameligo">
```cameligo
type w_and_v = (int, "w", nat, "v") michelson_pair
type x_and = (string, "x", w_and_v, "other") michelson_pair
type y_or = (unit, "y", x_and, "other") michelson_or
type z_or = (unit, "z", y_or, "other") michelson_or
```
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo
type w_and_v = michelson_pair(int, "w", nat, "v")
type x_and = michelson_pair(string, "x", w_and_v, "other")
type y_or = michelson_or(unit, "y", x_and, "other")
type z_or = michelson_or(unit, "z", y_or, "other")
```
</Syntax>
If you don't want to have an annotation, you need to provide an empty string.
:::info
Alternatively, if annotations are not important you can also use plain tuples
for pair's instead. Plain tuples don't have any annotations.
:::
To use variables of type `michelson_or` you have to use `M_left` and `M_right`.
`M_left` picks the left `or` case while `M_right` picks the right `or` case.
For `michelson_pair` you need to use tuples.
<Syntax syntax="pascaligo">
```pascaligo
const z: z_or = (M_left (unit) : z_or);
const y_1: y_or = (M_left (unit): y_or);
const y: z_or = (M_right (y_1) : z_or);
const x_pair: x_and = ("foo", (2, 3n));
const x_1: y_or = (M_right (x_pair): y_or);
const x: z_or = (M_right (y_1) : z_or);
```
</Syntax>
<Syntax syntax="cameligo">
```cameligo
let z: z_or = (M_left (unit) : z_or)
let y_1: y_or = (M_left (unit): y_or)
let y: z_or = (M_right (y_1) : z_or)
let x_pair: x_and = ("foo", (2, 3n))
let x_1: y_or = (M_right (x_pair): y_or)
let x: z_or = (M_right (y_1) : z_or)
```
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo
let z: z_or = (M_left (unit) : z_or)
let y_1: y_or = (M_left (unit): y_or)
let y: z_or = (M_right (y_1) : z_or)
let x_pair: x_and = ("foo", (2, 3n))
let x_1: y_or = (M_right (x_pair): y_or)
let x: z_or = (M_right (y_1) : z_or)
```
</Syntax>
## Helper functions
Converting between different LIGO types and data structures can happen in two
ways. The first way is to use the provided layout conversion functions, and the
second way is to handle the layout conversion manually.
:::info
In both cases it will increase the size of the smart contract and the
conversion will happen when running the smart contract.
:::
### Converting left combed Michelson data structures
Here's an example of a left combed Michelson data structure using pairs:
```michelson
(pair %other
(pair %other
(string %s)
(int %w)
)
(nat %v)
)
```
Which could respond with the following record type:
<Syntax syntax="pascaligo">
```pascaligo
type l_record is record [
s: string;
w: int;
v: nat
]
```
</Syntax>
<Syntax syntax="cameligo">
```cameligo
type l_record = {
s: string;
w: int;
v: nat
}
```
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo
type l_record = {
s: string,
w: int,
v: nat
}
```
</Syntax>
If we want to convert from the Michelson type to our record type and vice
versa, we can use the following code:
<Syntax syntax="pascaligo">
```pascaligo
type michelson is michelson_pair_left_comb(l_record)
function of_michelson (const f: michelson) : l_record is
block {
const p: l_record = Layout.convert_from_left_comb(f)
}
with p
function to_michelson (const f: l_record) : michelson is
block {
const p: michelson = Layout.convert_to_left_comb ((f: l_record))
}
with p
```
</Syntax>
<Syntax syntax="cameligo">
```cameligo
type michelson = l_record michelson_pair_left_comb
let of_michelson (f: michelson) : l_record =
let p: l_record = Layout.convert_from_left_comb f in
p
let to_michelson (f: l_record) : michelson =
let p = Layout.convert_to_left_comb (f: l_record) in
p
```
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo
type michelson = michelson_pair_left_comb(l_record);
let of_michelson = (f: michelson) : l_record => {
let p: l_record = Layout.convert_from_left_comb(f);
p
};
let to_michelson = (f: l_record) : michelson => {
let p = Layout.convert_to_left_comb(f: l_record);
p
}
```
</Syntax>
In the case of a left combed Michelson `or` data structure, that you want to
translate to a variant, you can use the `michelson_or_left_comb` type.
For example:
<Syntax syntax="pascaligo">
```pascaligo
type vari is
| Foo of int
| Bar of nat
| Other of bool
type r is michelson_or_left_comb(vari)
```
</Syntax>
<Syntax syntax="cameligo">
```cameligo
type vari =
| Foo of int
| Bar of nat
| Other of bool
type r = vari michelson_or_left_comb
```
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo
type vari =
| Foo(int)
| Bar(nat)
| Other(bool)
type r = michelson_or_left_comb(vari)
```
</Syntax>
And then use these types in `Layout.convert_from_left_comb` or
`Layout.convert_to_left_comb`, similar to the `pair`s example above, like this:
<Syntax syntax="pascaligo">
```pascaligo
function of_michelson_or (const f: r) : vari is
block {
const p: vari = Layout.convert_from_left_comb(f)
}
with p
function to_michelson_or (const f: vari) : r is
block {
const p: r = Layout.convert_to_left_comb((f: vari))
}
with p
```
</Syntax>
<Syntax syntax="cameligo">
```cameligo
let of_michelson_or (f: r) : vari =
let p: vari = Layout.convert_from_left_comb f in
p
let to_michelson_or (f: vari) : r =
let p = Layout.convert_to_left_comb (f: vari) in
p
```
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo
let of_michelson_or = (f: r) : vari => {
let p: vari = Layout.convert_from_left_comb(f);
p
};
let to_michelson_or = (f: vari) : r => {
let p = Layout.convert_to_left_comb(f: vari);
p
}
```
</Syntax>
### Converting right combed Michelson data structures
In the case of right combed data structures, like:
```michelson
(pair %other
(string %s)
(pair %other
(int %w)
(nat %v)
)
)
```
you can almost use the same code as that for the left combed data structures,
but with `michelson_or_right_comb`, `michelson_pair_right_comb`,
`Layout.convert_from_right_comb`, and `Layout.convert_to_left_comb`
respectively.
### Manual data structure conversion
If you want to get your hands dirty, it's also possible to do manual data
structure conversion.
The following code can be used as inspiration:
<Syntax syntax="pascaligo">
```pascaligo group=helper_functions
type z_to_v is
| Z
| Y
| X
| W
| V
type w_or_v is michelson_or(unit, "w", unit, "v")
type x_or is michelson_or(unit, "x", w_or_v, "other")
type y_or is michelson_or(unit, "y", x_or, "other")
type z_or is michelson_or(unit, "z", y_or, "other")
type test is record [
z: string;
y: int;
x: string;
w: bool;
v: int;
]
function make_concrete_sum (const r: z_to_v) : z_or is block {
const z: z_or = (M_left (unit) : z_or);
const y_1: y_or = (M_left (unit): y_or);
const y: z_or = (M_right (y_1) : z_or);
const x_2: x_or = (M_left (unit): x_or);
const x_1: y_or = (M_right (x_2): y_or);
const x: z_or = (M_right (x_1) : z_or);
const w_3: w_or_v = (M_left (unit): w_or_v);
const w_2: x_or = (M_right (w_3): x_or);
const w_1: y_or = (M_right (w_2): y_or);
const w: z_or = (M_right (w_1) : z_or);
const v_3: w_or_v = (M_right (unit): w_or_v);
const v_2: x_or = (M_right (v_3): x_or);
const v_1: y_or = (M_right (v_2): y_or);
const v: z_or = (M_right (v_1) : z_or);
}
with (case r of
| Z -> z
| Y -> y
| X -> x
| W -> w
| V -> v
end)
function make_concrete_record (const r: test) : (string * int * string * bool * int) is
(r.z, r.y, r.x, r.w, r.v)
function make_abstract_sum (const z_or: z_or) : z_to_v is
(case z_or of
| M_left (n) -> Z
| M_right (y_or) ->
(case y_or of
| M_left (n) -> Y
| M_right (x_or) ->
(case x_or of
| M_left (n) -> X
| M_right (w_or) ->
(case (w_or) of
| M_left (n) -> W
| M_right (n) -> V
end)
end)
end)
end)
function make_abstract_record (const z: string; const y: int; const x: string; const w: bool; const v: int) : test is
record [ z = z; y = y; x = x; w = w; v = v ]
```
</Syntax>
<Syntax syntax="cameligo">
```cameligo group=helper_functions
type z_to_v =
| Z
| Y
| X
| W
| V
type w_or_v = (unit, "w", unit, "v") michelson_or
type x_or = (unit, "x", w_or_v, "other") michelson_or
type y_or = (unit, "y", x_or, "other") michelson_or
type z_or = (unit, "z", y_or, "other") michelson_or
type test = {
z: string;
y: int;
x: string;
w: bool;
v: int;
}
let make_concrete_sum (r: z_to_v) : z_or =
match r with
| Z -> (M_left (unit) : z_or)
| Y -> (M_right (M_left (unit): y_or) : z_or )
| X -> (M_right (M_right (M_left (unit): x_or): y_or) : z_or )
| W -> (M_right (M_right (M_right (M_left (unit): w_or_v): x_or): y_or) : z_or )
| V -> (M_right (M_right (M_right (M_right (unit): w_or_v): x_or): y_or) : z_or )
let make_concrete_record (r: test) : (string * int * string * bool * int) =
(r.z, r.y, r.x, r.w, r.v)
let make_abstract_sum (z_or: z_or) : z_to_v =
match z_or with
| M_left n -> Z
| M_right y_or ->
(match y_or with
| M_left n -> Y
| M_right x_or -> (
match x_or with
| M_left n -> X
| M_right w_or -> (
match w_or with
| M_left n -> W
| M_right n -> V)))
let make_abstract_record (z: string) (y: int) (x: string) (w: bool) (v: int) : test =
{ z = z; y = y; x = x; w = w; v = v }
```
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo group=helper_functions
type z_to_v =
| Z
| Y
| X
| W
| V
type w_or_v = michelson_or(unit, "w", unit, "v")
type x_or = michelson_or(unit, "x", w_or_v, "other")
type y_or = michelson_or(unit, "y", x_or, "other")
type z_or = michelson_or(unit, "z", y_or, "other")
type test = {
z: string,
y: int,
x: string,
w: bool,
v: int
}
let make_concrete_sum = (r: z_to_v) : z_or =>
switch(r){
| Z => (M_left (unit) : z_or)
| Y => (M_right (M_left (unit): y_or) : z_or )
| X => (M_right (M_right (M_left (unit): x_or): y_or) : z_or )
| W => (M_right (M_right (M_right (M_left (unit): w_or_v): x_or): y_or) : z_or )
| V => (M_right (M_right (M_right (M_right (unit): w_or_v): x_or): y_or) : z_or )
}
let make_concrete_record = (r: test) : (string, int, string, bool, int) =>
(r.z, r.y, r.x, r.w, r.v)
let make_abstract_sum = (z_or: z_or) : z_to_v =>
switch (z_or) {
| M_left n => Z
| M_right y_or => (
switch (y_or) {
| M_left n => Y
| M_right x_or => (
switch (x_or) {
| M_left n => X
| M_right w_or => (
switch (w_or) {
| M_left n => W
| M_right n => V
})
})
})
}
let make_abstract_record = (z: string, y: int, x: string, w: bool, v: int) : test =>
{ z : z, y, x, w, v }
```
</Syntax>
## Amendment
With the upcoming 007 amendment to Tezos this will change though, and also
`pair`'s can be ordered differently.

View File

@ -11,13 +11,13 @@ LIGO features timestamps, as Michelson does, while bakers baking the
block (including the transaction in a block) are responsible for
providing the given current timestamp for the contract.
### Current Time
### Starting time of the current block
You can obtain the current time using the built-in syntax specific
expression, please be aware that it is up to the baker to set the
You can obtain the starting time of the current block using the
built-in `Tezos.now`. This timestamp does not change during the execution
of the contract. Please be aware that it is up to the baker to set the
current timestamp value.
<Syntax syntax="pascaligo">
```pascaligo group=a
@ -62,20 +62,20 @@ constraints on your smart contracts. Consider the following scenarios.
```pascaligo group=b
const today : timestamp = Tezos.now
const one_day : int = 86400
const one_day : int = 86_400
const in_24_hrs : timestamp = today + one_day
const some_date : timestamp = ("2000-01-01T10:10:10Z" : timestamp)
const one_day_later : timestamp = some_date + one_day
```
> Note that `now` is *deprecated*.
> Note that `now` is *deprecated*. Please use `Tezos.now`.
</Syntax>
<Syntax syntax="cameligo">
```cameligo group=b
let today : timestamp = Tezos.now
let one_day : int = 86400
let one_day : int = 86_400
let in_24_hrs : timestamp = today + one_day
let some_date : timestamp = ("2000-01-01t10:10:10Z" : timestamp)
let one_day_later : timestamp = some_date + one_day
@ -88,7 +88,7 @@ let one_day_later : timestamp = some_date + one_day
```reasonligo group=b
let today : timestamp = Tezos.now;
let one_day : int = 86400;
let one_day : int = 86_400;
let in_24_hrs : timestamp = today + one_day;
let some_date : timestamp = ("2000-01-01t10:10:10Z" : timestamp);
let one_day_later : timestamp = some_date + one_day;
@ -110,7 +110,7 @@ const one_day : int = 86400
const in_24_hrs : timestamp = today - one_day
```
> Note that `now` is *deprecated*.
> Note that `now` is *deprecated*. Please use `Tezos.now`.
</Syntax>
<Syntax syntax="cameligo">
@ -149,7 +149,7 @@ applying to numbers.
const not_tommorow : bool = (Tezos.now = in_24_hrs)
```
> Note that `now` is *deprecated*.
> Note that `now` is *deprecated*. Please use `Tezos.now`.
</Syntax>
<Syntax syntax="cameligo">

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@ id: cli-commands
title: CLI Commands
---
Contracts written in Ligo can be compiled using the `ligo` executable.
Contracts written in LIGO can be compiled using the `ligo` executable.
## Compiling a contract

View File

@ -6,7 +6,7 @@ title: Documentation and releases
## Documentation
If you'd like to contribute to the docs you can find them at [`gitlab-pages/docs`]() in raw markdown form.
If you'd like to contribute to the docs you can find them at `gitlab-pages/docs` in raw markdown form.
Deployment of the docs/website for LIGO is taken care of within the CI, from `dev` and `master` branches.
## Releases & versioning

View File

@ -7,7 +7,7 @@ Bonus: you'll become more familiar with LIGO in the process!
Tests are written in OCaml, as LIGO doesn't (yet) have a good way to do automated testing. Thankfully the test code is typically less demanding than the features being tested.
Tests are currently contained in [src/test](https://gitlab.com/ligolang/ligo/tree/dev/src/test), but most are integration tests which rely on test contracts kept in [src/test/contracts](https://gitlab.com/ligolang/ligo/tree/dev/src/test/contracts). If you're new to LIGO, reading these contracts can be a useful introduction to a particular LIGO syntax. In the future we plan
to have detailed documentation for each syntax, but at the moment we only have a reference manual for [PascaLIGO](https://gitlab.com/ligolang/ligo/blob/dev/src/passes/1-parser/pascaligo/Doc/pascaligo.md)
to have detailed documentation for each syntax, but at the moment we only have a reference manual for [PascaLIGO](https://gitlab.com/ligolang/ligo/blob/dev/src/passes/01-parsing/pascaligo/Doc/pascaligo.md)
## How To Find Good Test Cases
@ -23,7 +23,7 @@ LIGO is divided into two parts
- the **front end** handles syntax
- the **backend** optimizes and compiles a core language shared between syntaxes
You can find basic test cases for a particular LIGO syntax by studying its parser. You will find the parser under [src/passes/1-parser](https://gitlab.com/ligolang/ligo/tree/dev/src/passes/1-parser).
You can find basic test cases for a particular LIGO syntax by studying its parser. You will find the parser under [src/passes/1-parser](https://gitlab.com/ligolang/ligo/tree/dev/src/passes/01-parsing).
### Two Useful Test Cases Using LIGO
@ -102,7 +102,7 @@ What's going on is similar to the last program: `expect_eq_evaluate` runs a prog
For example, once the program stops running the value of `address` is `"tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx"`. The *comparison*, however, is made to a constructed expression.
Remember that we're testing from OCaml, but the program is written and evaluated as LIGO. In order to provide a proper comparison, we convert our expected test values into LIGO expressions and data. Constructors such as `e_list` and `e_address` provide a bridge between LIGO and OCaml. Their definitions can be found in files such as [src/stages/ast_core/combinators.ml](https://gitlab.com/ligolang/ligo/blob/dev/src/stages/ast_core/combinators.ml), or using [Merlin's definition point finder](https://github.com/ocaml/merlin/wiki). These same functions are used during the simplification stage of LIGO compilation, so becoming familiar with them will help prepare you to work on the [front end](contributors/big-picture/front-end/).
Remember that we're testing from OCaml, but the program is written and evaluated as LIGO. In order to provide a proper comparison, we convert our expected test values into LIGO expressions and data. Constructors such as `e_list` and `e_address` provide a bridge between LIGO and OCaml. Their definitions can be found in files such as [src/stages/ast_core/combinators.ml](https://gitlab.com/ligolang/ligo/blob/dev/src/stages/ast_core/combinators.ml), or using [Merlin's definition point finder](https://github.com/ocaml/merlin/wiki). These same functions are used during the simplification stage of LIGO compilation, so becoming familiar with them will help prepare you to work on the [front end](big-picture/front-end.md).
## How To Write A Test For LIGO

View File

@ -0,0 +1,170 @@
---
id: ligo-snippets-demo
title: Ligo-Snippets Demo
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
“ligo-snippets” (https://www.npmjs.com/package/@ligolang/ligo-snippets) is a React component that can be included on any webpage to display Ligo source code to users.
The user will see Ligo code with syntax highlighting, and an action button allowing the user to open the source code in the Ligo Web IDE (https://ide.ligolang.org).
Each code snippet can have preset Ligo Web IDE configurations (e.g. entrypoint, parameters or storage). These configurations are optional and will be passed onto the Ligo Web IDE when present. This will allow examples to provide the proper configurations for the reader to experiment with.
The “ligo-snippets” React component uses the CodeJar editor (https://github.com/antonmedv/codejar), which is extremely lightweight (only 2kB). It currently supports syntax highlighting for PascaLigo, CameLigo and ReasonLigo. Additionally, it has both a light and dark theme mode.
<Tabs
defaultValue="pascaligo"
values={[
{ label: 'PascaLIGO', value: 'pascaligo', },
{ label: 'CameLIGO', value: 'cameligo', },
{ label: 'ReasonLIGO', value: 'reasonligo', },
]
}>
<TabItem value="pascaligo">
```pascaligo {"name": "Ligo Introduction Example", "editor": true}
(*_*
name: PascaLIGO Contract
language: pascaligo
compile:
entrypoint: main
dryRun:
entrypoint: main
parameters: Increment (1)
storage: 999
deploy:
entrypoint: main
storage: 999
evaluateValue:
entrypoint: ""
evaluateFunction:
entrypoint: add
parameters: (5, 6)
generateDeployScript:
entrypoint: main
storage: 999
*_*)
// variant defining pseudo multi-entrypoint actions
type action is
| Increment of int
| Decrement of int
function add (const a : int ; const b : int) : int is
block { skip } with a + b
function subtract (const a : int ; const b : int) : int is
block { skip } with a - b
// real entrypoint that re-routes the flow based
// on the action provided
function main (const p : action ; const s : int) :
(list(operation) * int) is
block { skip } with ((nil : list(operation)),
case p of
| Increment(n) -> add(s, n)
| Decrement(n) -> subtract(s, n)
end)
```
</TabItem>
<TabItem value="cameligo">
```cameligo {"name": "Ligo Introduction Example", "editor": true}
(*_*
name: CameLIGO Contract
language: cameligo
compile:
entrypoint: main
dryRun:
entrypoint: main
parameters: Increment 1
storage: 999
deploy:
entrypoint: main
storage: 999
evaluateValue:
entrypoint: ""
evaluateFunction:
entrypoint: add
parameters: 5, 6
generateDeployScript:
entrypoint: main
storage: 999
*_*)
type storage = int
(* variant defining pseudo multi-entrypoint actions *)
type action =
| Increment of int
| Decrement of int
let add (a,b: int * int) : int = a + b
let sub (a,b: int * int) : int = a - b
(* real entrypoint that re-routes the flow based on the action provided *)
let main (p,s: action * storage) =
let storage =
match p with
| Increment n -> add (s, n)
| Decrement n -> sub (s, n)
in ([] : operation list), storage
```
</TabItem>
<TabItem value="reasonligo">
```reasonligo {"name": "Ligo Introduction Example", "editor": true}
(*_*
name: ReasonLIGO Contract
language: reasonligo
compile:
entrypoint: main
dryRun:
entrypoint: main
parameters: Increment (1)
storage: 999
deploy:
entrypoint: main
storage: 999
evaluateValue:
entrypoint: ""
evaluateFunction:
entrypoint: add
parameters: (5, 6)
generateDeployScript:
entrypoint: main
storage: 999
*_*)
type storage = int;
/* variant defining pseudo multi-entrypoint actions */
type action =
| Increment(int)
| Decrement(int);
let add = ((a,b): (int, int)): int => a + b;
let sub = ((a,b): (int, int)): int => a - b;
/* real entrypoint that re-routes the flow based on the action provided */
let main = ((p,storage): (action, storage)) => {
let storage =
switch (p) {
| Increment(n) => add((storage, n))
| Decrement(n) => sub((storage, n))
};
([]: list(operation), storage);
};
```
</TabItem>
</Tabs>

View File

@ -3,26 +3,28 @@ id: installation
title: Installation
---
There are currently two ways to get started with Ligo. You can choose to use a Docker image, or to install packages for your Debian Linux distribution.
There are currently three ways to get started with LIGO. You can choose to use a Docker image, a static Linux binary or to install packages for your Debian Linux distribution.
## Dockerized installation (recommended)
> 🐳 You can find instructions on how to install Docker [here](https://docs.docker.com/install/).
It's easiest to use LIGO through one of its Docker images. You have two options:
* Use our installation script to set up a globally available LIGO
* Use our installation script to set up a globally available `ligo`
executable (see below). This manages the Docker bits for you.
* Use the Docker image available at [Docker Hub](https://hub.docker.com/r/ligolang/ligo).
This lets you run multiple versions and keep your installation(s) self contained, but requires more familiarity with Docker.
This lets you run multiple versions and keep your installation(s) self-contained but requires more familiarity with Docker.
Sources for the image can be found on [GitLab](https://gitlab.com/ligolang/ligo/blob/master/docker/Dockerfile).
If this is your first time using Docker, you probably want to set up a global LIGO executable as shown below.
If this is your first time using Docker, you probably want to set up a global `ligo` executable as shown below.
### Setting up a globally available `ligo` executable
> You can install additional ligo versions by replacing `next` with the desired version number
<!--
> You can install additional LIGO versions by replacing `next` with the desired version number
-->
Download the latest binaries here: https://gitlab.com/ligolang/ligo/pipelines/85536879/builds or get the latest pre-release:
Get the latest pre-release:
```zsh
# next (pre-release)
@ -35,25 +37,36 @@ curl https://gitlab.com/ligolang/ligo/raw/master/scripts/installer.sh | bash -s
```
-->
**Verify your ligo installation by running:**
**Verify your LIGO installation by running:**
```zsh
ligo --help
```
## Static Linux binary
The `ligo` executable is statically linked. It should run on most modern Linux distributions.
To use it, get it [here](https://ligolang.org/bin/linux/ligo), make it executable, you're done!
```zsh
wget https://ligolang.org/bin/linux/ligo
chmod +x ./ligo
```
Optionally, you can put it somewhere in your `PATH` for easy access:
```zsh
sudo cp ./ligo /usr/local/bin
```
## Debian Linux package installation
We have produced .deb packages for a few Debian Linux versions. They will install a global `ligo` executable.
First download one of the packages below, and then install using:
A `.deb` package containing the static `ligo` executable is also available.
First, download [the package](https://ligolang.org/deb/ligo.deb), and then install using:
```zsh
sudo apt install ./ligo.deb
```
sudo apt install ./<package_name_here>.deb
```
- [Ubuntu 18.04](/deb/ligo_ubuntu-18.04.deb)
- [Ubuntu 19.04](/deb/ligo_ubuntu-19.04.deb)
- [Debian 9](/deb/ligo_debian-9.deb)
- [Debian 10](/deb/ligo_debian-10.deb)
## Release schedule

View File

@ -1,6 +1,6 @@
---
id: introduction
title: Introduction To LIGO
title: Introduction to LIGO
---
import Tabs from '@theme/Tabs';
@ -9,13 +9,13 @@ import TabItem from '@theme/TabItem';
LIGO is a programming language for writing [Tezos](https://tezos.com/) smart contracts.
Smart contracts are a unique domain with extreme resource constraints and even
more extreme security risks. Unlike desktop, mobile, or web
application development smart contracts cannot rely on cheap CPU time and memory.
application development, smart contracts cannot rely on cheap CPU time and memory.
All resources used by contracts are expensive, and tracked as 'gas costs'. Smart
contracts often directly control money or assets, which if stolen could rack up to
a large financial loss to the contracts controllers and users. Tezos smart contracts
live on the blockchain forever, if there's a bug in them they can't be patched or
amended. Naturally under these conditions it's not possible to develop smart contracts
the way we're used to developing user facing applications.
amended. Naturally, under these conditions, it's not possible to develop smart contracts
the way we're used to developing user-facing applications.
LIGO is designed with these problems in mind. The design philosophy can be
described in a few bullet points:
@ -29,7 +29,7 @@ compiled output using a project like [Mi-Cho-Coq](https://gitlab.com/nomadic-lab
4. Significantly reduce the risk that your smart contract will lose its balance to an [avoidable exploit](https://www.wired.com/2016/06/50-million-hack-just-showed-dao-human/).
LIGO is a functional language designed to include the features you need, while
LIGO is a functional language designed to include the features you need while
avoiding patterns that make formal verification hard. Most useful smart contracts
can express their core functionality in under a thousand lines of code. This makes
them a good target for formal methods, and what can't be easily proven can at least
@ -41,11 +41,11 @@ LIGO currently offers three syntaxes:
- **PascaLIGO**, a syntax inspired by Pascal which provides an
imperative developer experience.
- **CameLIGO**, an [OCaml]((https://ocaml.org/)) inspired
- **CameLIGO**, an [OCaml](https://ocaml.org/) inspired
syntax that allows you to write in a functional style.
- **ReasonLIGO**, an [ReasonML]((https://reasonml.github.io/)) inspired syntax
that builds on the strong points of OCaml. It aims to be familiar for those
- **ReasonLIGO**, a [ReasonML](https://reasonml.github.io/) inspired syntax
that builds on the strong points of OCaml. It aims to be familiar to those
coming from JavaScript.
Let's define some LIGO contract in the three flavours above. Do
@ -134,20 +134,19 @@ This LIGO contract accepts the following LIGO expressions:
---
## Runnable code snippets & exercises
## Runnable code snippets
Some of the sections in this documentation will include runnable code snippets and exercises. Sources for those are available at
Some of the sections in this documentation will include runnable code snippets. Sources for those are available at
the [LIGO Gitlab repository](https://gitlab.com/ligolang/ligo).
### Snippets
For example **code snippets** for the *Types* subsection of this doc, can be found here:
`gitlab-pages/docs/language-basics/src/types/**`
### Exercises
Solutions to exercises can be found e.g. here: `gitlab-pages/docs/language-basics/exercises/types/**/solutions/**`
### Running snippets
### Running snippets / exercise solutions
In certain cases it makes sense to be able to run/evaluate the given snippet or a solution, usually there'll be an example command which you can use, such as:
In certain cases it makes sense to be able to run/evaluate the given snippet. Usually there'll be an example command which you can use, such as:
```shell
ligo evaluate-value -s pascaligo gitlab-pages/docs/language-basics/src/variables-and-constants/const.ligo age

View File

@ -36,6 +36,373 @@ let b : bool = false;
</Syntax>
Common operations:
<Syntax syntax="pascaligo">
<div className="boolean-example-table">
<div className="operation">
and
</div>
<div className="description">
Logical and
</div>
<div className="example">
```pascaligo
const logical_and: bool = True and True;
```
</div>
<div className="operation">
or
</div>
<div className="description">
Logical or
</div>
<div className="example">
```pascaligo
const logical_or: bool = False or True;
```
</div>
<div className="operation">
not
</div>
<div className="description">
Logical not
</div>
<div className="example">
```pascaligo
const logical_not: bool = not False;
```
</div>
<div className="operation">
=
</div>
<div className="description">
Equals
</div>
<div className="example">
```pascaligo
const eq: bool = 2 = 3;
```
</div>
<div className="operation">
=/=
</div>
<div className="description">
Not equals
</div>
<div className="example">
```pascaligo
const not_eq: bool = 2 =/= 3;
```
</div>
<div className="operation">
&gt;
</div>
<div className="description">
Greater than
</div>
<div className="example">
```pascaligo
const gt: bool = 4 > 3;
```
</div>
<div className="operation">
&lt;
</div>
<div className="description">
Less than
</div>
<div className="example">
```pascaligo
const lt: bool = 4 < 3;
```
</div>
<div className="operation">
&gt;=
</div>
<div className="description">
Greater than or equal to
</div>
<div className="example">
```pascaligo
const gte: bool = 4 >= 3;
```
</div>
<div className="operation">
&lt;=
</div>
<div className="description">
Less than or equal to
</div>
<div className="example">
```pascaligo
const lte: bool = 4 <= 3;
```
</div>
</div>
</Syntax>
<Syntax syntax="cameligo">
<div className="boolean-example-table">
<div className="operation">
&&
</div>
<div className="description">
Logical and
</div>
<div className="example">
```cameligo
let logical_and: bool = true && true
```
</div>
<div className="operation">
||
</div>
<div className="description">
Logical or
</div>
<div className="example">
```cameligo
let logical_or: bool = false || true
```
</div>
<div className="operation">
!
</div>
<div className="description">
Logical not
</div>
<div className="example">
```cameligo
let logical_not: bool = not false
```
</div>
<div className="operation">
=
</div>
<div className="description">
Equals
</div>
<div className="example">
```cameligo
let eq: bool = 2 = 3
```
</div>
<div className="operation">
&lt;&gt;
</div>
<div className="description">
Not equals
</div>
<div className="example">
```cameligo
let not_eq: bool = 2 <> 3
```
</div>
<div className="operation">
&gt;
</div>
<div className="description">
Greater than
</div>
<div className="example">
```cameligo
let gt: bool = 4 > 3
```
</div>
<div className="operation">
&lt;
</div>
<div className="description">
Less than
</div>
<div className="example">
```cameligo
let lt: bool = 4 < 3
```
</div>
<div className="operation">
&gt;=
</div>
<div className="description">
Greater than or equal to
</div>
<div className="example">
```cameligo
let gte: bool = 4 >= 3
```
</div>
<div className="operation">
&lt;=
</div>
<div className="description">
Less than or equal to
</div>
<div className="example">
```cameligo
let lte: bool = 4 <= 3
```
</div>
</div>
</Syntax>
<Syntax syntax="reasonligo">
<div className="boolean-example-table">
<div className="operation">
&&
</div>
<div className="description">
Logical and
</div>
<div className="example">
```reasonligo
let logical_and: bool = true && true;
```
</div>
<div className="operation">
||
</div>
<div className="description">
Logical or
</div>
<div className="example">
```reasonligo
let logical_or: bool = false || true;
```
</div>
<div className="operation">
!
</div>
<div className="description">
Logical not
</div>
<div className="example">
```reasonligo
let logical_not: bool = !false;
```
</div>
<div className="operation">
==
</div>
<div className="description">
Equals
</div>
<div className="example">
```reasonligo
let eq: bool = 2 == 3;
```
</div>
<div className="operation">
!=
</div>
<div className="description">
Not equals
</div>
<div className="example">
```reasonligo
let not_eq: bool = 2 != 3;
```
</div>
<div className="operation">
&gt;
</div>
<div className="description">
Greater than
</div>
<div className="example">
```reasonligo
let gt: bool = 4 > 3;
```
</div>
<div className="operation">
&lt;
</div>
<div className="description">
Less than
</div>
<div className="example">
```reasonligo
let lt: bool = 4 < 3;
```
</div>
<div className="operation">
&gt;=
</div>
<div className="description">
Greater than or equal to
</div>
<div className="example">
```reasonligo
let gte: bool = 4 >= 3;
```
</div>
<div className="operation">
&lt;=
</div>
<div className="description">
Less than or equal to
</div>
<div className="example">
```reasonligo
let lte: bool = 4 <= 3;
```
</div>
</div>
</Syntax>
## Comparing Values
@ -152,6 +519,7 @@ let c : bool = (a = b) // false
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo group=d
let a : tez = 5mutez;
let b : tez = 10mutez;
@ -181,7 +549,7 @@ You can run the `compare` function defined above using the LIGO compiler
like this:
```shell
ligo run-function
gitlab-pages/docs/language-basics/boolean-if-else/cond.ligo compare 21n'
gitlab-pages/docs/language-basics/src/boolean-if-else/cond.ligo compare '21n'
# Outputs: Large(Unit)
```
@ -222,7 +590,7 @@ You can run the `compare` function defined above using the LIGO compiler
like this:
```shell
ligo run-function
gitlab-pages/docs/language-basics/boolean-if-else/cond.mligo compare 21n'
gitlab-pages/docs/language-basics/src/boolean-if-else/cond.mligo compare '21n'
# Outputs: Large
```
@ -245,7 +613,7 @@ You can run the `compare` function defined above using the LIGO compiler
like this:
```shell
ligo run-function
gitlab-pages/docs/language-basics/boolean-if-else/cond.religo compare 21n'
gitlab-pages/docs/language-basics/src/boolean-if-else/cond.religo compare '21n'
# Outputs: Large
```

View File

@ -127,7 +127,7 @@ in CameLIGO. While this approach is faithful to the original OCaml,
it is costlier in Michelson than naive function execution accepting
multiple arguments. Instead, for most functions with more than one
parameter, we should gather the arguments in a
[tuple](language-basics/sets-lists-tuples.md) and pass the tuple in as
[tuple](sets-lists-tuples.md) and pass the tuple in as
a single parameter.
Here is how you define a basic function that accepts two integers and
@ -342,7 +342,7 @@ At the moment, recursive function are limited to one (possibly tupled) parameter
limited to tail recursion (i.e the recursive call should be the last expression of the function)
<Syntax syntax="pascaligo">
In PascaLigo recursive functions are defined using the `recursive` keyword
In PascaLIGO recursive functions are defined using the `recursive` keyword
```pascaligo group=d
recursive function sum (const n : int; const acc: int) : int is
@ -353,7 +353,7 @@ recursive function fibo (const n: int; const n_1: int; const n_0 :int) : int is
```
</Syntax>
<Syntax syntax="cameligo">
In CameLigo recursive functions are defined using the `rec` keyword
In CameLIGO recursive functions are defined using the `rec` keyword
```cameligo group=d
let rec sum ((n,acc):int * int) : int =
@ -364,7 +364,7 @@ let rec fibo ((n,n_1,n_0):int*int*int) : int =
```
</Syntax>
<Syntax syntax="reasonligo">
In ReasonLigo recursive functions are defined using the `rec` keyword
In ReasonLIGO recursive functions are defined using the `rec` keyword
```reasonligo group=d
let rec sum = ((n, acc) : (int,int)): int =>

View File

@ -1,6 +1,6 @@
---
id: loops
title: Loops
title: Iteration
---
import Syntax from '@theme/Syntax';
@ -110,6 +110,7 @@ let gcd = ((x,y) : (nat, nat)) : nat => {
</Syntax>
<Syntax syntax="pascaligo">
## Bounded Loops
@ -212,3 +213,5 @@ gitlab-pages/docs/language-basics/src/loops/collection.ligo sum_map
'map ["1"->1; "2"->2; "3"->3]'
# Outputs: ( "123", 6 )
```
</Syntax>

View File

@ -5,20 +5,18 @@ title: Records and Maps
import Syntax from '@theme/Syntax';
So far we have seen pretty basic data types. LIGO also offers more
So far, we have seen pretty basic data types. LIGO also offers more
complex built-in constructs, such as *records* and *maps*.
## Records
Records are one way data of different types can be packed into a
Records are one-way data of different types can be packed into a
single type. A record is made of a set of *fields*, which are made of
a *field name* and a *field type*. Given a value of a record type, the
value bound to a field can be accessed by giving its field name to a
special operator (`.`).
Let us first consider and example of record type declaration.
Let us first consider an example of record type declaration.
<Syntax syntax="pascaligo">
@ -55,10 +53,8 @@ type user = {
</Syntax>
And here is how a record value is defined:
<Syntax syntax="pascaligo">
```pascaligo group=records1
@ -138,13 +134,11 @@ updated record.
Let us consider defining a function that translates three-dimensional
points on a plane.
<Syntax syntax="pascaligo">
In PascaLIGO, the shape of that expression is
`<record variable> with <record value>`.
The record variable is the record to update and the
The record variable is the record to update, and the
record value is the update itself.
```pascaligo group=records2
@ -162,13 +156,13 @@ following command of the shell:
```shell
ligo run-function
gitlab-pages/docs/language-basics/src/maps-records/record_update.ligo
translate "(record [x=2;y=3;z=1], record [dx=3;dy=4])"
xy_translate "(record [x=2;y=3;z=1], record [dx=3;dy=4])"
# Outputs: {z = 1 , y = 7 , x = 5}
```
You have to understand that `p` has not been changed by the functional
update: a namless new version of it has been created and returned by
the blockless function.
update: a nameless new version of it has been created and returned by
the block-less function.
</Syntax>
<Syntax syntax="cameligo">
@ -188,6 +182,7 @@ let xy_translate (p, vec : point * vector) : point =
You can call the function `xy_translate` defined above by running the
following command of the shell:
```shell
ligo run-function
gitlab-pages/docs/language-basics/src/maps-records/record_update.mligo
@ -220,6 +215,7 @@ let xy_translate = ((p, vec) : (point, vector)) : point =>
You can call the function `xy_translate` defined above by running the
following command of the shell:
```shell
ligo run-function
gitlab-pages/docs/language-basics/src/maps-records/record_update.religo
@ -230,10 +226,119 @@ xy_translate "({x:2,y:3,z:1}, {dx:3,dy:4})"
You have to understand that `p` has not been changed by the functional
update: a nameless new version of it has been created and returned.
#### Nested updates
A unique feature of LIGO is the ability to perform nested updates on records.
For example if you have the following record structure:
<Syntax syntax="pascaligo">
```pascaligo
type color is
| Blue
| Green
type preferences is record [
color : color;
other : int;
]
type account is record [
id : int;
preferences : preferences;
]
```
</Syntax>
<Syntax syntax="cameligo">
```cameligo
type color =
Blue
| Green
type preferences = {
color : color;
other : int;
}
type account = {
id: int;
preferences: preferences;
}
```
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo
type color =
Blue
| Green;
type preferences = {
color : color,
other : int
}
type account = {
id : int,
preferences : preferences
}
```
</Syntax>
You can update the nested record with the following code:
<Syntax syntax="pascaligo">
```pascaligo
function change_color_preference (const account : account; const color : color ) : account is
block {
account := account with record [preferences.color = color]
} with account
```
</Syntax>
<Syntax syntax="cameligo">
```cameligo
let change_color_preference (account : account) (color : color) : account =
{ account with preferences.color = color }
```
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo
let change_color_preference = (account : account, color : color): account =>
{ ...account, preferences.color: color };
```
</Syntax>
Note that all the records in the path will get updated. In this example that's
`account` and `preferences`.
You can call the function `change_color_preference` defined above by running the
following command:
```shell
ligo run-function gitlab-pages/docs/language-basics/src/maps-records/record_nested_update.ligo
change_color_preference "(record [id=1001; preferences=record [color=Blue; other=1]], Green)"
# Outputs: record[id -> 1001 , preferences -> record[color -> Green(unit) , other -> 1]]
```
<Syntax syntax="pascaligo">
### Record Patches
Another way to understand what it means to update a record value is to
make sure that any further reference to the value afterwards will
make sure that any further reference to the value afterward will
exhibit the modification. This is called a `patch` and this is only
possible in PascaLIGO, because a patch is an *instruction*, therefore
we can only use it in a block. Similarly to a *functional update*, a
@ -248,8 +353,6 @@ points on a plane.
type point is record [x : int; y : int; z : int]
type vector is record [dx : int; dy : int]
const origin : point = record [x = 0; y = 0; z = 0]
function xy_translate (var p : point; const vec : vector) : point is
block {
patch p with record [x = p.x + vec.dx];
@ -259,6 +362,7 @@ function xy_translate (var p : point; const vec : vector) : point is
You can call the function `xy_translate` defined above by running the
following command of the shell:
```shell
ligo run-function
gitlab-pages/docs/language-basics/src/maps-records/record_patch.ligo
@ -274,8 +378,6 @@ the value of `p` indeed changed. So, a shorter version would be
type point is record [x : int; y : int; z : int]
type vector is record [dx : int; dy : int]
const origin : point = record [x = 0; y = 0; z = 0]
function xy_translate (var p : point; const vec : vector) : point is
block {
patch p with record [x = p.x + vec.dx; y = p.y + vec.dy]
@ -284,6 +386,7 @@ function xy_translate (var p : point; const vec : vector) : point is
You can call the new function `xy_translate` defined above by running the
following command of the shell:
```shell
ligo run-function
gitlab-pages/docs/language-basics/src/maps-records/record_patch2.ligo
@ -299,8 +402,6 @@ one we want to update* and use a functional update, like so:
type point is record [x : int; y : int; z : int]
type vector is record [dx : int; dy : int]
const origin : point = record [x = 0; y = 0; z = 0]
function xy_translate (var p : point; const vec : vector) : point is
block {
const p : point = p with record [x = p.x + vec.dx; y = p.y + vec.dy]
@ -309,6 +410,7 @@ function xy_translate (var p : point; const vec : vector) : point is
You can call the new function `xy_translate` defined above by running the
following command of the shell:
```shell
ligo run-function
gitlab-pages/docs/language-basics/src/maps-records/record_simu.ligo
@ -318,6 +420,8 @@ xy_translate "(record [x=2;y=3;z=1], record [dx=3;dy=4])"
The hiding of a variable by another (here `p`) is called `shadowing`.
</Syntax>
## Maps
*Maps* are a data structure which associate values of the same type to
@ -331,8 +435,6 @@ sense.
Here is how a custom map from addresses to a pair of integers is
defined.
<Syntax syntax="pascaligo">
```pascaligo group=maps
@ -586,8 +688,8 @@ let assign = (m : register) : register =>
(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address), Some ((4,9)), m);
```
Notice the optional value `Some (4,9)` instead of `(4,9)`. If we had
use `None` instead, that would have meant that the binding is removed.
Notice the optional value `Some (4,9)` instead of `(4,9)`. If we used
`None` instead that would have meant that the binding is removed.
As a particular case, we can only add a key and its associated value.
@ -599,7 +701,6 @@ let add = (m : register) : register =>
</Syntax>
To remove a binding from a map, we need its key.
@ -654,8 +755,8 @@ There are three kinds of functional iterations over LIGO maps: the
The first, the *iterated operation*, is an iteration over the map with
no return value: its only use is to produce side-effects. This can be
useful if for example you would like to check that each value inside
of a map is within a certain range, and fail with an error otherwise.
useful if, for example you would like to check that each value inside
of a map is within a certain range and fail with an error otherwise.
The predefined functional iterator implementing the iterated operation
over maps is called `Map.iter`. In the following example, the register
@ -891,7 +992,7 @@ let moves : register =
(("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address), (0,3))]
```
The predefind function `Big_map.literal` constructs a big map from a
The predefined function `Big_map.literal` constructs a big map from a
list of key-value pairs `(<key>, <value>)`. Note also the semicolon
separating individual map entries. The annotated value `("<string>
value>" : address)` means that we cast a string into an address.
@ -906,7 +1007,7 @@ let moves : register =
("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address, (0,3))]);
```
The predefind function `Big_map.literal` constructs a big map from a
The predefined function `Big_map.literal` constructs a big map from a
list of key-value pairs `(<key>, <value>)`. Note also the semicolon
separating individual map entries. The annotated value `("<string>
value>" : address)` means that we cast a string into an address.
@ -959,12 +1060,23 @@ The values of a PascaLIGO big map can be updated using the
assignment syntax for ordinary maps
```pascaligo group=big_maps
function add (var m : register) : register is
function assign (var m : register) : register is
block {
m [("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN": address)] := (4,9)
} with m
```
const updated_map : register = add (moves)
If multiple bindings need to be updated, PascaLIGO offers a *patch
instruction* for maps, similar to that for records.
```pascaligo group=big_maps
function assignments (var m : register) : register is
block {
patch m with map [
("tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN" : address) -> (4,9);
("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address) -> (1,2)
]
} with m
```
</Syntax>
@ -1038,4 +1150,3 @@ let updated_map : register =
```
</Syntax>

View File

@ -25,7 +25,7 @@ Like records, tuple components can be of arbitrary types.
### Defining Tuples
Unlike [a record](language-basics/maps-records.md), tuple types do not
Unlike [a record](maps-records.md), tuple types do not
have to be defined before they can be used. However below we will give
them names by *type aliasing*.
@ -59,12 +59,58 @@ let full_name : full_name = ("Alice", "Johnson");
</Syntax>
<Syntax syntax="cameligo">
### Destructuring
If we want to get the first and last name of the `full_name` type, we can use
destructuring. Destructuring a tuple allows you to give names to the elements
inside the tuple.
```cameligo group=tuple
let (first_name, last_name) : full_name = full_name
```
This also works in functions:
```cameligo group=tuple
let first_name ((first_name, _): full_name) = first_name
let alice = first_name full_name
```
Notice that we use the underscore to indicate that we ignore the last element
of the tuple.
</Syntax>
<Syntax syntax="reasonligo">
### Destructuring
If we want to get the first and last name of the `full_name` type, we can use
destructuring. Destructuring a tuple allows you to give names to the elements
inside the tuple.
```reasonligo group=tuple
let (first_name, last_name) : full_name = full_name
```
This also works in functions:
```reasonligo group=tuple
let first_name = ((first_name, _): full_name) => first_name
let alice = first_name(full_name)
```
Notice that we use the underscore to indicate that we ignore the last element
of the tuple.
</Syntax>
### Accessing Components
Accessing the components of a tuple in OCaml is achieved by
[pattern matching](language-basics/unit-option-pattern-matching.md). LIGO
[pattern matching](unit-option-pattern-matching.md). LIGO
currently supports tuple patterns only in the parameters of functions,
not in pattern matching. However, we can access components by their
position in their tuple, which cannot be done in OCaml. *Tuple

View File

@ -71,16 +71,17 @@ let full_greeting : string = greeting ++ " " ++ name;
## Slicing Strings
Strings can be sliced using a built-in function:
## Extracting Subtrings
Substrings can be extracted using the predefined function
`String.sub`. The first character has index 0 and the interval of
indices for the substring has inclusive bounds.
<Syntax syntax="pascaligo">
```pascaligo group=b
const name : string = "Alice"
const slice : string = String.slice (0n, 1n, name)
const slice : string = String.sub (0n, 1n, name)
```
> Note that `string_slide` is *deprecated*.
@ -90,17 +91,21 @@ const slice : string = String.slice (0n, 1n, name)
```cameligo group=b
let name : string = "Alice"
let slice : string = String.slice 0n 1n name
let slice : string = String.sub 0n 1n name
```
> Note that `String.slice` is *deprecated*.
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo group=b
let name : string = "Alice";
let slice : string = String.slice (0n, 1n, name);
let slice : string = String.sub (0n, 1n, name);
```
> Note that `String.slice` is *deprecated*.
</Syntax>
@ -126,16 +131,20 @@ const length : nat = String.length (name) // length = 5
```cameligo group=c
let name : string = "Alice"
let length : nat = String.size name // length = 5
let length : nat = String.length name // length = 5
```
> Note that `String.size` is *deprecated*.
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo group=c
let name : string = "Alice";
let length : nat = String.size (name); // length == 5
let length : nat = String.length (name); // length == 5
```
> Note that `String.size` is *deprecated*.
</Syntax>

View File

@ -11,10 +11,11 @@ functions. This page will tell you about them.
## Pack and Unpack
Michelson provides the `PACK` and `UNPACK` instructions for data
serialization. The former converts Michelson data structures into a
binary format, and the latter reverses that transformation. This
functionality can be accessed from within LIGO.
As Michelson provides the `PACK` and `UNPACK` instructions for data
serialization, so does LIGO with `Bytes.pack` and `Bytes.unpack`. The
former serializes Michelson data structures into a binary format, and
the latter reverses that transformation. Unpacking may fail, so the
return type of `Byte.unpack` is an option that needs to be annotated.
> ⚠️ `PACK` and `UNPACK` are Michelson instructions that are intended
> to be used by people that really know what they are doing. There are
@ -28,11 +29,11 @@ functionality can be accessed from within LIGO.
```pascaligo group=a
function id_string (const p : string) : option (string) is block {
const packed : bytes = bytes_pack (p)
const packed : bytes = Bytes.pack (p)
} with (Bytes.unpack (packed) : option (string))
```
> Note that `bytes_unpack` is *deprecated*.
> Note that `bytes_pack` and `bytes_unpack` are *deprecated*.
</Syntax>
<Syntax syntax="cameligo">
@ -72,18 +73,21 @@ a predefined functions returning a value of type `key_hash`.
function check_hash_key (const kh1 : key_hash; const k2 : key) : bool * key_hash is
block {
var ret : bool := False;
var kh2 : key_hash := crypto_hash_key (k2);
var kh2 : key_hash := Crypto.hash_key (k2);
if kh1 = kh2 then ret := True else skip
} with (ret, kh2)
```
> Note that `hash_key` is *deprecated*. Please use `Crypto.hash_key`.
</Syntax>
<Syntax syntax="cameligo">
```cameligo group=b
let check_hash_key (kh1, k2 : key_hash * key) : bool * key_hash =
let kh2 : key_hash = Crypto.hash_key k2 in
if kh1 = kh2 then true, kh2 else false, kh2
(kh1 = kh2), kh2
```
</Syntax>
@ -92,7 +96,7 @@ let check_hash_key (kh1, k2 : key_hash * key) : bool * key_hash =
```reasonligo group=b
let check_hash_key = ((kh1, k2) : (key_hash, key)) : (bool, key_hash) => {
let kh2 : key_hash = Crypto.hash_key (k2);
if (kh1 == kh2) { (true, kh2); } else { (false, kh2); }
((kh1 == kh2), kh2);
};
```

View File

@ -9,52 +9,12 @@ import Syntax from '@theme/Syntax';
import SyntaxTitle from '@theme/SyntaxTitle';
A lazily deserialized map that's intended to store large amounts of data.
Lazily means that storage is read or written per key on demand. Therefore
there are no `map`, `fold`, and `iter` operations as in
[Map](map.md).
The gast costs of deserialized maps are higher than standard maps as data is lazily deserialized.
<SyntaxTitle syntax="pascaligo">
type big_map ('key, 'value)
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type ('key, 'value) big_map
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type big_map ('key, 'value)
</SyntaxTitle>
<Syntax syntax="pascaligo">
The type of a big map from values of type `key` to
values of type `value` is `big_map (key, value)`.
```pascaligo group=big_map
type move is int * int
type register is big_map (address, move)
```
</Syntax>
<Syntax syntax="cameligo">
The type of a big map from values of type `key` to values
of type `value` is `(key, value) big_map`.
```cameligo group=big_map
type move = int * int
type register = (address, move) big_map
```
</Syntax>
<Syntax syntax="reasonligo">
The type of a big map from values of type `key` to
values of type `value` is `big_map (key, value)`.
```reasonligo group=big_map
type move = (int, int);
type register = big_map (address, move);
```
</Syntax>
The gas costs of big maps are higher than standard maps as data is lazily
deserialized.
<SyntaxTitle syntax="pascaligo">
function empty : big_map ('key, 'value)
@ -71,6 +31,9 @@ Create an empty big_map.
<Syntax syntax="pascaligo">
```pascaligo group=big_map
type move is int * int
type register is big_map (address, move)
const empty : register = Big_map.empty
```
@ -84,6 +47,9 @@ const empty_alternative : register = big_map []
<Syntax syntax="cameligo">
```cameligo group=big_map
type move = int * int
type register = (address, move) big_map
let empty : register = Big_map.empty
```
@ -91,6 +57,9 @@ let empty : register = Big_map.empty
<Syntax syntax="reasonligo">
```reasonligo group=big_map
type move = (int, int);
type register = big_map(address, move);
let empty: register = Big_map.empty
```

View File

@ -9,17 +9,42 @@ import Syntax from '@theme/Syntax';
import SyntaxTitle from '@theme/SyntaxTitle';
<SyntaxTitle syntax="pascaligo">
function and : nat -> nat -> nat
function and : 'a -> nat -> nat
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
val and : nat -> nat -> nat
val and : 'a -> nat -> nat
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
let and: (nat, nat) -> nat
let and: ('a, nat) => nat
</SyntaxTitle>
`'a` can either be an `int` or `nat`.
A bitwise `and` operation.
<Syntax syntax="pascaligo">
```pascaligo
const zero: nat = Bitwise.and(2n, 1n)
```
</Syntax>
<Syntax syntax="cameligo">
```cameligo
let zero: nat = Bitwise.and 2n 1n
```
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo
let zero: nat = Bitwise.and(2n, 1n);
```
</Syntax>
<SyntaxTitle syntax="pascaligo">
function or : nat -> nat -> nat
</SyntaxTitle>
@ -27,11 +52,33 @@ function or : nat -> nat -> nat
val or : nat -> nat -> nat
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
let or: (nat, nat) -> nat
let or: (nat, nat) => nat
</SyntaxTitle>
A bitwise `or` operation.
<Syntax syntax="pascaligo">
```pascaligo
const three: nat = Bitwise.or(2n, 1n)
```
</Syntax>
<Syntax syntax="cameligo">
```cameligo
let three: nat = Bitwise.or 2n 1n
```
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo
let three: nat = Bitwise.or(2n, 1n);
```
</Syntax>
<SyntaxTitle syntax="pascaligo">
function xor : nat -> nat -> nat
</SyntaxTitle>
@ -39,11 +86,33 @@ function xor : nat -> nat -> nat
val xor : nat -> nat -> nat
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
let xor: (nat, nat) -> nat
let xor: (nat, nat) => nat
</SyntaxTitle>
A bitwise `xor` operation.
<Syntax syntax="pascaligo">
```pascaligo
const three: nat = Bitwise.xor(2n, 1n)
```
</Syntax>
<Syntax syntax="cameligo">
```cameligo
let three: nat = Bitwise.xor 2n 1n
```
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo
let three: nat = Bitwise.xor(2n, 1n);
```
</Syntax>
<SyntaxTitle syntax="pascaligo">
function shift_left : nat -> nat -> nat
</SyntaxTitle>
@ -51,11 +120,33 @@ function shift_left : nat -> nat -> nat
val shift_left : nat -> nat -> nat
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
let shift_left: (nat, nat) -> nat
let shift_left: (nat, nat) => nat
</SyntaxTitle>
A bitwise shift left operation.
<Syntax syntax="pascaligo">
```pascaligo
const four: nat = Bitwise.shift_left(2n, 1n)
```
</Syntax>
<Syntax syntax="cameligo">
```cameligo
let four: nat = Bitwise.shift_left 2n 1n
```
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo
let four: nat = Bitwise.shift_left(2n, 1n);
```
</Syntax>
<SyntaxTitle syntax="pascaligo">
function shift_right : nat -> nat -> nat
</SyntaxTitle>
@ -63,7 +154,29 @@ function shift_right : nat -> nat -> nat
val shift_right : nat -> nat -> nat
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
let shift_right: (nat, nat) -> nat
let shift_right: (nat, nat) => nat
</SyntaxTitle>
A bitwise shift right operation.
<Syntax syntax="pascaligo">
```pascaligo
const one: nat = Bitwise.shift_right(2n, 1n)
```
</Syntax>
<Syntax syntax="cameligo">
```cameligo
let one: nat = Bitwise.shift_right 2n 1n
```
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo
let one: nat = Bitwise.shift_right(2n, 1n);
```
</Syntax>

View File

@ -8,16 +8,6 @@ hide_table_of_contents: true
import Syntax from '@theme/Syntax';
import SyntaxTitle from '@theme/SyntaxTitle';
<SyntaxTitle syntax="pascaligo">
type bytes
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type bytes
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type bytes
</SyntaxTitle>
<SyntaxTitle syntax="pascaligo">
function concat : bytes -> bytes -> bytes
</SyntaxTitle>
@ -65,8 +55,8 @@ val sub : nat -> nat -> bytes -> bytes
let sub : (nat, nat, bytes) => bytes
</SyntaxTitle>
Extract the bytes between `pos1` and `pos2`. **Positions are zero indexed and
inclusive**. For example if you gave the input "ff7a7aff" to the following:
Extract bytes from `start` to `length`. For example if you gave the
input "ff7a7aff" to the following function:
<Syntax syntax="pascaligo">
@ -96,7 +86,7 @@ let slice_op = (s: bytes): bytes => Bytes.sub(1n, 2n, s);
</Syntax>
It would return "7a7a" rather than "ff7a" or "ff" or "7a".
It would return "7a7a".
<SyntaxTitle syntax="pascaligo">
function pack : 'a -> bytes

View File

@ -8,42 +8,6 @@ hide_table_of_contents: true
import Syntax from '@theme/Syntax';
import SyntaxTitle from '@theme/SyntaxTitle';
<SyntaxTitle syntax="pascaligo">
type key
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type key
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type key
</SyntaxTitle>
A public cryptographic key.
<SyntaxTitle syntax="pascaligo">
type key_hash
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type key_hash
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type key_hash
</SyntaxTitle>
The hash of a public cryptographic key.
<SyntaxTitle syntax="pascaligo">
type signature
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type signature
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type signature
</SyntaxTitle>
A cryptographic signature.
<SyntaxTitle syntax="pascaligo">
function blake2b : bytes -> bytes
</SyntaxTitle>

View File

@ -9,93 +9,17 @@ import Syntax from '@theme/Syntax';
import SyntaxTitle from '@theme/SyntaxTitle';
<SyntaxTitle syntax="pascaligo">
type timestamp
function balance : tez
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type timestamp
val balance : tez
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type timestamp
</SyntaxTitle>
A date in the real world.
<SyntaxTitle syntax="pascaligo">
type mutez
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type mutez
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type mutez
</SyntaxTitle>
A specific type for tokens.
<SyntaxTitle syntax="pascaligo">
type address
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type address
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type address
</SyntaxTitle>
An untyped address which can refer to a smart contract or account.
<SyntaxTitle syntax="pascaligo">
type contract('parameter)
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type 'parameter contract
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type contract('parameter)
</SyntaxTitle>
A typed contract.
Use `unit` as `parameter` to indicate an implicit account.
<SyntaxTitle syntax="pascaligo">
type operation
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type operation
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type operation
</SyntaxTitle>
An operation emitted by the contract
<SyntaxTitle syntax="pascaligo">
type chain_id
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type chain_id
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type chain_id
</SyntaxTitle>
The identifier of a chain, used to indicate test or main chains.
<SyntaxTitle syntax="pascaligo">
function balance : mutez
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
val balance : mutez
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
let balance: mutez
let balance: tez
</SyntaxTitle>
Get the balance for the contract.
<Syntax syntax="pascaligo">
```pascaligo
@ -263,13 +187,13 @@ let not_tomorrow: bool = (Tezos.now == in_24_hrs);
<SyntaxTitle syntax="pascaligo">
function amount : mutez
function amount : tez
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
val amount : mutez
val amount : tez
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
let amount: mutez
let amount: tez
</SyntaxTitle>
Get the amount of tez provided by the sender to complete this
@ -598,48 +522,17 @@ let main = (p : unit) : address => Tezos.source;
<SyntaxTitle syntax="pascaligo">
function failwith : string -> unit
function failwith : 'a -> unit
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
function failwith : string -> unit
function failwith : 'a -> unit
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
function failwith : string -> unit
function failwith: 'a -> unit
</SyntaxTitle>
Cause the contract to fail with an error message.
[See `failwith`](toplevel.md#failwith)
> ⚠ Using this currently requires in general a type annotation on the
> `failwith` call.
<Syntax syntax="pascaligo">
```pascaligo
function main (const p : int; const s : unit) : list (operation) * unit is
block {
if p > 10 then failwith ("Failure.") else skip
}
with ((nil : list (operation)), s)
```
</Syntax>
<Syntax syntax="cameligo">
```cameligo
let main (p,s : int * unit) = if p > 10 then failwith "Failure."
```
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo
let main = ((p,s) : (int, unit)) =>
if (p > 10) { failwith ("Failure."); };
```
</Syntax>
<SyntaxTitle syntax="pascaligo">
function chain_id : chain_id
@ -713,10 +606,19 @@ val transaction : 'parameter -> mutez -> 'parameter contract -> operation
let transaction: 'parameter -> mutez -> contract('parameter) -> operation
</SyntaxTitle>
Create a transaction to a contract or account.
Transfer `tez` to an account, or run code of another smart contract.
To indicate an account, use `unit` as `parameter`.
<Syntax syntax="pascaligo">
Note that `transaction` is deprecated. Please use `Tezos.transaction` instead.
</Syntax>
<Syntax syntax="cameligo">
Note that `transaction` is deprecated. Please use `Tezos.transaction` instead.
</Syntax>
<Syntax syntax="reasonligo">
Note that `transaction` is deprecated. Please use `Tezos.transaction` instead.
</Syntax>
<SyntaxTitle syntax="pascaligo">
function set_delegate : option(key_hash) -> operation
@ -728,9 +630,26 @@ val set_delegate : key_hash option -> operation
let set_delegate: option(key_hash) => operation
</SyntaxTitle>
Create a delegation.
Modify the [delegate](http://tezos.gitlab.io/user/glossary.html?highlight=delegate#delegate) of the current contract.
See also: http://tezos.gitlab.io/user/glossary.html?highlight=delegate#delegate
The operation fails when:
- the delegate is the same as current delegate
- the keyhash is not of a registered delegate
Use `None` to withdraw the current delegate.
<Syntax syntax="pascaligo">
Note that `set_delegate` is deprecated. Please use `Tezos.set_delegate`
instead.
</Syntax>
<Syntax syntax="cameligo">
Note that `Operation.set_delegate` is deprecated. Please use
`Tezos.set_delegate` instead.
</Syntax>
<Syntax syntax="reasonligo">
Note that `Operation.set_delegate` is deprecated. Please use
`Tezos.set_delegate` instead.
</Syntax>
<SyntaxTitle syntax="pascaligo">
function get_contract_opt : address -> option(contract('parameter))
@ -747,6 +666,19 @@ Get a contract from an address.
When no contract is found or the contract doesn't match the type,
`None` is returned.
<Syntax syntax="pascaligo">
Note that `get_contract` and `get_contract_opt` are deprecated. Please use
`Tezos.get_contract_opt` instead.
</Syntax>
<Syntax syntax="cameligo">
Note that `Operation.get_contract` and `Operation.get_contract_opt` are
deprecated. Please use `Tezos.get_contract_opt` instead.
</Syntax>
<Syntax syntax="reasonligo">
Note that `Operation.get_contract` and `Operation.get_contract_opt` are
deprecated. Please use `Tezos.get_contract_opt` instead.
</Syntax>
<SyntaxTitle syntax="pascaligo">
function get_entrypoint_opt : string -> address -> option(contract('parameter))
</SyntaxTitle>
@ -763,3 +695,18 @@ Entrypoints are written in the form of: `%entrypoint`.
When no contract is found or the contract doesn't match the type,
`None` is returned.
<Syntax syntax="pascaligo">
Note that `get_entrypoint` and `get_entrypoint_opt` are deprecated. Please use
`Tezos.get_entrypoint_opt` instead.
</Syntax>
<Syntax syntax="cameligo">
Note that `Operation.get_entrypoint` and `Operation.get_entrypoint_opt` are
deprecated. Please use `Tezos.get_entrypoint_opt` instead.
</Syntax>
<Syntax syntax="reasonligo">
Note that `Operation.get_entrypoint` and `Operation.get_entrypoint_opt` are
deprecated. Please use `Tezos.get_entrypoint_opt` instead.
</Syntax>

View File

@ -8,18 +8,6 @@ hide_table_of_contents: true
import Syntax from '@theme/Syntax';
import SyntaxTitle from '@theme/SyntaxTitle';
<SyntaxTitle syntax="pascaligo">
type list ('t)
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type 't list
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type list('t)
</SyntaxTitle>
A sequence of elements of the same type.
<SyntaxTitle syntax="pascaligo">
function length : nat
</SyntaxTitle>
@ -155,7 +143,7 @@ val fold : ('accumulator -> 'item -> 'accumulator) -> 'item list -> 'accumulator
let fold: ((('accumulator, 'item) => 'accumulator), list('item), 'accumulator) => 'accumulator
</SyntaxTitle>
[Fold over items in a list](../language-basics/sets-lists-tuples#folded-operation-over-lists);
[Fold over items in a list](../language-basics/sets-lists-tuples.md#folded-operation-over-lists);
<Syntax syntax="pascaligo">

View File

@ -8,50 +8,6 @@ hide_table_of_contents: true
import Syntax from '@theme/Syntax';
import SyntaxTitle from '@theme/SyntaxTitle';
<SyntaxTitle syntax="pascaligo">
type map ('key, 'value)
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type ('key, 'value) map
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type map ('key, 'value)
</SyntaxTitle>
<Syntax syntax="pascaligo">
The type of a map from values of type `key` to
values of type `value` is `map (key, value)`.
```pascaligo group=maps
type move is int * int
type register is map (address, move)
```
</Syntax>
<Syntax syntax="cameligo">
The type of a map from values of type `key` to values
of type `value` is `(key, value) map`.
```cameligo group=maps
type move = int * int
type register = (address, move) map
```
</Syntax>
<Syntax syntax="reasonligo">
The type of a map from values of type `key` to
values of type `value` is `map (key, value)`.
```reasonligo group=maps
type move = (int, int);
type register = map (address, move);
```
</Syntax>
<SyntaxTitle syntax="pascaligo">
function empty : map ('key, 'value)
</SyntaxTitle>
@ -67,6 +23,9 @@ Create an empty map.
<Syntax syntax="pascaligo">
```pascaligo group=maps
type move is int * int
type register is map (address, move)
const empty : register = Map.empty
```
@ -80,6 +39,9 @@ const empty : register = map []
<Syntax syntax="cameligo">
```cameligo group=maps
type move = int * int
type register = (address, move) map
let empty : register = Map.empty
```
@ -87,6 +49,9 @@ let empty : register = Map.empty
<Syntax syntax="reasonligo">
```reasonligo group=maps
type move = (int, int);
type register = map (address, move);
let empty : register = Map.empty
```

View File

@ -10,16 +10,6 @@ import SyntaxTitle from '@theme/SyntaxTitle';
Sets are unordered collections of unique values of the same type.
<SyntaxTitle syntax="pascaligo">
type set ('value)
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type 'value set
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type set('value)
</SyntaxTitle>
<SyntaxTitle syntax="pascaligo">
function empty : set('value)
</SyntaxTitle>
@ -258,7 +248,7 @@ val fold : ('accumulator -> 'item -> 'accumulator) -> 'set list -> 'accumulator
let fold: ((('accumulator, 'item) => 'accumulator), set('item), 'accumulator) => 'accumulator
</SyntaxTitle>
[Fold over values in a set](../language-basics/sets-lists-tuples#folded-operation)
[Fold over values in a set](../language-basics/sets-lists-tuples.md#folded-operation)
<Syntax syntax="pascaligo">

View File

@ -8,18 +8,6 @@ hide_table_of_contents: true
import Syntax from '@theme/Syntax';
import SyntaxTitle from '@theme/SyntaxTitle';
<SyntaxTitle syntax="pascaligo">
type string
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type string
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type string
</SyntaxTitle>
A sequence of characters.
<SyntaxTitle syntax="pascaligo">
function length : string -> nat
</SyntaxTitle>
@ -73,8 +61,8 @@ val sub : nat -> nat -> string -> string
let sub: (nat, nat, string) => string
</SyntaxTitle>
Get the substring of `s` between `pos1` inclusive and `pos2` inclusive. For example
the string "tata" given to the function below would return "at".
Extract a substring from a string based on the given offset and length. For
example the string "abcd" given to the function below would return "bc".
<Syntax syntax="pascaligo">

View File

@ -0,0 +1,461 @@
---
id: toplevel
title: Top-Level
description: Available functions at the top level
hide_table_of_contents: true
---
import Syntax from '@theme/Syntax';
import SyntaxTitle from '@theme/SyntaxTitle';
These types and functions are available without any needed prefix.
<SyntaxTitle syntax="pascaligo">
type address
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type address
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type address
</SyntaxTitle>
An untyped address which can refer to a smart contract or account.
<SyntaxTitle syntax="pascaligo">
type big_map ('key, 'value)
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type ('key, 'value) big_map
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type big_map ('key, 'value)
</SyntaxTitle>
<Syntax syntax="pascaligo">
The type of a big map from values of type `key` to
values of type `value` is `big_map (key, value)`.
```pascaligo group=big_map
type move is int * int
type register is big_map (address, move)
```
</Syntax>
<Syntax syntax="cameligo">
The type of a big map from values of type `key` to values
of type `value` is `(key, value) big_map`.
```cameligo group=big_map
type move = int * int
type register = (address, move) big_map
```
</Syntax>
<Syntax syntax="reasonligo">
The type of a big map from values of type `key` to
values of type `value` is `big_map(key, value)`.
```reasonligo group=big_map
type move = (int, int);
type register = big_map(address, move);
```
</Syntax>
Be aware that a `big_map` cannot appear inside another `big_map`.
<SyntaxTitle syntax="pascaligo">
type bool
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type bool
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type bool
</SyntaxTitle>
<SyntaxTitle syntax="pascaligo">
type bytes
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type bytes
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type bytes
</SyntaxTitle>
<SyntaxTitle syntax="pascaligo">
type contract('parameter)
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type 'parameter contract
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type contract('parameter)
</SyntaxTitle>
A typed contract.
Use `unit` as `parameter` to indicate an implicit account.
<SyntaxTitle syntax="pascaligo">
type chain_id
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type chain_id
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type chain_id
</SyntaxTitle>
The identifier of a chain, used to indicate test or main chains.
<SyntaxTitle syntax="pascaligo">
type int
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type int
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type int
</SyntaxTitle>
An integer.
The only size limit to integers is gas.
<SyntaxTitle syntax="pascaligo">
type key
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type key
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type key
</SyntaxTitle>
A public cryptographic key.
<SyntaxTitle syntax="pascaligo">
type key_hash
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type key_hash
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type key_hash
</SyntaxTitle>
The hash of a public cryptographic key.
<SyntaxTitle syntax="pascaligo">
type list ('t)
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type 't list
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type list('t)
</SyntaxTitle>
A sequence of elements of the same type.
<SyntaxTitle syntax="pascaligo">
type map ('key, 'value)
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type ('key, 'value) map
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type map ('key, 'value)
</SyntaxTitle>
<Syntax syntax="pascaligo">
The type of a map from values of type `key` to
values of type `value` is `map (key, value)`.
```pascaligo group=maps
type move is int * int
type register is map (address, move)
```
</Syntax>
<Syntax syntax="cameligo">
The type of a map from values of type `key` to values
of type `value` is `(key, value) map`.
```cameligo group=maps
type move = int * int
type register = (address, move) map
```
</Syntax>
<Syntax syntax="reasonligo">
The type of a map from values of type `key` to
values of type `value` is `map (key, value)`.
```reasonligo group=maps
type move = (int, int);
type register = map (address, move);
```
</Syntax>
<SyntaxTitle syntax="pascaligo">
type nat
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type nat
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type nat
</SyntaxTitle>
A natural number.
The only size limit to natural numbers is gas.
<SyntaxTitle syntax="pascaligo">
type operation
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type operation
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type operation
</SyntaxTitle>
An operation emitted by the contract
<SyntaxTitle syntax="pascaligo">
type set ('value)
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type 'value set
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type set('value)
</SyntaxTitle>
<SyntaxTitle syntax="pascaligo">
type signature
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type signature
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type signature
</SyntaxTitle>
A cryptographic signature.
<SyntaxTitle syntax="pascaligo">
type string
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type string
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type string
</SyntaxTitle>
A sequence of characters.
<SyntaxTitle syntax="pascaligo">
type tez
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type tez
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type tez
</SyntaxTitle>
A specific type for tokens.
<SyntaxTitle syntax="pascaligo">
type timestamp
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type timestamp
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type timestamp
</SyntaxTitle>
A date in the real world.
<SyntaxTitle syntax="pascaligo">
type unit
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
type unit
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
type unit
</SyntaxTitle>
<SyntaxTitle syntax="pascaligo">
function is_nat: int -> option(nat)
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
val is_nat: int -> nat option
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
let is_nat: int => option(nat)
</SyntaxTitle>
Convert an `int` to a `nat` if possible.
Note that `Michelson.is_nat` is deprecated. Please use `is_nat` instead.
<SyntaxTitle syntax="pascaligo">
function abs: int -> nat
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
val abs: int -> nat
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
let abs: int => nat
</SyntaxTitle>
Cast an `int` to `nat`.
<SyntaxTitle syntax="pascaligo">
function int: nat -> int
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
val int: nat -> int
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
let int: nat => int
</SyntaxTitle>
Cast an `nat` to `int`.
<SyntaxTitle syntax="pascaligo">
const unit: unit
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
val unit: unit
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
let (): unit
</SyntaxTitle>
A helper to create a unit.
<a name="failwith"></a>
<SyntaxTitle syntax="pascaligo">
function failwith : 'a -> unit
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
val failwith : 'a -> unit
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
let failwith: 'a => unit
</SyntaxTitle>
Cause the contract to fail with an error message or integer. Other types are
not supported at the moment.
Using this currently requires in general a type annotation on the
`failwith` call.
<Syntax syntax="pascaligo">
```pascaligo
function main (const p : int; const s : unit) : list (operation) * unit is
block {
if p > 10 then failwith ("Failure.") else skip
}
with ((nil : list (operation)), s)
```
</Syntax>
<Syntax syntax="cameligo">
```cameligo
let main (p,s : int * unit) = if p > 10 then failwith "Failure."
```
</Syntax>
<Syntax syntax="reasonligo">
```reasonligo
let main = ((p,s) : (int, unit)) =>
if (p > 10) { failwith ("Failure."); };
```
</Syntax>
<Syntax syntax="cameligo">
`Current.failwith` is deprecated. Use `Tezos.failwith` or `failwith` instead.
</Syntax>
<Syntax syntax="reasonligo">
`Current.failwith` is deprecated. Use `Tezos.failwith` or `failwith` instead.
</Syntax>
<SyntaxTitle syntax="pascaligo">
function assert : bool -> unit
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
val assert : bool -> unit
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
let assert: bool => unit
</SyntaxTitle>
Check if a certain condition has been met. If not the contract will fail.
<SyntaxTitle syntax="pascaligo">
function ediv : int -> int -> option (int * nat)
</SyntaxTitle>
<SyntaxTitle syntax="pascaligo">
function ediv : mutez -> nat -> option (mutez * mutez)
</SyntaxTitle>
<SyntaxTitle syntax="pascaligo">
function ediv : mutez -> mutez -> option (nat * mutez)
</SyntaxTitle>
<SyntaxTitle syntax="pascaligo">
function ediv : nat -> nat -> option (nat * nat)
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
val ediv : int -> int -> (int * nat) option
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
val ediv : mutez -> nat -> (mutez * mutez) option
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
val ediv : mutez -> mutez -> (nat * mutez) option
</SyntaxTitle>
<SyntaxTitle syntax="cameligo">
val ediv : nat -> nat -> (nat * nat) option
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
let ediv: (int, int) => option((int, nat))
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
let ediv: (mutez, nat) => option((mutez, mutez))
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
let ediv: (mutez, mutez) => option((nat, mutez))
</SyntaxTitle>
<SyntaxTitle syntax="reasonligo">
let ediv: (nat, nat) => option((nat, nat))
</SyntaxTitle>
Compiles to Michelson `EDIV`, one operation to get both the quotient and remainder of a division. `ediv x y` returns None if `y` is zero, otherwise returns `Some (quotient, remainder)` such that `x = (quotient * y) + remainder` and `0 <= remainder < abs(y)`.

View File

@ -34,13 +34,21 @@ function buy_taco (const taco_kind_index : nat; var taco_shop_storage : taco_sho
// Update the storage with the refreshed taco_kind
taco_shop_storage[taco_kind_index] := taco_kind;
const receiver : contract (unit) = get_contract (ownerAddress);
const donationReceiver : contract (unit) = get_contract (donationAddress);
const receiver : contract (unit) =
case (Tezos.get_contract_opt (ownerAddress): option(contract (unit))) of
Some (contract) -> contract
| None -> (failwith ("Not a contract") : contract (unit))
end;
const donationReceiver : contract (unit) =
case (Tezos.get_contract_opt (donationAddress): option(contract (unit))) of
Some (contract) -> contract
| None -> (failwith ("Not a contract") : contract (unit))
end;
const donationAmount : tez = amount / 10n;
const operations : list (operation) = list [
transaction (unit, amount - donationAmount, receiver);
transaction (unit, donationAmount, donationReceiver);
Tezos.transaction (unit, amount - donationAmount, receiver);
Tezos.transaction (unit, donationAmount, donationReceiver);
]
} with (operations, taco_shop_storage)

View File

@ -4,7 +4,7 @@ title: Paying out profits from the Taco Shop
---
In the
[previous tutorial](tutorials/get-started/tezos-taco-shop-smart-contract.md)
[previous tutorial](tezos-taco-shop-smart-contract.md)
we have learnt how to setup & interact with the LIGO CLI. Followed an
implementation of a simple Taco Shop smart contract for our
entrepreneur Pedro.
@ -72,7 +72,7 @@ const current_purchase_price : tez =
### Replacing *spendable* Smart Contracts
However, due to the
[recent protocol upgrade](http://tezos.gitlab.io/mainnet/protocols/004_Pt24m4xi.html)
[recent protocol upgrade](http://tezos.gitlab.io/protocols/004_Pt24m4xi.html)
of the Tezos `mainnet`, Pedro cannot access the tokens stored in his
shop's contract directly. This was previously possible via *spendable
smart contracts*, which are no longer available in the new
@ -105,7 +105,11 @@ contract with no parameters, or an implicit account.
```pascaligo group=ex1
const ownerAddress : address = ("tz1TGu6TN5GSez2ndXXeDX6LgUDvLzPLqgYV" : address);
const receiver : contract (unit) = get_contract (ownerAddress);
const receiver : contract (unit) =
case (Tezos.get_contract_opt (ownerAddress): option(contract(unit))) of
Some (contract) -> contract
| None -> (failwith ("Not a contract") : (contract(unit)))
end;
```
> Would you like to learn more about addresses, contracts and
@ -120,7 +124,7 @@ receiver)` within a list of operations returned at the end of our
contract.
```pascaligo group=ex1
const payoutOperation : operation = transaction (unit, amount, receiver) ;
const payoutOperation : operation = Tezos.transaction (unit, amount, receiver) ;
const operations : list (operation) = list [payoutOperation];
```
@ -166,10 +170,15 @@ function buy_taco (const taco_kind_index : nat ; var taco_shop_storage : taco_sh
// Update the storage with the refreshed taco_kind
taco_shop_storage[taco_kind_index] := taco_kind;
const receiver : contract(unit) = get_contract (ownerAddress);
const payoutOperation : operation = transaction (unit, amount, receiver);
const receiver : contract (unit) =
case (Tezos.get_contract_opt (ownerAddress): option(contract(unit))) of
Some (contract) -> contract
| None -> (failwith ("Not a contract") : (contract(unit)))
end;
const payoutOperation : operation = Tezos.transaction (unit, amount, receiver);
const operations : list(operation) = list [payoutOperation]
} with ((nil : list (operation)), taco_shop_storage)
} with ((operations : list (operation)), taco_shop_storage)
```
### Dry-run the Contract
@ -214,8 +223,16 @@ sum from each taco purchase.
const ownerAddress : address = ("tz1TGu6TN5GSez2ndXXeDX6LgUDvLzPLqgYV" : address);
const donationAddress : address = ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" : address);
const receiver : contract (unit) = get_contract (ownerAddress);
const donationReceiver : contract(unit) = get_contract (donationAddress);
const receiver : contract (unit) =
case (Tezos.get_contract_opt (ownerAddress) : option(contract(unit))) of
Some (contract) -> contract
| None -> (failwith ("Not a contract") : contract (unit))
end;
const donationReceiver : contract (unit) =
case (Tezos.get_contract_opt (donationAddress) : option(contract(unit))) of
Some (contract) -> contract
| None -> (failwith ("Not a contract") : contract (unit))
end;
const donationAmount : tez = amount / 10n;

View File

@ -67,7 +67,7 @@ current_purchase_price = max_price / available_stock
In this tutorial, we will use LIGO's dockerized version, for the sake
of simplicity. You can find the installation instructions
[here](intro/installation.md#dockerized-installation-recommended).
[here](../../intro/installation.md#dockerized-installation-recommended).
The best way to install the dockerized LIGO is as a **global
executable** through the installation script, as shown in the
@ -203,7 +203,7 @@ function main (const parameter : unit; const taco_shop_storage : taco_shop_stor
When dry-running a contract, it is crucial to provide a correct
initial storage value. In our case the storage is type-checked as
`taco_shop_storage`. Reflecting
[Pedro's daily offer](tutorials/get-started/tezos-taco-shop-smart-contract.md#daily-offer),
[Pedro's daily offer](tezos-taco-shop-smart-contract.md#daily-offer),
our storage's value will be defined as follows:
**Storage value**
@ -340,7 +340,7 @@ accessible within LIGO as `amount`.
To make sure we get paid, we will:
- calculate a `current_purchase_price` based on the
[equation specified earlier](tutorials/get-started/tezos-taco-shop-smart-contract.md#calculating-the-current-purchase-price)
[equation specified earlier](tezos-taco-shop-smart-contract.md#calculating-the-current-purchase-price)
- check if the sent `amount` matches the `current_purchase_price`:
- if not, then our contract will fail (`failwith`)
- otherwise, stock for the given `taco_kind` will be decreased and

View File

@ -113,9 +113,14 @@ const siteConfig = {
// template. For example, if you need your repo's URL...
// repoUrl: repoUrl,
plugins: [
'@ligo/syntax', {
require.resolve('@ligo/syntax', {
}
},
'@docusaurus/plugin-sitemap', {
cacheTime: 600 * 1000, // 600 sec - cache purge period
changefreq: 'weekly',
priority: 0.5,
})
],
presets: [
@ -151,17 +156,18 @@ const siteConfig = {
srcDark: 'img/logo-night.svg'
},
links: [
{ href: 'https://ide.ligolang.org/', label: 'Try Online' },
{ to: 'docs/intro/installation', label: 'Install' },
{ to: 'docs/intro/introduction', label: 'Docs' },
{ href: 'https://ide.ligolang.org/', label: 'Try Online', position: 'left', target: '_self' },
{ to: 'docs/intro/installation', label: 'Install', position: 'left' },
{ to: 'docs/intro/introduction', label: 'Docs', position: 'left' },
{
to: 'docs/tutorials/get-started/tezos-taco-shop-smart-contract',
label: 'Tutorials'
label: 'Tutorials',
position: 'left'
},
{ href: 'https://forum.tezosagora.org/tag/ligo', label: 'Blog' },
{ href: 'https://forum.tezosagora.org/tag/ligo', label: 'Blog', position: 'left' },
// TODO: { href: "/odoc", label: "API" },
// { doc: 'contributors/origin', label: 'Contribute' },
{ to: '/contact', label: 'Ask Questions' }
{ to: '/contact', label: 'Ask Questions', position: 'left' }
],
},
footer: {
@ -171,28 +177,28 @@ const siteConfig = {
items: [
{ to: 'docs/intro/installation', label: 'Install' },
{ to: 'docs/api/cli-commands', label: 'CLI Commands' },
{ to: 'docs/contributors/origin', label: 'Contribute' },
{ to: '/odoc', label: 'API Documentation' }
{ to: 'docs/api/cheat-sheet', label: 'Cheat Sheet' },
{ href: 'https://ligolang.org/odoc/', label: 'API Documentation' }
]
},
{
title: 'Community',
items: [
{
href: 'https://forum.tezosagora.org/tag/ligo',
label: 'Tezos Agora Forum'
},
{
href: 'https://tezos.stackexchange.com/questions/tagged/ligo',
label: 'Tezos Stack Exchange'
},
{
href: 'https://discord.gg/9rhYaEt',
label: 'Discord'
},
{
href: 'https://t.me/LigoLang',
label: 'Telegram'
},
{
href: 'https://discord.gg/9rhYaEt',
label: 'Discord'
href: 'https://riot.im/app/#/room/#ligo-public:matrix.org',
label: 'Riot'
}
]
},
@ -203,9 +209,17 @@ const siteConfig = {
label: 'Tutorials',
to: 'docs/tutorials/get-started/tezos-taco-shop-smart-contract'
},
{
href: 'https://forum.tezosagora.org/tag/ligo',
label: 'Blog'
},
{
label: 'GitLab',
href: repoUrl
},
{
label: 'Contribute',
to: 'docs/contributors/origin'
}
]
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,6 @@
{
"name": "ligo-website",
"version": "0.0.1",
"scripts": {
"start": "docusaurus start --host 0.0.0.0 --port 3000",
"build": "docusaurus build",
@ -6,8 +8,8 @@
"deploy": "docusaurus deploy"
},
"devDependencies": {
"@docusaurus/core": "^2.0.0-alpha.43",
"@docusaurus/preset-classic": "^2.0.0-alpha.43",
"@docusaurus/core": "^2.0.0-alpha.56",
"@docusaurus/preset-classic": "^2.0.0-alpha.56",
"classnames": "^2.2.6",
"react": "^16.13.0",
"react-dom": "^16.13.0",
@ -26,6 +28,11 @@
]
},
"dependencies": {
"@ligo/syntax": "file:src/@ligo/syntax"
"@docusaurus/plugin-sitemap": "^2.0.0-alpha.56",
"@ligo/syntax": "file:src/@ligo/syntax",
"@ligolang/ligo-snippets": "^1.0.1",
"axios": "^0.19.2",
"react-codejar": "^1.0.1",
"yaml": "^1.10.0"
}
}

View File

@ -19,13 +19,16 @@
"advanced/entrypoints-contracts",
"advanced/include",
"advanced/first-contract",
"advanced/michelson-and-ligo"
"advanced/michelson-and-ligo",
"advanced/inline",
"advanced/interop"
],
"Reference": [
"api/cli-commands",
"api/cheat-sheet"
],
"API":[
"reference/toplevel",
"reference/big-map-reference",
"reference/bitwise-reference",
"reference/bytes-reference",

File diff suppressed because one or more lines are too long

View File

@ -2,15 +2,15 @@ import React from 'react';
import styles from './styles.module.css';
function SyntaxSwitch(props) {
return React.createElement("select", {
return /*#__PURE__*/React.createElement("select", {
className: styles.syntaxSwitch,
defaultValue: props.syntax,
onChange: e => props.onSyntaxChange(e.target.value)
}, React.createElement("option", {
}, /*#__PURE__*/React.createElement("option", {
value: "pascaligo"
}, "PascaLIGO"), React.createElement("option", {
}, "PascaLIGO"), /*#__PURE__*/React.createElement("option", {
value: "cameligo"
}, "CameLIGO"), React.createElement("option", {
}, "CameLIGO"), /*#__PURE__*/React.createElement("option", {
value: "reasonligo"
}, "ReasonLIGO"));
}

View File

@ -2,11 +2,11 @@ import React from 'react';
import SyntaxContext from './SyntaxContext';
function Syntax(props) {
return React.createElement(SyntaxContext.Consumer, null, syntax => {
return /*#__PURE__*/React.createElement(SyntaxContext.Consumer, null, syntax => {
if (syntax === props.syntax) {
return props.children;
} else {
return React.createElement(React.Fragment, null);
return /*#__PURE__*/React.createElement(React.Fragment, null);
}
});
}

View File

@ -32,6 +32,7 @@
.syntaxSwitch option {
color: var(--color-primary-text);
font-weight:normal;
background-color: var(--ifm-navbar-background-color);
}

View File

@ -72,9 +72,9 @@ function SyntaxTitle(props) {
useEffect(() => {
setMounted(true);
}, []);
return React.createElement(SyntaxContext.Consumer, null, syntax => {
return /*#__PURE__*/React.createElement(SyntaxContext.Consumer, null, syntax => {
if (syntax === props.syntax) {
return React.createElement(Highlight, _extends({}, defaultProps, {
return /*#__PURE__*/React.createElement(Highlight, _extends({}, defaultProps, {
key: mounted,
language: props.syntax,
code: props.children,
@ -85,7 +85,7 @@ function SyntaxTitle(props) {
tokens,
getLineProps,
getTokenProps
}) => React.createElement("pre", {
}) => /*#__PURE__*/React.createElement("pre", {
className: className,
style: {
backgroundColor: 'var(--ifm-background-color)',
@ -95,15 +95,15 @@ function SyntaxTitle(props) {
whiteSpace: 'break-spaces',
marginTop: '3rem'
}
}, tokens.map((line, i) => React.createElement("div", getLineProps({
}, tokens.map((line, i) => /*#__PURE__*/React.createElement("div", getLineProps({
line,
key: i
}), line.map((token, key) => React.createElement("span", getTokenProps({
}), line.map((token, key) => /*#__PURE__*/React.createElement("span", getTokenProps({
token,
key
})))))));
} else {
return React.createElement("div", null);
return /*#__PURE__*/React.createElement("div", null);
}
});
}

View File

@ -32,6 +32,7 @@
.syntaxSwitch option {
color: var(--color-primary-text);
font-weight:normal;
background-color: var(--ifm-navbar-background-color);
}

View File

@ -6,15 +6,22 @@ const TEAM = [
{
firstName: 'Christian',
lastName: 'Rinderknecht',
image: 'img/christian.jpeg',
image: 'img/christian.jpg',
link: 'https://github.com/rinderknecht',
pinned: true
},
{
firstName: 'Brice',
lastName: 'Aldrich',
image: 'img/brice.jpeg',
link: 'https://github.com/DefinitelyNotAGoat',
firstName: 'Eowyn',
lastName: 'Dean',
image: 'img/eowyn.jpg',
link: 'https://gitlab.com/dernhelm7',
pinned: true
},
{
firstName: 'Francis',
lastName: 'Brunelle',
image: 'img/francis.jpg',
link: 'https://github.com/frabrunelle',
pinned: true
},
{
@ -25,10 +32,10 @@ const TEAM = [
pinned: true
},
{
firstName: 'Matej',
lastName: 'Sima',
image: 'img/matej.jpeg',
link: 'https://github.com/maht0rz',
firstName: 'Pierre-Emmanuel',
lastName: 'Wolfman',
image: 'img/pierre-emmanuel.jpg',
link: 'https://gitlab.com/Popu-sama',
pinned: true
},
{
@ -41,27 +48,32 @@ const TEAM = [
{
firstName: 'Suzanne',
lastName: 'Dupéron',
image: 'img/suzanne.jpeg',
image: 'img/suzanne.jpg',
link: 'https://gitlab.com/suzanne.duperon',
pinned: true
}
];
const COMMUNICATION_CHANNELS = [
{
link: 'https://discord.gg/9rhYaEt',
icon: 'img/discord.svg',
description: "Join our Discord server. We're here to help."
},
{
link: 'https://t.me/LigoLang',
icon: 'img/telegram.svg',
description: "We're here to help. Ask us anything"
description: "We're also on Telegram. Ask us anything!"
},
{
link: 'https://gitlab.com/ligolang/ligo/issues',
icon: 'img/gitlab.svg',
description: 'Need a fix? Create an issue on GitLab'
description: 'Need a fix? Create an issue on GitLab.'
},
{
link: 'https://twitter.com/ligolang',
icon: 'img/twitter.svg',
description: 'Join the latest chit-chat'
description: 'Join the latest chit-chat and follow us on Twitter!'
}
];

View File

@ -88,7 +88,7 @@ const FEATURES = [
{
image: 'img/easy-integration.svg',
title: 'Easy Integration',
content: 'You can use LIGO as a NodeJS library with Granary'
content: 'You can use LIGO as a Node.js library with Truffle.'
}
];
@ -100,9 +100,9 @@ const PARTNERS = [
pinned: true
},
{
name: 'Tocqueville Group',
name: 'TQ Tezos',
image: 'img/tq-logo.svg',
link: 'https://tqgroup.io/',
link: 'https://tqtezos.com/',
pinned: true
},
{

View File

@ -1,14 +1,18 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/* eslint-disable jsx-a11y/no-noninteractive-tabindex */
import React, { useEffect, useState, useRef } from 'react';
import classnames from 'classnames';
import Highlight, { defaultProps } from 'prism-react-renderer';
const {Prism} = require("prism-react-renderer");
import Prism from 'prism-react-renderer/prism';
Prism.languages = {
...Prism.languages,
pascaligo: {
@ -59,7 +63,8 @@ Prism.languages = {
'punctuation': /\(\.|\.\)|[()\[\]:;,.]/
},
reasonligo:
{...Prism.languages.reason,
{
...Prism.languages.reason,
'comment': [
/(^|[^\\])\/\*[\s\S]*?\*\//,
/\(\*[\s\S]*?\*\)/,
@ -67,24 +72,97 @@ Prism.languages = {
]
},
cameligo: {...Prism.languages.ocaml,
cameligo: {
...Prism.languages.ocaml,
'comment': [
/(^|[^\\])\/\*[\s\S]*?\*\//,
/\(\*[\s\S]*?\*\)/,
/\/\/.*/
]}
]
}
};
import defaultTheme from 'prism-react-renderer/themes/palenight';
import Clipboard from 'clipboard';
import rangeParser from 'parse-numeric-range';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import useThemeContext from '@theme/hooks/useThemeContext';
import { LigoSnippet } from '@ligolang/ligo-snippets'
import styles from './styles.module.css';
const highlightLinesRangeRegex = /{([\d,-]+)}/;
const getHighlightDirectiveRegex = (
languages = ['js', 'jsBlock', 'jsx', 'python', 'html'],
) => {
// supported types of comments
const comments = {
js: {
start: '\\/\\/',
end: '',
},
jsBlock: {
start: '\\/\\*',
end: '\\*\\/',
},
jsx: {
start: '\\{\\s*\\/\\*',
end: '\\*\\/\\s*\\}',
},
python: {
start: '#',
end: '',
},
html: {
start: '<!--',
end: '-->',
},
};
// supported directives
const directives = [
'highlight-next-line',
'highlight-start',
'highlight-end',
].join('|');
// to be more reliable, the opening and closing comment must match
const commentPattern = languages
.map(
(lang) =>
`(?:${comments[lang].start}\\s*(${directives})\\s*${comments[lang].end})`,
)
.join('|');
// white space is allowed, but otherwise it should be on it's own line
return new RegExp(`^\\s*(?:${commentPattern})\\s*$`);
};
// select comment styles based on language
const highlightDirectiveRegex = (lang) => {
switch (lang) {
case 'js':
case 'javascript':
case 'ts':
case 'typescript':
return getHighlightDirectiveRegex(['js', 'jsBlock']);
case 'jsx':
case 'tsx':
return getHighlightDirectiveRegex(['js', 'jsBlock', 'jsx']);
case 'html':
return getHighlightDirectiveRegex(['js', 'jsBlock', 'html']);
case 'python':
case 'py':
return getHighlightDirectiveRegex(['python']);
default:
// all comment types
return getHighlightDirectiveRegex();
}
};
const codeBlockTitleRegex = /title=".*"/;
export default ({ children, className: languageClassName, metastring }) => {
const {
siteConfig: {
themeConfig: {prism = {}},
@ -107,6 +185,7 @@ export default ({children, className: languageClassName, metastring}) => {
const target = useRef(null);
const button = useRef(null);
let highlightLines = [];
let codeBlockTitle = '';
const {isDarkTheme} = useThemeContext();
const lightModeTheme = prism.theme || defaultTheme;
@ -115,7 +194,16 @@ export default ({children, className: languageClassName, metastring}) => {
if (metastring && highlightLinesRangeRegex.test(metastring)) {
const highlightLinesRange = metastring.match(highlightLinesRangeRegex)[1];
highlightLines = rangeParser.parse(highlightLinesRange).filter(n => n > 0);
highlightLines = rangeParser
.parse(highlightLinesRange)
.filter((n) => n > 0);
}
if (metastring && codeBlockTitleRegex.test(metastring)) {
codeBlockTitle = metastring
.match(codeBlockTitleRegex)[0]
.split('title=')[1]
.replace(/"+/g, '');
}
useEffect(() => {
@ -141,6 +229,50 @@ export default ({children, className: languageClassName, metastring}) => {
language = prism.defaultLanguage;
}
// only declaration OR directive highlight can be used for a block
let code = children.replace(/\n$/, '');
if (highlightLines.length === 0 && language !== undefined) {
let range = '';
const directiveRegex = highlightDirectiveRegex(language);
// go through line by line
const lines = children.replace(/\n$/, '').split('\n');
let blockStart;
// loop through lines
for (let index = 0; index < lines.length; ) {
const line = lines[index];
// adjust for 0-index
const lineNumber = index + 1;
const match = line.match(directiveRegex);
if (match !== null) {
const directive = match
.slice(1)
.reduce((final, item) => final || item, undefined);
switch (directive) {
case 'highlight-next-line':
range += `${lineNumber},`;
break;
case 'highlight-start':
blockStart = lineNumber;
break;
case 'highlight-end':
range += `${blockStart}-${lineNumber - 1},`;
break;
default:
break;
}
lines.splice(index, 1);
} else {
// lines without directives are unchanged
index += 1;
}
}
highlightLines = rangeParser.parse(range);
code = lines.join('\n');
}
const handleCopyCode = () => {
window.getSelection().empty();
setShowCopied(true);
@ -148,25 +280,65 @@ export default ({children, className: languageClassName, metastring}) => {
setTimeout(() => setShowCopied(false), 2000);
};
// ligo-snippets - begin
if (metastring) {
const theme = isDarkTheme ? 'dark' : 'light';
let isObject = true
let metadata
try {
metadata = JSON.parse(metastring)
} catch (e) {
isObject = false
}
if (isObject) {
const snippetData = {
"language": language,
"name": metadata.name,
"code": children,
"theme": theme,
"height": "" // Optional
}
if (metadata.editor) {
return <LigoSnippet data={snippetData} />
}
}
}
// ligo-snippets - end
return (
<Highlight
{...defaultProps}
key={mounted}
theme={prismTheme}
code={children.trim()}
code={code}
language={language}>
{({className, style, tokens, getLineProps, getTokenProps}) => (
<pre className={classnames(className, styles.codeBlock)}>
<>
{codeBlockTitle && (
<div style={style} className={styles.codeBlockTitle}>
{codeBlockTitle}
</div>
)}
<div className={styles.codeBlockContent}>
<button
ref={button}
type="button"
aria-label="Copy code to clipboard"
className={styles.copyButton}
className={classnames(styles.copyButton, {
[styles.copyButtonWithTitle]: codeBlockTitle,
})}
onClick={handleCopyCode}>
{showCopied ? 'Copied' : 'Copy'}
</button>
<code ref={target} className={styles.codeBlockLines} style={style}>
<div
tabIndex="0"
className={classnames(className, styles.codeBlock, {
[styles.codeBlockWithTitle]: codeBlockTitle,
})}>
<div ref={target} className={styles.codeBlockLines} style={style}>
{tokens.map((line, i) => {
if (line.length === 1 && line[0].content === '') {
line[0].content = '\n'; // eslint-disable-line no-param-reassign
@ -186,8 +358,10 @@ export default ({children, className: languageClassName, metastring}) => {
</div>
);
})}
</code>
</pre>
</div>
</div>
</div>
</>
)}
</Highlight>
);

View File

@ -1,44 +1,62 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
.codeBlockContent {
position: relative;
}
.codeBlockTitle {
border-top-left-radius: var(--ifm-global-radius);
border-top-right-radius: var(--ifm-global-radius);
border-bottom: 1px solid var(--ifm-color-emphasis-200);
font-family: var(--ifm-font-family-monospace);
font-weight: bold;
padding: 0.75rem var(--ifm-pre-padding);
width: 100%;
}
.codeBlock {
overflow: auto;
display: block;
padding: 0;
margin: 0;
border-radius: var(--ifm-global-radius);
}
.codeBlockWithTitle {
border-top-left-radius: 0;
border-top-right-radius: 0;
}
.copyButton {
background: rgb(1, 22, 39);
border: 1px solid rgb(214, 222, 235);
background: rgba(0, 0, 0, 0.3);
border: none;
border-radius: var(--ifm-global-radius);
color: rgb(214, 222, 235);
color: var(--ifm-color-white);
cursor: pointer;
line-height: 12px;
opacity: 0;
outline: none;
padding: 4px 8px;
padding: 0.4rem 0.5rem;
position: absolute;
right: var(--ifm-pre-padding);
top: var(--ifm-pre-padding);
right: calc(var(--ifm-pre-padding) / 2);
top: calc(var(--ifm-pre-padding) / 2);
visibility: hidden;
transition: opacity 200ms ease-in-out, visibility 200ms ease-in-out,
bottom 200ms ease-in-out;
}
.codeBlock:hover > .copyButton {
.codeBlockTitle:hover + .codeBlockContent .copyButton,
.codeBlockContent:hover > .copyButton {
visibility: visible;
opacity: 1;
}
.codeBlockLines {
background-color: transparent;
border-radius: 0;
margin-bottom: 0;
font-family: var(--ifm-font-family-monospace);
font-size: inherit;
line-height: var(--ifm-pre-line-height);
white-space: pre;
float: left;
min-width: 100%;
padding: var(--ifm-pre-padding);

View File

@ -0,0 +1,217 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import Head from '@docusaurus/Head';
import isInternalUrl from '@docusaurus/isInternalUrl';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import useBaseUrl from '@docusaurus/useBaseUrl';
import DocPaginator from '@theme/DocPaginator';
import useTOCHighlight from '@theme/hooks/useTOCHighlight';
import classnames from 'classnames';
import styles from './styles.module.css';
const LINK_CLASS_NAME = 'table-of-contents__link';
const ACTIVE_LINK_CLASS_NAME = 'table-of-contents__link--active';
const TOP_OFFSET = 100;
function DocTOC({headings}) {
useTOCHighlight(LINK_CLASS_NAME, ACTIVE_LINK_CLASS_NAME, TOP_OFFSET);
return (
<div className="col col--3">
<div className={styles.tableOfContents}>
<Headings headings={headings} />
</div>
</div>
);
}
/* eslint-disable jsx-a11y/control-has-associated-label */
function Headings({headings, isChild}) {
if (!headings.length) {
return null;
}
return (
<ul
className={
isChild ? '' : 'table-of-contents table-of-contents__left-border'
}>
{headings.map((heading) => (
<li key={heading.id}>
<a
href={`#${heading.id}`}
className={LINK_CLASS_NAME}
dangerouslySetInnerHTML={{__html: heading.value}}
/>
<Headings isChild headings={heading.children} />
</li>
))}
</ul>
);
}
function DocItem(props) {
const {siteConfig = {}} = useDocusaurusContext();
const {url: siteUrl, title: siteTitle} = siteConfig;
const {content: DocContent} = props;
const {metadata} = DocContent;
const {
description,
title,
permalink,
editUrl,
lastUpdatedAt,
lastUpdatedBy,
version,
} = metadata;
const {
frontMatter: {
image: metaImage,
keywords,
hide_title: hideTitle,
hide_table_of_contents: hideTableOfContents,
},
} = DocContent;
const metaTitle = title ? `${title} | ${siteTitle}` : siteTitle;
let metaImageUrl = siteUrl + useBaseUrl(metaImage);
if (!isInternalUrl(metaImage)) {
metaImageUrl = metaImage;
}
return (
<>
<Head>
<title>{metaTitle}</title>
<meta property="og:title" content={metaTitle} />
{description && <meta name="description" content={description} />}
{description && (
<meta property="og:description" content={description} />
)}
{keywords && keywords.length && (
<meta name="keywords" content={keywords.join(',')} />
)}
{metaImage && <meta property="og:image" content={metaImageUrl} />}
{metaImage && <meta property="twitter:image" content={metaImageUrl} />}
{metaImage && (
<meta name="twitter:image:alt" content={`Image for ${title}`} />
)}
{permalink && <meta property="og:url" content={siteUrl + permalink} />}
{permalink && <link rel="canonical" href={siteUrl + permalink} />}
</Head>
<div
className={classnames(
'container padding-vert--lg',
styles.docItemWrapper,
)}>
<div className="row">
<div
className={classnames('col', {
[styles.docItemCol]: !hideTableOfContents,
})}>
<div className={styles.docItemContainer}>
<article>
{version && (
<div>
<span className="badge badge--secondary">
Version: {version}
</span>
</div>
)}
{!hideTitle && (
<header>
<h1 className={styles.docTitle}>{title}</h1>
</header>
)}
<div className="markdown">
<DocContent />
</div>
</article>
{(editUrl || lastUpdatedAt || lastUpdatedBy) && (
<div className="margin-vert--xl">
<div className="row">
<div className="col">
{editUrl && (
<a
href={editUrl}
target="_blank"
rel="noreferrer noopener">
<svg
fill="currentColor"
height="1.2em"
width="1.2em"
preserveAspectRatio="xMidYMid meet"
viewBox="0 0 40 40"
style={{
marginRight: '0.3em',
verticalAlign: 'sub',
}}>
<g>
<path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z" />
</g>
</svg>
Edit this page
</a>
)}
</div>
{(lastUpdatedAt || lastUpdatedBy) && (
<div className="col text--right">
<em>
<small>
Last updated{' '}
{lastUpdatedAt && (
<>
on{' '}
<time
dateTime={new Date(
lastUpdatedAt * 1000,
).toISOString()}
className={styles.docLastUpdatedAt}>
{new Date(
lastUpdatedAt * 1000,
).toLocaleDateString()}
</time>
{lastUpdatedBy && ' '}
</>
)}
{lastUpdatedBy && (
<>
by <strong>{lastUpdatedBy}</strong>
</>
)}
{process.env.NODE_ENV === 'development' && (
<div>
<small>
{' '}
(Simulated during dev for better perf)
</small>
</div>
)}
</small>
</em>
</div>
)}
</div>
</div>
)}
<div className="margin-vert--lg">
<DocPaginator metadata={metadata} />
</div>
</div>
</div>
{!hideTableOfContents && DocContent.rightToc && (
<DocTOC headings={DocContent.rightToc} />
)}
</div>
</div>
</>
);
}
export default DocItem;

View File

@ -0,0 +1,70 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
.docTitle {
font-size: 3rem;
margin-bottom: calc(var(--ifm-leading-desktop) * var(--ifm-leading));
}
.docItemContainer {
margin: 0 auto;
padding: 0 0.5rem;
}
@media only screen and (min-width: 997px) {
.docItemCol {
max-width: 75% !important;
}
}
@media (min-width: 997px) and (max-width: 1320px) {
.docItemWrapper {
max-width: calc(
var(--ifm-container-width) - 300px - var(--ifm-spacing-horizontal) * 2
);
}
}
.tableOfContents {
display: inherit;
max-height: calc(100vh - (var(--ifm-navbar-height) + 2rem));
overflow-y: auto;
position: sticky;
top: calc(var(--ifm-navbar-height) + 2rem);
}
.tableOfContents::-webkit-scrollbar {
width: 7px;
}
.tableOfContents::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 10px;
}
.tableOfContents::-webkit-scrollbar-thumb {
background: #888;
border-radius: 10px;
}
.tableOfContents::-webkit-scrollbar-thumb:hover {
background: #555;
}
@media only screen and (max-width: 996px) {
.tableOfContents {
display: none;
}
.docItemContainer {
padding: 0 0.3rem;
}
}
.docLastUpdatedAt {
font-weight: bold;
}

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
@ -11,6 +11,7 @@ import {MDXProvider} from '@mdx-js/react';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import renderRoutes from '@docusaurus/renderRoutes';
import Layout from '@theme/Layout';
import DocItem from '@theme/DocItem';
import DocSidebar from '@theme/DocSidebar';
import MDXComponents from '@theme/MDXComponents';
import NotFound from '@theme/NotFound';
@ -21,20 +22,29 @@ import styles from './styles.module.css';
import SyntaxContext from '@theme/Syntax/SyntaxContext';
function DocPage(props) {
const {route: baseRoute, docsMetadata, location} = props;
// case-sensitive route such as it is defined in the sidebar
const currentRoute =
baseRoute.routes.find(route => {
return matchPath(location.pathname, route);
}) || {};
const {permalinkToSidebar, docsSidebars, version} = docsMetadata;
const sidebar = permalinkToSidebar[currentRoute.path];
const {route: baseRoute, docsMetadata, location, content} = props;
const {
siteConfig: {themeConfig = {}} = {},
permalinkToSidebar,
docsSidebars,
version,
isHomePage,
homePagePath,
} = docsMetadata;
// Get case-sensitive route such as it is defined in the sidebar.
const currentRoute = !isHomePage
? baseRoute.routes.find((route) => {
return matchPath(location.pathname, route);
}) || {}
: {};
const sidebar = isHomePage
? content.metadata.sidebar
: permalinkToSidebar[currentRoute.path];
const {
siteConfig: {themeConfig: {sidebarCollapsible = true} = {}} = {},
isClient,
} = useDocusaurusContext();
const {sidebarCollapsible = true} = themeConfig;
let defaultSyntax = 'pascaligo';
if (isClient) {
@ -43,7 +53,7 @@ function DocPage(props) {
const [syntax, setSyntax] = useState(defaultSyntax);
if (Object.keys(currentRoute).length === 0) {
if (!isHomePage && Object.keys(currentRoute).length === 0) {
return <NotFound {...props} />;
}
@ -55,7 +65,7 @@ function DocPage(props) {
<div className={styles.docSidebarContainer}>
<DocSidebar
docsSidebars={docsSidebars}
path={currentRoute.path}
path={isHomePage ? homePagePath : currentRoute.path}
sidebar={sidebar}
sidebarCollapsible={sidebarCollapsible}
syntax={syntax}
@ -68,7 +78,11 @@ function DocPage(props) {
)}
<main className={styles.docMainContainer}>
<MDXProvider components={MDXComponents}>
{renderRoutes(baseRoute.routes)}
{isHomePage ? (
<DocItem content={content} />
) : (
renderRoutes(baseRoute.routes)
)}
</MDXProvider>
</main>
</div>

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
@ -10,11 +10,11 @@
}
.docSidebarContainer {
border-right: 1px solid var(--ifm-contents-border-color);
border-right: 1px solid var(--ifm-toc-border-color);
box-sizing: border-box;
width: 300px;
position: relative;
top: calc(-1 * var(--ifm-navbar-height));
margin-top: calc(-1 * var(--ifm-navbar-height));
}
.docMainContainer {

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
@ -8,19 +8,24 @@
import React, {useState, useCallback} from 'react';
import classnames from 'classnames';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import useBaseUrl from '@docusaurus/useBaseUrl';
import useLockBodyScroll from '@theme/hooks/useLockBodyScroll';
import useLogo from '@theme/hooks/useLogo';
import Link from '@docusaurus/Link';
import isInternalUrl from '@docusaurus/utils'; // eslint-disable-line import/no-extraneous-dependencies
import isInternalUrl from '@docusaurus/isInternalUrl';
import styles from './styles.module.css';
import SyntaxSwitch from '@theme/Syntax/SyntaxSwitch';
const MOBILE_TOGGLE_SIZE = 24;
function DocSidebarItem({item, onItemClick, collapsible}) {
function DocSidebarItem({
item,
onItemClick,
collapsible,
activePath,
...props
}) {
const {items, href, label, type} = item;
const [collapsed, setCollapsed] = useState(item.collapsed);
const [prevCollapsedProp, setPreviousCollapsedProp] = useState(null);
@ -33,9 +38,10 @@ function DocSidebarItem({item, onItemClick, collapsible}) {
setCollapsed(item.collapsed);
}
const handleItemClick = useCallback(e => {
const handleItemClick = useCallback((e) => {
e.preventDefault();
setCollapsed(state => !state);
e.target.blur();
setCollapsed((state) => !state);
});
switch (type) {
@ -53,16 +59,19 @@ function DocSidebarItem({item, onItemClick, collapsible}) {
'menu__link--active': collapsible && !item.collapsed,
})}
href="#!"
onClick={collapsible ? handleItemClick : undefined}>
onClick={collapsible ? handleItemClick : undefined}
{...props}>
{label}
</a>
<ul className="menu__list">
{items.map(childItem => (
{items.map((childItem) => (
<DocSidebarItem
tabIndex={collapsed ? '-1' : '0'}
key={childItem.label}
item={childItem}
onItemClick={onItemClick}
collapsible={collapsible}
activePath={activePath}
/>
))}
</ul>
@ -75,18 +84,21 @@ function DocSidebarItem({item, onItemClick, collapsible}) {
return (
<li className="menu__list-item" key={label}>
<Link
className="menu__link"
className={classnames('menu__link', {
'menu__link--active': href === activePath,
})}
to={href}
{...(isInternalUrl(href)
? {
activeClassName: 'menu__link--active',
isNavLink: true,
exact: true,
onClick: onItemClick,
}
: {
target: '_blank',
rel: 'noreferrer noopener',
})}>
})}
{...props}>
{label}
</Link>
</li>
@ -102,8 +114,8 @@ function mutateSidebarCollapsingState(item, path) {
case 'category': {
const anyChildItemsActive =
items
.map(childItem => mutateSidebarCollapsingState(childItem, path))
.filter(val => val).length > 0;
.map((childItem) => mutateSidebarCollapsingState(childItem, path))
.filter((val) => val).length > 0;
// eslint-disable-next-line no-param-reassign
item.collapsed = !anyChildItemsActive;
return anyChildItemsActive;
@ -118,9 +130,12 @@ function mutateSidebarCollapsingState(item, path) {
function DocSidebar(props) {
const [showResponsiveSidebar, setShowResponsiveSidebar] = useState(false);
const {
siteConfig: {themeConfig: {navbar: {title, logo = {}} = {}}} = {}, isClient
siteConfig: {
themeConfig: {navbar: {title, hideOnScroll = false} = {}},
} = {},
isClient,
} = useDocusaurusContext();
const logoUrl = useBaseUrl(logo.src);
const {logoLink, logoLinkProps, logoImageUrl, logoAlt} = useLogo();
const {
docsSidebars,
@ -144,17 +159,25 @@ function DocSidebar(props) {
}
if (sidebarCollapsible) {
sidebarData.forEach(sidebarItem =>
sidebarData.forEach((sidebarItem) =>
mutateSidebarCollapsingState(sidebarItem, path),
);
}
return (
<div className={styles.sidebar}>
<div className={styles.sidebarLogo}>
{logo != null && <img src={logoUrl} alt={logo.alt} />}
{hideOnScroll && (
<Link
tabIndex="-1"
className={styles.sidebarLogo}
to={logoLink}
{...logoLinkProps}>
{logoImageUrl != null && (
<img key={isClient} src={logoImageUrl} alt={logoAlt} />
)}
{title != null && <strong>{title}</strong>}
</div>
</Link>
)}
{isClient && document.location.pathname.startsWith('/docs') && !showResponsiveSidebar ?
<div className={styles.switchContainer}>
Display syntax: <SyntaxSwitch syntax={props.syntax} onSyntaxChange={s => props.onSyntaxChange(s)} />
@ -168,14 +191,14 @@ function DocSidebar(props) {
})}>
{isClient && document.location.pathname.startsWith('/docs') && showResponsiveSidebar ?
<div className={styles.switchContainerResponsive}>
Display syntax:
<SyntaxSwitch syntax={props.syntax} onSyntaxChange={s => props.onSyntaxChange(s)} />
Display syntax: <SyntaxSwitch syntax={props.syntax} onSyntaxChange={s => props.onSyntaxChange(s)} />
</div>
:
null
}
<button
aria-label={showResponsiveSidebar ? 'Close Menu' : 'Open Menu'}
aria-haspopup="true"
className="button button--secondary button--sm menu__button"
type="button"
onClick={() => {
@ -191,6 +214,7 @@ function DocSidebar(props) {
</span>
) : (
<svg
aria-label="Menu"
className={styles.sidebarMenuIcon}
xmlns="http://www.w3.org/2000/svg"
height={MOBILE_TOGGLE_SIZE}
@ -210,14 +234,16 @@ function DocSidebar(props) {
)}
</button>
<ul className="menu__list">
{sidebarData.map(item => (
{sidebarData.map((item) => (
<DocSidebarItem
key={item.label}
item={item}
onItemClick={() => {
onItemClick={(e) => {
e.target.blur();
setShowResponsiveSidebar(false);
}}
collapsible={sidebarCollapsible}
activePath={path}
/>
))}
</ul>

View File

@ -1,5 +1,5 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
@ -39,6 +39,8 @@
top: 0;
margin: 0 var(--ifm-navbar-padding-horizontal);
height: var(--ifm-navbar-height);
color: inherit !important;
text-decoration: none !important;
}
.sidebarLogo img {

View File

@ -1,201 +0,0 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, {useCallback, useState} from 'react';
import Link from '@docusaurus/Link';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import useBaseUrl from '@docusaurus/useBaseUrl';
import SearchBar from '@theme/SearchBar';
import Toggle from '@theme/Toggle';
import classnames from 'classnames';
import useThemeContext from '@theme/hooks/useThemeContext';
import useHideableNavbar from '@theme/hooks/useHideableNavbar';
import useLockBodyScroll from '@theme/hooks/useLockBodyScroll';
import styles from './styles.module.css';
function NavLink({to, href, label, position, ...props}) {
const toUrl = useBaseUrl(to);
return (
<Link
className="navbar__item navbar__link"
{...(href
? {
target: '_blank',
rel: 'noopener noreferrer',
href,
}
: {
activeClassName: 'navbar__link--active',
to: toUrl,
})}
{...props}>
{label}
</Link>
);
}
function Navbar(props) {
const context = useDocusaurusContext();
const {siteConfig = {}} = context;
const {baseUrl, themeConfig = {}} = siteConfig;
const {navbar = {}, disableDarkMode = false} = themeConfig;
const {title, logo = {}, links = [], hideOnScroll = false} = navbar;
const [sidebarShown, setSidebarShown] = useState(false);
const [isSearchBarExpanded, setIsSearchBarExpanded] = useState(false);
const {isDarkTheme, setLightTheme, setDarkTheme} = useThemeContext();
const {navbarRef, isNavbarVisible} = useHideableNavbar(hideOnScroll);
useLockBodyScroll(sidebarShown);
const showSidebar = useCallback(() => {
setSidebarShown(true);
}, [setSidebarShown]);
const hideSidebar = useCallback(() => {
setSidebarShown(false);
}, [setSidebarShown]);
const onToggleChange = useCallback(
e => (e.target.checked ? setDarkTheme() : setLightTheme()),
[setLightTheme, setDarkTheme],
);
const logoLink = logo.href || baseUrl;
const isExternalLogoLink = /http/.test(logoLink);
const logoLinkProps = isExternalLogoLink
? {
rel: 'noopener noreferrer',
target: '_blank',
}
: null;
const logoSrc = logo.srcDark && isDarkTheme ? logo.srcDark : logo.src;
const logoImageUrl = useBaseUrl(logoSrc);
return (
<nav
ref={navbarRef}
className={classnames('navbar', 'navbar--light', 'navbar--fixed-top', {
'navbar-sidebar--show': sidebarShown,
[styles.navbarHideable]: hideOnScroll,
[styles.navbarHidden]: !isNavbarVisible,
})}>
<div className="navbar__inner">
<div className="navbar__items">
<div
aria-label="Navigation bar toggle"
className="navbar__toggle"
role="button"
tabIndex={0}
onClick={showSidebar}
onKeyDown={showSidebar}>
<svg
xmlns="http://www.w3.org/2000/svg"
width="30"
height="30"
viewBox="0 0 30 30"
role="img"
focusable="false">
<title>Menu</title>
<path
stroke="currentColor"
strokeLinecap="round"
strokeMiterlimit="10"
strokeWidth="2"
d="M4 7h22M4 15h22M4 23h22"
/>
</svg>
</div>
<Link className="navbar__brand" to={logoLink} {...logoLinkProps}>
{logo != null && (
<img className="navbar__logo" src={logoImageUrl} alt={logo.alt} />
)}
{title != null && (
<strong
className={isSearchBarExpanded ? styles.hideLogoText : ''}>
{title}
</strong>
)}
</Link>
{links
.filter(linkItem => linkItem.position !== 'right')
.map((linkItem, i) => (
<NavLink {...linkItem} key={i} />
))}
</div>
<div className="navbar__items navbar__items--right">
{links
.filter(linkItem => linkItem.position === 'right')
.map((linkItem, i) => (
<NavLink {...linkItem} key={i} />
))}
{!disableDarkMode && (
<Toggle
className={styles.displayOnlyInLargeViewport}
aria-label="Dark mode toggle"
checked={isDarkTheme}
onChange={onToggleChange}
/>
)}
<SearchBar
handleSearchBarToggle={setIsSearchBarExpanded}
isSearchBarExpanded={isSearchBarExpanded}
/>
</div>
</div>
<div
role="presentation"
className="navbar-sidebar__backdrop"
onClick={hideSidebar}
/>
<div className="navbar-sidebar">
<div className="navbar-sidebar__brand">
<Link
className="navbar__brand"
onClick={hideSidebar}
to={logoLink}
{...logoLinkProps}>
{logo != null && (
<img className="navbar__logo" src={logoImageUrl} alt={logo.alt} />
)}
{title != null && <strong>{title}</strong>}
</Link>
{!disableDarkMode && sidebarShown && (
<Toggle
aria-label="Dark mode toggle in sidebar"
checked={isDarkTheme}
onChange={onToggleChange}
/>
)}
</div>
<div className="navbar-sidebar__items">
<div className="menu">
<ul className="menu__list">
{links.map((linkItem, i) => (
<li className="menu__list-item" key={i}>
<NavLink
className="menu__link"
{...linkItem}
onClick={hideSidebar}
/>
</li>
))}
</ul>
</div>
</div>
</div>
</nav>
);
}
export default Navbar;

View File

@ -1,26 +0,0 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
@media screen and (max-width: 997px) {
.displayOnlyInLargeViewport {
display: none !important;
}
}
@media (max-width: 360px) {
.hideLogoText {
display: none;
}
}
.navbarHideable {
transition: top 0.2s ease-in-out;
}
.navbarHidden {
top: calc(var(--ifm-navbar-height) * -1) !important;
}

View File

@ -50,6 +50,7 @@
html[data-theme='dark'] {
--color-primary-text: white;
--blockquote-color: var(--ifm-navbar-background-color);
--light-blue: var(--ifm-navbar-background-color);
}
html {
@ -241,6 +242,10 @@ p {
border-top: none;
}
.tabs .tabs__item {
outline: 0;
}
.tabs .nav-tabs > div {
font-size: 1em;
font-weight: normal;
@ -506,7 +511,6 @@ a:hover {
#contactPage,
#pageNotFoundPage {
font-weight: lighter;
margin-top: 80px;
margin-bottom: 80px;
}
@ -691,7 +695,7 @@ a:hover {
flex-direction: column;
justify-content: center;
align-items: center;
font-size: 1.25em;
font-size: 0.85em;
font-weight: normal;
color: white;
}
@ -734,6 +738,8 @@ a:hover {
cursor: pointer;
background-color: var(--lighter-blue);
border-left: 6px solid var(--blue);
color: black;
text-decoration: none;
}
#contactPage #message .communicationOptions .option .icon {
@ -989,21 +995,79 @@ a:hover {
}
}
/* ReasonLIGO specific syntax highlighting */
.language-reasonligo .hljs-operator {
color: #a626a4;
}
.language-reasonligo .hljs-character {
color: #50a14f;
}
.language-reasonligo .hljs-module-identifier {
color: #00f;
}
.language-reasonligo .hljs-constructor {
color: #a31515;
}
.badge {
display: none;
}
.codeTable {
display: grid;
grid-template-columns: 30% 70%;
align-items: center;
}
.codeTable > .primitive {
width: 100%;
height: 100%;
display: flex;
justify-content: right;
text-align: right;
align-items: center;
font-weight: bold;
padding-right: 1rem;
}
.codeTable > div:nth-child(4n+1) {
background-color: var(--ifm-table-stripe-background);
}
.codeTable > div:nth-child(4n+2) {
background-color: var(--ifm-table-stripe-background);
}
.codeTable > .example {
padding-top: var(--ifm-leading);
}
.codeTable > .example pre,
.codeTable > .example .codeBlockLines_src-theme-CodeBlock- {
background-color: transparent;
}
.boolean-example-table {
display: grid;
grid-template-columns: 10% 30% 60%;
width: 100%;
}
.boolean-example-table .operation{
font-weight: bold;
display: flex;
align-items: center;
justify-content: center;
}
.boolean-example-table .description {
display: flex;
align-items: center;
}
.boolean-example-table > div:nth-child(6n+1),
.boolean-example-table > div:nth-child(6n+2),
.boolean-example-table > div:nth-child(6n+3) {
background-color: var(--ifm-table-stripe-background);
}
.boolean-example-table > .example pre,
.boolean-example-table > .example .codeBlockLines_src-theme-CodeBlock- {
background-color: transparent;
}
.compactLigoIde {
height: 400px;
}
.compactLigoIde pre {
border-radius: 0px;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -1,6 +1,6 @@
name: "ligo"
opam-version: "2.0"
maintainer: "ligolang@gmail.com"
maintainer: "Galfour <contact@ligolang.org>"
authors: [ "Galfour" ]
homepage: "https://gitlab.com/ligolang/tezos"
bug-reports: "https://gitlab.com/ligolang/tezos/issues"
@ -23,6 +23,8 @@ depends: [
"getopt"
"terminal_size"
"pprint"
"UnionFind"
"RedBlackTrees"
# work around upstream in-place update
"ocaml-migrate-parsetree" { = "1.4.0" }
]

30
nix/README.md Normal file
View File

@ -0,0 +1,30 @@
# Nix expressions for building LIGO
Nix is a declarative package manager. Get it here: https://nixos.org/nix
These expressions are used on CI to reproducibly build the LIGO compiler, as well as WebIDE and https://ligolang.org .
If you wish to build it yourself, do `nix build -f. $thing`, where `$thing` is
- `ligo`: executables, libraries, documentation, coverage reports
- `ligo-bin`: a dynamically linked binary (Linux, Mac)
- `ligo-static`: a statically linked binary (Linux only)
- `ligo-doc`: documentation generated by odoc
- `ligo-editor`: WebIDE, it can be started with `result/bin/ligo-editor`
- `ligo-website`: the website, website root is `result`
- `ligo-docker`: a docker image with LIGO binaries
- `ligo-editor-docker`: a docker image with webide
- `ligo-deb`: debian package with static binaries
The output of `nix build` can be found in `result` directory.
## Quick maintenance guide
- `opam-repository` and `tezos-opam-repository` are pinned. To update them when required, run `niv update` (you can get niv with `nix shell 'nixpkgs#niv'`)
- `ocaml` version is pinned in `ocaml-overlay.nix`. If you want to update it, go there and change the version.
- If something fails, `nix repl pkgs.nix` can be very useful to investigate it.
## Known caveats
- This is not a [nix flake](https://gist.github.com/edolstra/40da6e3a4d4ee8fd019395365e0772e7). This will never be a flake if we want to keep this low-maintenance, because of the way `opam` sources are defined. Sometimes, the checksum is omitted there, so we have to use `fetchTarball` without the checksum, which won't work in restricted mode (which is required for flakes). The only solution would be to generate nix expressions for opam-repository separately, but it means a manual step in the process (and it's also impossible to make this work as a flake).
- For the same reason as above, evaluation can take a while because we need to download all the sources every `tarball-ttl` seconds. This can be mitigated by setting `tarball-ttl` to a high value.

9
nix/default.nix Normal file
View File

@ -0,0 +1,9 @@
{ sources ? import ./sources.nix }@args:
let pkgs = import ./pkgs.nix args;
in {
inherit (pkgs)
ligo ligo-tests ligo-doc ligo-coverage
ligo-bin ligo-static ligo-docker ligo-deb
ligo-editor ligo-editor-docker
ligo-website;
}

8
nix/docker.nix Normal file
View File

@ -0,0 +1,8 @@
{ dockerTools, writeShellScriptBin, runCommand, mcpp, bash, coreutils, ligo
, name ? "ligo", extraContents ? [ ] }:
dockerTools.buildLayeredImage {
inherit name;
tag = "latest";
contents = [ ligo bash ] ++ extraContents;
config.Entrypoint = name;
}

77
nix/ligo-editor.nix Normal file
View File

@ -0,0 +1,77 @@
{ stdenv, lib, mkYarnPackage, nodejs, python2, ligo-bin, coreutils
, writeShellScriptBin, makeFontsConf, buildEnv, rsync, sources
, chromium ? null }:
let
# Use a common yarn.lock for everything
yarnLock = ../tools/webide/yarn.lock;
installPhase = "mkdir $out; cp -Lr node_modules $out/node_modules";
# node_modules of the server
server = mkYarnPackage {
name = "webide-server";
src = ../tools/webide/packages/server;
buildPhase = ''
cp ${../tools/webide/tsconfig.json} tsconfig.json
yarn --offline run build
rm node_modules/server/server
'';
doCheck = true;
checkPhase = "DATA_DIR=/tmp LIGO_CMD=${ligo-bin}/bin/ligo yarn --offline jest";
distPhase = "true";
inherit yarnLock installPhase;
};
# node_modules of the client
client = mkYarnPackage rec {
name = "webide-client";
src = ../tools/webide/packages/client;
buildPhase = ''
export EXAMPLES_DIR=${../src/test/examples}
yarn --offline run build
rm node_modules/client/client
find deps/client/build -type f -exec sed -r "s,/nix/store/[a-z0-9]{32}-[^/]*,$out,g" -i '{}' \;
'';
distPhase = "true";
installPhase = "mkdir $out; cp -Lr deps/client/build $out";
inherit yarnLock;
# Downloads node-sass from the official github repo
# Uncomment the commented lines if you wish to build it from source
yarnPreBuild = "export SASS_BINARY_PATH=${sources.node-sass-bin}";
/* ''
mkdir -p "$HOME/.node-gyp/${nodejs.version}"
echo 9 > "$HOME/.node-gyp/${nodejs.version}/installVersion"
ln -sfv "${nodejs}/include" "$HOME/.node-gyp/${nodejs.version}"
'';
*/
};
# Perform the e2e tests; output is empty on purpose
e2e = mkYarnPackage rec {
name = "webide-e2e";
src = ../tools/webide/packages/e2e;
# Provide puppeteer with chromium, since it can't download it inside the nix sandbox.
# Also, since we override nodejs in our overlays, import chromium from pure nixpkgs to avoid a rebuild
buildPhase = ''
export HOME="$(pwd)"
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
export PUPPETEER_EXECUTABLE_PATH=${(import (import ./sources.nix).nixpkgs {}).chromium.outPath}/bin/chromium
${ligo-editor}/bin/ligo-editor &
export API_HOST=http://localhost:8080
export FONTCONFIG_FILE=${makeFontsConf { fontDirectories = [ ]; }}
yarn --offline jest
'';
distPhase = "true";
installPhase = "touch $out";
inherit yarnLock;
};
# Run the WebIDE server with all the needed env variables
ligo-editor = writeShellScriptBin "ligo-editor" ''
set -e
LIGO_CMD=${ligo-bin}/bin/ligo \
STATIC_ASSETS=${client} \
DATA_DIR=/tmp \
${nodejs}/bin/node ${server}/node_modules/server/dist/src/index.js
'';
in ligo-editor // { inherit e2e; }

18
nix/ligo-website.nix Normal file
View File

@ -0,0 +1,18 @@
{ buildNpmPackage, writeShellScriptBin, yarn, linkFarm, nodejs-slim, python2
, ligo-doc, ligo-deb, ligo-static }:
buildNpmPackage {
src = ../gitlab-pages/website;
npmBuild = "npm run build";
preBuild = ''
cp -r ${../gitlab-pages/docs} $NIX_BUILD_TOP/docs
chmod 700 -R $NIX_BUILD_TOP/docs
'';
installPhase = ''
cp -Lr build $out
cp -r ${ligo-deb}/*.deb $out/deb/ligo.deb
mkdir -p $out/bin/linux
cp -r ${ligo-static}/bin/ligo $out/bin/linux/ligo
cp -r ${ligo-doc}/share/doc $out/odoc
'';
extraEnvVars.nativeBuildInputs = [ python2 ];
}

9
nix/mac-overlay.nix Normal file
View File

@ -0,0 +1,9 @@
oself: osuper:
let
fixHardeningWarning = pkg: pkg.overrideAttrs (_: {
hardeningDisable = [ "strictoverflow" ];
});
in
{
hacl = fixHardeningWarning osuper.hacl;
}

6
nix/nodejs-overlay.nix Normal file
View File

@ -0,0 +1,6 @@
self: super: {
# Note: this overlay doesn't apply to nix-npm-buildpackage
nodejs = super.nodejs-12_x;
nodePackages = super.nodePackages_12_x;
nodejs-slim = super.nodejs-slim-12_x;
}

152
nix/ocaml-overlay.nix Normal file
View File

@ -0,0 +1,152 @@
# An overlay that adds ligo to ocamlPackages
{ sources ? import ./sources.nix
, CI_COMMIT_SHA ? builtins.getEnv "CI_COMMIT_SHA"
, COMMIT_DATE ? builtins.getEnv "COMMIT_DATE" }:
self: super:
let
opam-nix = import sources.opam-nix (import sources.nixpkgs { });
inherit (import sources."gitignore.nix" { inherit (self) lib; })
gitignoreSource;
# Remove list of directories or files from source (to stop unneeded rebuilds)
# Also, apply the gitignore here.
filterOut = xs:
gitignoreSource (self.lib.cleanSourceWith {
filter = p: type: !(builtins.elem (builtins.baseNameOf p) xs);
src = gitignoreSource ../.;
});
in {
ocamlPackages = self.ocaml-ng.ocamlPackages_4_07.overrideScope'
(builtins.foldl' self.lib.composeExtensions (_: _: { }) [
# Both opam-repository and tezos-opam-repository are updated manually with `niv update`
(opam-nix.traverseOPAMRepo' sources.opam-repository)
(opam-nix.traverseOPAMRepo sources.tezos-opam-repository)
(opam-nix.callOPAMPackage (filterOut [
".git"
".gitlab-ci.yml"
".gitignore"
"nix"
"docker"
"tools"
"gitlab-pages"
]))
(oself: osuper: {
# Strange naming in nixpkgs
ocamlfind = oself.findlib;
lablgtk = null;
lwt = oself.lwt4;
# Native dependencies
conf-gmp = self.gmp;
conf-libev = self.libev;
conf-hidapi = self.hidapi;
conf-pkg-config = self.pkg-config;
# Strange problems
bigstring = osuper.bigstring.overrideAttrs (_: { doCheck = false; });
xmldiff = osuper.xmldiff.overrideAttrs (_: { src = sources.xmldiff; });
getopt = osuper.getopt.overrideAttrs (_: { configurePhase = "true"; });
# Force certain versions
ipaddr = osuper.ipaddr.versions."4.0.0";
conduit = osuper.conduit.versions."2.1.0";
conduit-lwt-unix = osuper.conduit-lwt-unix.versions."2.0.2";
cohttp-lwt-unix = osuper.cohttp-lwt-unix.versions."2.4.0";
cohttp-lwt = osuper.cohttp-lwt.versions."2.4.0";
macaddr = osuper.macaddr.versions."4.0.0";
ocaml-migrate-parsetree =
osuper.ocaml-migrate-parsetree.versions."1.4.0";
ppx_tools_versioned = osuper.ppx_tools_versioned.versions."5.2.3";
bisect_ppx = osuper.bisect_ppx.versions."2.0.0".overrideAttrs (_: {
src = builtins.fetchTarball
"https://github.com/aantron/bisect_ppx/archive/02dfb10188033a26d07d23480c2bc44a3a670357.tar.gz";
});
proto-alpha-utils = osuper.proto-alpha-utils.overrideAttrs (oa: rec {
buildInputs = oa.buildInputs
++ [ oself.tezos-protocol-006-PsCARTHA-parameters ];
propagatedBuildInputs = buildInputs;
});
tezos-protocol-compiler = osuper.tezos-protocol-compiler.overrideAttrs
(oa: rec {
buildInputs = oa.buildInputs ++ [ oself.pprint ];
propagatedBuildInputs = buildInputs;
});
# A combination of executables, libraries, documentation and test coverage
ligo = self.buildEnv {
name = "ligo";
paths = with oself; [
ligo-out.out
ligo-tests
ligo-doc
ligo-coverage
];
};
# LIGO executable and public libraries
ligo-out = osuper.ligo.overrideAttrs (oa: {
name = "ligo-out";
inherit CI_COMMIT_SHA COMMIT_DATE;
buildInputs = oa.buildInputs
++ [ oself.UnionFind oself.Preprocessor ];
nativeBuildInputs = oa.nativeBuildInputs
++ [ self.buildPackages.rakudo ];
});
# LIGO test suite; output empty on purpose
ligo-tests = osuper.ligo.overrideAttrs (oa: {
name = "ligo-tests";
src = filterOut [
".git"
".gitlab-ci.yml"
".gitignore"
"nix"
"docker"
"tools"
];
outputs = [ "out" ];
buildPhase = "dune runtest";
nativeBuildInputs = oa.nativeBuildInputs
++ [ self.buildPackages.rakudo ];
installPhase = "mkdir $out";
});
# LIGO odoc documentation
ligo-doc = osuper.ligo.overrideAttrs (oa: {
name = "ligo-doc";
buildInputs = oa.buildInputs
++ [ oself.odoc oself.tezos-protocol-updater ];
outputs = [ "out" ];
buildPhase = "dune build @doc";
nativeBuildInputs = oa.nativeBuildInputs
++ [ self.buildPackages.rakudo ];
installPhase =
"mkdir $out; cp -r _build/default/_doc/_html/ $out/doc";
});
# LIGO test coverage reports
ligo-coverage = oself.ligo-tests.overrideAttrs (oa: {
name = "ligo-coverage";
nativeBuildInputs = oa.nativeBuildInputs
++ [ self.buildPackages.rakudo ];
buildPhase = ''
# Needed for coverage and nothing else
mkdir -p $out/share/coverage
echo "Coverage:"
BISECT_ENABLE=yes dune runtest --force
bisect-ppx-report html -o $out/share/coverage/all --title="LIGO overall test coverage"
bisect-ppx-report summary --per-file > $out/share/coverage-all
echo "Test coverage:"
BISECT_ENABLE=yes dune runtest src/test --force
bisect-ppx-report html -o $out/share/coverage/ligo --title="LIGO test coverage"
echo "Doc coverage:"
BISECT_ENABLE=yes dune build @doc-test --force
bisect-ppx-report html -o $out/share/coverage/docs --title="LIGO doc coverage"
echo "CLI test coverage:"
BISECT_ENABLE=yes dune runtest src/bin/expect_tests
bisect-ppx-report html -o $out/share/coverage/cli --title="CLI test coverage"
'';
installPhase = "true";
});
})
]);
}

47
nix/packageDeb.nix Normal file
View File

@ -0,0 +1,47 @@
# Create a debian package from static executable
{ stdenv, lib, writeTextFile, ligo-static, dpkg }:
let
project = "ligo";
version = "0.0.0";
revision = lib.commitIdFromGitRepo ../.git;
pkgArch = "amd64";
bin = "${ligo-static}/bin/ligo";
pkgName = "${project}_0ubuntu${version}-${revision}_${pkgArch}";
depends = "";
maintainer = "ligolang ligolang.org";
description = "A friendly Smart Contract Language for Tezos";
writeControlFile = writeTextFile {
name = "control";
text = ''
Package: ${project}
Version: ${version}-${revision}
Priority: optional
Architecture: ${pkgArch}
Depends: ${depends}
Maintainer: ${maintainer}
Description: ${project}
${description}
'';
};
in stdenv.mkDerivation rec {
name = "${pkgName}.deb";
nativeBuildInputs = [ dpkg ];
phases = "packagePhase";
packagePhase = ''
mkdir ${pkgName}
mkdir -p ${pkgName}/usr/local/bin
cp ${bin} ${pkgName}/usr/local/bin/${project}
mkdir ${pkgName}/DEBIAN
cp ${writeControlFile} ${pkgName}/DEBIAN/control
dpkg-deb --build ${pkgName}
mkdir -p $out
cp ${name} $out/
'';
}

42
nix/pkgs.nix Normal file
View File

@ -0,0 +1,42 @@
# nixpkgs extended with all the overlays for LIGO
{ sources ? import ./sources.nix }:
let
ocaml-overlay = import ./ocaml-overlay.nix { inherit sources; };
static-overlay = import ./static-overlay.nix pkgs;
mac-overlay = import ./mac-overlay.nix;
nodejs-overlay = import ./nodejs-overlay.nix;
nix-npm-buildpackage = pkgs.callPackage sources.nix-npm-buildpackage { };
pkgs = import sources.nixpkgs {
overlays = [ ocaml-overlay nodejs-overlay ]
# This is done here to prevent the need for bootstrap nixpkgs
++ (if builtins.currentSystem == "x86_64-darwin"
then [ mac-overlay ]
else [ ]);
};
# Takes $pkg/ligo and creates a new package with $pkg/bin/ligo
separateBinary = pkg:
pkgs.runCommandNoCC "${pkg.name}-bin" { }
"mkdir -p $out/bin; cp -Lr ${pkg}/ligo $out/bin";
tmp = pkgs.runCommandNoCC "tmpdir" { } "mkdir -p $out/tmp";
in pkgs.extend (self: super: {
inherit (self.ocamlPackages) ligo ligo-out ligo-tests ligo-doc ligo-coverage;
ligo-bin = separateBinary self.ligo-out.bin;
ligo-docker = self.callPackage ./docker.nix { ligo = self.ligo-bin; };
ligo-deb = self.callPackage ./packageDeb.nix { };
ligo-editor = self.callPackage ./ligo-editor.nix { inherit sources; };
ligo-editor-docker = self.callPackage ./docker.nix {
ligo = self.ligo-editor;
name = "ligo-editor";
extraContents = [ tmp ];
};
ligo-website = self.callPackage ./ligo-website.nix {
inherit (nix-npm-buildpackage) buildNpmPackage;
};
ligo-static = self.pkgsMusl.ligo-bin;
pkgsMusl = super.pkgsMusl.extend static-overlay;
})

87
nix/sources.json Normal file
View File

@ -0,0 +1,87 @@
{
"gitignore.nix": {
"branch": "master",
"description": "Nix function for filtering local git sources",
"homepage": "",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "2ced4519f865341adcb143c5d668f955a2cb997f",
"sha256": "0fc5bgv9syfcblp23y05kkfnpgh3gssz6vn24frs8dzw39algk2z",
"type": "tarball",
"url": "https://github.com/hercules-ci/gitignore.nix/archive/2ced4519f865341adcb143c5d668f955a2cb997f.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nix-npm-buildpackage": {
"branch": "balsoft/local-deps",
"description": "Build nix packages that use npm/yarn",
"homepage": "",
"owner": "serokell",
"repo": "nix-npm-buildpackage",
"rev": "f2107f638f7df7450a5b7b77b96aaf9752b838d9",
"sha256": "02w8jxmmhxsq7fgzml75b8w8i9mdqxnaajia99jajg6rdiam8zfp",
"type": "tarball",
"url": "https://github.com/serokell/nix-npm-buildpackage/archive/f2107f638f7df7450a5b7b77b96aaf9752b838d9.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
"branch": "nixos-unstable",
"description": "Pinned Nixpkgs tree (master follows nixos-unstable-small, only tags have stable history)",
"homepage": "",
"owner": "nixos",
"repo": "nixpkgs-channels",
"rev": "3320a06049fc259e87a2bd98f4cd42f15f746b96",
"sha256": "1g5l186d5xh187vdcpfsz1ff8s749949c1pclvzfkylpar09ldkl",
"type": "tarball",
"url": "https://github.com/nixos/nixpkgs-channels/archive/3320a06049fc259e87a2bd98f4cd42f15f746b96.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"node-sass-bin": {
"sha256": "0dl91l414na44h090cgghd06q0j2whlj9h98im2qb9823glq7xff",
"type": "file",
"url": "https://github.com/sass/node-sass/releases/download/v4.12.0/linux-x64-64_binding.node",
"url_template": "https://github.com/sass/node-sass/releases/download/v<version>/linux-x64-64_binding.node",
"version": "4.12.0"
},
"opam-nix": {
"branch": "master",
"description": "A handy nix library to package OCaml software from OPAM repositories",
"homepage": null,
"owner": "balsoft",
"repo": "opam-nix",
"rev": "75ad75c18b8d80d82c13dc30c3b8d70960b1b441",
"sha256": "0mcr32f5i71diysvpblbvgdnx2pdymwjb9nxz5gbcsib3vdg2p83",
"type": "tarball",
"url": "https://github.com/balsoft/opam-nix/archive/75ad75c18b8d80d82c13dc30c3b8d70960b1b441.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"opam-repository": {
"branch": "master",
"description": "Main public package repository for OPAM, the source package manager of OCaml.",
"homepage": "https://opam.ocaml.org",
"owner": "ocaml",
"repo": "opam-repository",
"rev": "d67e70b40203a6a1c77ccb2edbe136c1509a73a3",
"sha256": "1yphw9xcss284p51qnml5jvfs4mhjcjgdka3wk25q0437zdzqj4n",
"type": "tarball",
"url": "https://github.com/ocaml/opam-repository/archive/d67e70b40203a6a1c77ccb2edbe136c1509a73a3.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"tezos-opam-repository": {
"ref": "master",
"repo": "https://gitlab.com/ligolang/tezos-opam-repository",
"rev": "dfc46bd895b070bd89028a7ad98741d05ec684df",
"type": "git"
},
"xmldiff": {
"branch": "master",
"description": "Diffs on XML trees",
"homepage": "http://zoggy.github.io/xmldiff",
"owner": "zoggy",
"repo": "xmldiff",
"rev": "5873df80c1ba8c79287dc42e5008fac14cefffed",
"sha256": "0b92j9j2xdd2gyi9bgp39w0w1lkp0vc2rxq6wx6xdfvvklpprgb4",
"type": "tarball",
"url": "https://github.com/zoggy/xmldiff/archive/5873df80c1ba8c79287dc42e5008fac14cefffed.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}

134
nix/sources.nix Normal file
View File

@ -0,0 +1,134 @@
# This file has been generated by Niv.
let
#
# The fetchers. fetch_<type> fetches specs of type <type>.
#
fetch_file = pkgs: spec:
if spec.builtin or true then
builtins_fetchurl { inherit (spec) url sha256; }
else
pkgs.fetchurl { inherit (spec) url sha256; };
fetch_tarball = pkgs: spec:
if spec.builtin or true then
builtins_fetchTarball { inherit (spec) url sha256; }
else
pkgs.fetchzip { inherit (spec) url sha256; };
fetch_git = spec:
builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; };
fetch_builtin-tarball = spec:
builtins.trace
''
WARNING:
The niv type "builtin-tarball" will soon be deprecated. You should
instead use `builtin = true`.
$ niv modify <package> -a type=tarball -a builtin=true
''
builtins_fetchTarball { inherit (spec) url sha256; };
fetch_builtin-url = spec:
builtins.trace
''
WARNING:
The niv type "builtin-url" will soon be deprecated. You should
instead use `builtin = true`.
$ niv modify <package> -a type=file -a builtin=true
''
(builtins_fetchurl { inherit (spec) url sha256; });
#
# Various helpers
#
# The set of packages used when specs are fetched using non-builtins.
mkPkgs = sources:
let
sourcesNixpkgs =
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {};
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
in
if builtins.hasAttr "nixpkgs" sources
then sourcesNixpkgs
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
import <nixpkgs> {}
else
abort
''
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
add a package called "nixpkgs" to your sources.json.
'';
# The actual fetching function.
fetch = pkgs: name: spec:
if ! builtins.hasAttr "type" spec then
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
else if spec.type == "file" then fetch_file pkgs spec
else if spec.type == "tarball" then fetch_tarball pkgs spec
else if spec.type == "git" then fetch_git spec
else if spec.type == "builtin-tarball" then fetch_builtin-tarball spec
else if spec.type == "builtin-url" then fetch_builtin-url spec
else
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
# Ports of functions for older nix versions
# a Nix version of mapAttrs if the built-in doesn't exist
mapAttrs = builtins.mapAttrs or (
f: set: with builtins;
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
);
# fetchTarball version that is compatible between all the versions of Nix
builtins_fetchTarball = { url, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchTarball;
in
if lessThan nixVersion "1.12" then
fetchTarball { inherit url; }
else
fetchTarball attrs;
# fetchurl version that is compatible between all the versions of Nix
builtins_fetchurl = { url, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchurl;
in
if lessThan nixVersion "1.12" then
fetchurl { inherit url; }
else
fetchurl attrs;
# Create the final "sources" from the config
mkSources = config:
mapAttrs (
name: spec:
if builtins.hasAttr "outPath" spec
then abort
"The values in sources.json should not have an 'outPath' attribute"
else
spec // { outPath = fetch config.pkgs name spec; }
) config.sources;
# The "config" used by the fetchers
mkConfig =
{ sourcesFile ? ./sources.json
, sources ? builtins.fromJSON (builtins.readFile sourcesFile)
, pkgs ? mkPkgs sources
}: rec {
# The sources, i.e. the attribute set of spec name to spec
inherit sources;
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
inherit pkgs;
};
in
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }

27
nix/static-overlay.nix Normal file
View File

@ -0,0 +1,27 @@
# An overlay that adds flags needed to build LIGO statically;
# Supposed to be applied to pkgsMusl
# Takes `native` as a package set that doesn't cause mass rebuilds (so that we don't have to build perl with musl)
native: self: super:
let dds = x: x.overrideAttrs (o: { dontDisableStatic = true; });
in {
buildPackages = super.buildPackages // { inherit (native) rakudo; };
ocaml = self.ocaml-ng.ocamlPackages_4_07.ocaml;
libev = dds super.libev;
libusb = self.libusb1;
systemd = self.eudev;
libusb1 = dds (super.libusb1.override {
enableSystemd = true;
});
gdb = null;
hidapi = dds (super.hidapi.override { systemd = self.eudev; });
glib = (super.glib.override { libselinux = null; }).overrideAttrs
(o: { mesonFlags = o.mesonFlags ++ [ "-Dselinux=disabled" ]; });
eudev = dds (super.eudev.overrideAttrs
(o: { nativeBuildInputs = o.nativeBuildInputs ++ [ super.gperf ]; }));
gmp = dds (super.gmp);
ocamlPackages = super.ocamlPackages.overrideScope' (self: super: {
ligo-out = super.ligo-out.overrideAttrs (_: {
patches = [ ./static.patch ];
});
});
}

13
nix/static.patch Normal file
View File

@ -0,0 +1,13 @@
diff --git a/src/bin/dune b/src/bin/dune
index 162963b4b..29dfa5191 100644
With this patch, a static executable is produced
--- a/src/bin/dune
+++ b/src/bin/dune
@@ -34,5 +34,6 @@
(preprocess
(pps ppx_let ppx_blob bisect_ppx --conditional)
)
- (flags (:standard -open Simple_utils))
+ (flags (:standard -open Simple_utils)
+ -ccopt -static -cclib "-lgmp")
)

View File

@ -1,5 +1,6 @@
#!/bin/sh
set -e
set -x
if test $# -ne 1 || test "x$1" = "-h" -o "x$1" = "x--help"; then
echo "Usage: build_docker_image.sh TAG_NAME"

View File

@ -1,5 +1,6 @@
#!/bin/sh
set -e
set -x
eval $(opam config env)
dune build -p ligo

View File

@ -1,4 +1,6 @@
#!/bin/sh
set -e
set -x
dockerfile_name="build"
# Generic dockerfile
@ -8,4 +10,9 @@ dockerfile="./docker/distribution/generic/build.Dockerfile"
echo "Building LIGO for $target"
echo "Using Dockerfile: $dockerfile"
echo "Tagging as: $tag_build\n"
docker build --build-arg ci_job_id="${CI_JOB_ID}" --build-arg target="$target" -t "$tag_build" -f "$dockerfile" .
docker build \
--build-arg ci_job_id="${CI_JOB_ID}" \
--build-arg ci_commit_sha="${CI_COMMIT_SHA}" \
--build-arg commit_date="${COMMIT_DATE}" \
--build-arg target="$target" \
-t "$tag_build" -f "$dockerfile" .

View File

@ -9,4 +9,6 @@ export LIGO_REGISTRY_IMAGE_BASE_NAME="ligolang/ligo"
# ligo_incrementing-id_commit-hash
export CI_JOB_ID="0"
export CI_COMMIT_SHORT_SHA="$(git rev-parse --short HEAD)"
export CI_COMMIT_SHA="$(git rev-parse HEAD)"
export COMMIT_DATE="$(git show --no-patch --format=%ci)"
export LIGO_DIST_DIR="./dist"

View File

@ -1,4 +1,6 @@
#!/bin/sh
set -e
set -x
dockerfile_name="package"
dockerfile=""

View File

@ -1,16 +1,22 @@
#!/bin/sh
set -e
set -x
# This script accepts three arguments, os family, os and its version,
# which are subsequently used to fetch the respective docker
# image from the ocaml/infrastructure project.
#
# https://github.com/ocaml/infrastructure/wiki/Containers#selecting-linux-distributions
target_os_family=$1
target_os=$2
target_os_version=$3
target_os_family="$1"
target_os="$2"
target_os_version="$3"
# Variables configured at the CI level
dist="$LIGO_DIST_DIR"
version="$(echo $CI_JOB_ID)-$(echo $CI_COMMIT_SHORT_SHA)"
ci_job_id="$CI_JOB_ID"
ci_commit_sha="$CI_COMMIT_SHA"
commit_date="$COMMIT_DATE"
# Image names for building & packaging
target="$target_os-$target_os_version"

View File

@ -22,9 +22,9 @@ echo "Installing dependencies.."
if [ -n "`uname -a | grep -i arch`" ]
then
sudo pacman -Sy --noconfirm \
rakudo \
make \
m4 \
gcc \
patch \
bubblewrap \
rsync \
@ -34,8 +34,9 @@ fi
if [ -n "`uname -a | grep -i ubuntu`" ]
then
sudo apt-get install -y make \
perl6 \
make \
m4 \
gcc \
patch \
bubblewrap \
rsync \
@ -89,5 +90,3 @@ else
fi
opam init -a --bare

View File

@ -1,11 +1,13 @@
#!/bin/sh
set -e
set -x
. /etc/os-release
if [ $ID = arch ]
then
pacman -Sy
sudo pacman -S --noconfirm \
rakudo \
libevdev \
perl \
pkg-config \
@ -20,6 +22,7 @@ then
else
apt-get update -qq
apt-get -y -qq install \
perl6 \
libev-dev \
perl \
pkg-config \

View File

@ -1,5 +1,6 @@
#!/bin/sh
set -e
set -x
# Install local dependencies
opam install -y --deps-only --with-test ./ligo.opam $(find vendors -name \*.opam)

View File

@ -7,7 +7,7 @@ dry_run_output=$(./scripts/ligo_ci.sh dry-run src/test/contracts/website2.ligo m
expected_compiled_parameter="(Right 1)";
expected_compiled_storage=1;
expected_dry_run_output="( list[] , 2 )";
expected_dry_run_output="( LIST_EMPTY() , 2 )";
if [ "$compiled_storage" != "$expected_compiled_storage" ]; then
echo "Expected $expected_compiled_storage as compile-storage output, got $compiled_storage instead";

45
scripts/versioning.sh Executable file
View File

@ -0,0 +1,45 @@
#!/bin/sh
apt-get update -qq
apt-get -y -qq install jq
fetch_version () {
local LAST_VERSION=`curl --silent "https://gitlab.com/api/v4/projects/12294987/repository/tags?search=^V&order_by=name" | jq "map(.name)[0]"`
MAJOR=`echo $LAST_VERSION | sed -E "s/\.|\"|\V/\n/g" | grep -e . | sed -n 1p`
MINOR=`echo $LAST_VERSION | sed -E "s/\.|\"|\V/\n/g" | grep -e . | sed -n 2p`
PATCH=`echo $LAST_VERSION | sed -E "s/\.|\"|\V/\n/g" | grep -e . | sed -n 3p`
}
increment_patch () {
fetch_version
local NEW_PATCH=$((PATCH+1))
NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
}
increment_minor () {
fetch_version
local NEW_MINOR=$((MINOR+1))
NEW_VERSION="${MAJOR}.${NEW_MINOR}.0"
}
increment_major () {
fetch_version
local NEW_MAJOR=$((MAJOR+1))
NEW_VERSION="${NEW_MAJOR}.0.0"
}
tag_dev () {
curl --request POST --header "PRIVATE-TOKEN: ${AUTH}" https://gitlab.com/api/v4/projects/12294987/repository/tags -d "tag_name=V.${1}&ref=dev"
}
increment_minor
echo $NEW_VERSION
# increment_major
# echo $NEW_VERSION
# increment_patch
# echo $NEW_VERSION
tag_dev $NEW_VERSION
# curl --header "PRIVATE-TOKEN: W-7UVDzeofRmejE17_Gn" https://gitlab.com/api/v4/version
# curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/5/repository/branches?branch=newbranch&ref=master

View File

@ -2,12 +2,7 @@ open Cmdliner
open Trace
open Cli_helpers
let version =
Format.asprintf
"Rolling release\nHash: %s\nDate: %s\nCI job id: %s"
Version.hash
Version.commit_date
Version.job_id
let version = Version.version
let main =
let man =
@ -101,6 +96,13 @@ let disable_michelson_typechecking =
info ~doc ["disable-michelson-typechecking"] in
value @@ flag info
let with_types =
let open Arg in
let info =
let doc = "tries to infer types for all named expressions" in
info ~doc ["with-types"] in
value @@ flag info
let predecessor_timestamp =
let open Arg in
let info =
@ -111,16 +113,25 @@ let predecessor_timestamp =
let display_format =
let open Arg in
let open Display in
let info =
let docv = "DISPLAY_FORMAT" in
let doc = "$(docv) is the format that will be used by the CLI. Available formats are 'dev', 'json', and 'human-readable' (default). When human-readable lacks details (we are still tweaking it), please contact us and use another format in the meanwhile." in
info ~docv ~doc ["format" ; "display-format"] in
value @@
opt
(enum [("human-readable", `Human_readable); ("dev", `Dev); ("json", `Json)])
`Human_readable
(enum [("human-readable", human_readable); ("dev", dev); ("json", json)])
human_readable
info
let output_file =
let open Arg in
let info =
let docv = "OUTPUT_FILE" in
let doc = "$(docv) if used, prints the output into the specified file instead of stdout" in
info ~docv ~doc ["output" ; "output-file"] in
value @@ opt (some string) None info
let michelson_code_format =
let open Arg in
let info =
@ -132,32 +143,58 @@ let michelson_code_format =
(enum [("text", `Text); ("json", `Json); ("hex", `Hex)])
`Text info
let optimize =
let open Arg in
let docv = "ENTRY_POINT" in
let doc = "Apply Mini-C optimizations as if compiling $(docv)" in
let info =
info ~docv ~doc ["optimize"] in
value @@ opt (some string) None info
module Helpers = Ligo.Compile.Helpers
module Compile = Ligo.Compile
module Uncompile = Ligo.Uncompile
module Decompile = Ligo.Decompile
module Run = Ligo.Run.Of_michelson
let compile_file =
let f source_file entry_point syntax display_format disable_typecheck michelson_format =
toplevel ~display_format @@
let f source_file entry_point syntax display_format disable_typecheck michelson_format output_file =
return_result ~output_file ~display_format (Tezos_utils.Michelson.michelson_format michelson_format) @@
let%bind typed,_ = Compile.Utils.type_file source_file syntax (Contract entry_point) in
let%bind mini_c = Compile.Of_typed.compile typed in
let%bind michelson = Compile.Of_mini_c.aggregate_and_compile_contract mini_c entry_point in
let%bind contract = Compile.Of_michelson.build_contract ~disable_typecheck michelson in
ok @@ Format.asprintf "%a\n" (Main.Display.michelson_pp michelson_format) contract
Compile.Of_michelson.build_contract ~disable_typecheck michelson
in
let term =
Term.(const f $ source_file 0 $ entry_point 1 $ syntax $ display_format $ disable_michelson_typechecking $ michelson_code_format) in
Term.(const f $ source_file 0 $ entry_point 1 $ syntax $ display_format $ disable_michelson_typechecking $ michelson_code_format $ output_file) in
let cmdname = "compile-contract" in
let doc = "Subcommand: Compile a contract." in
(Term.ret term , Term.info ~doc cmdname)
let preprocess =
let f source_file syntax display_format =
return_result ~display_format (Parser.Formatter.ppx_format) @@
Compile.Of_source.preprocess source_file (Syntax_name syntax)
in
let term = Term.(const f $ source_file 0 $ syntax $ display_format) in
let cmdname = "preprocess" in
let doc = "Subcommand: Preprocess the source file.\nWarning: Intended for development of LIGO and can break at any time." in
(Term.ret term, Term.info ~doc cmdname)
let pretty_print =
let f source_file syntax display_format =
return_result ~display_format (Parser.Formatter.ppx_format) @@
Compile.Of_source.pretty_print source_file (Syntax_name syntax)
in
let term = Term.(const f $ source_file 0 $ syntax $ display_format) in
let cmdname = "pretty-print" in
let doc = "Subcommand: Pretty-print the source file."
in (Term.ret term, Term.info ~doc cmdname)
let print_cst =
let f source_file syntax display_format = (
toplevel ~display_format @@
let%bind pp = Compile.Of_source.pretty_print source_file (Syntax_name syntax) in
ok @@ Format.asprintf "%s \n" (Buffer.contents pp)
)
let f source_file syntax display_format =
return_result ~display_format (Parser.Formatter.ppx_format) @@
Compile.Of_source.pretty_print_cst source_file (Syntax_name syntax)
in
let term = Term.(const f $ source_file 0 $ syntax $ display_format) in
let cmdname = "print-cst" in
@ -165,23 +202,20 @@ let print_cst =
(Term.ret term, Term.info ~doc cmdname)
let print_ast =
let f source_file syntax display_format = (
toplevel ~display_format @@
let%bind imperative = Compile.Utils.to_imperatve source_file syntax in
ok @@ Format.asprintf "%a\n" Compile.Of_imperative.pretty_print imperative
)
let f source_file syntax display_format =
return_result ~display_format (Ast_imperative.Formatter.program_format) @@
Compile.Utils.to_imperatve source_file syntax
in
let term = Term.(const f $ source_file 0 $ syntax $ display_format) in
let cmdname = "print-ast" in
let doc = "Subcommand: Print the AST.\n Warning: Intended for development of LIGO and can break at any time." in
(Term.ret term, Term.info ~doc cmdname)
let print_ast_sugar =
let f source_file syntax display_format = (
toplevel ~display_format @@
let%bind sugar = Compile.Utils.to_sugar source_file syntax in
ok @@ Format.asprintf "%a\n" Compile.Of_sugar.pretty_print sugar
)
let f source_file syntax display_format =
return_result ~display_format (Ast_sugar.Formatter.program_format) @@
Compile.Utils.to_sugar source_file syntax
in
let term = Term.(const f $ source_file 0 $ syntax $ display_format) in
let cmdname = "print-ast-sugar" in
@ -189,11 +223,9 @@ let print_ast_sugar =
(Term.ret term, Term.info ~doc cmdname)
let print_ast_core =
let f source_file syntax display_format = (
toplevel ~display_format @@
let%bind core = Compile.Utils.to_core source_file syntax in
ok @@ Format.asprintf "%a\n" Compile.Of_core.pretty_print core
)
let f source_file syntax display_format =
return_result ~display_format (Ast_core.Formatter.program_format) @@
Compile.Utils.to_core source_file syntax
in
let term = Term.(const f $ source_file 0 $ syntax $ display_format) in
let cmdname = "print-ast-core" in
@ -201,11 +233,10 @@ let print_ast_core =
(Term.ret term, Term.info ~doc cmdname)
let print_ast_typed =
let f source_file syntax display_format = (
toplevel ~display_format @@
let f source_file syntax display_format =
return_result ~display_format (Ast_typed.Formatter.program_format) @@
let%bind typed,_ = Compile.Utils.type_file source_file syntax Env in
ok @@ Format.asprintf "%a\n" Compile.Of_typed.pretty_print typed
)
ok typed
in
let term = Term.(const f $ source_file 0 $ syntax $ display_format) in
let cmdname = "print-ast-typed" in
@ -213,24 +244,28 @@ let print_ast_typed =
(Term.ret term, Term.info ~doc cmdname)
let print_mini_c =
let f source_file syntax display_format = (
toplevel ~display_format @@
let f source_file syntax display_format optimize =
return_result ~display_format (Mini_c.Formatter.program_format) @@
let%bind typed,_ = Compile.Utils.type_file source_file syntax Env in
let%bind mini_c = Compile.Of_typed.compile typed in
ok @@ Format.asprintf "%a\n" Compile.Of_mini_c.pretty_print mini_c
)
match optimize with
| None -> ok @@ Mini_c.Formatter.Raw mini_c
| Some entry_point ->
let%bind o = Compile.Of_mini_c.aggregate_contract mini_c entry_point in
ok @@ Mini_c.Formatter.Optimized o
in
let term = Term.(const f $ source_file 0 $ syntax $ display_format) in
let term = Term.(const f $ source_file 0 $ syntax $ display_format $ optimize) in
let cmdname = "print-mini-c" in
let doc = "Subcommand: Print Mini-C. Warning: Intended for development of LIGO and can break at any time." in
(Term.ret term, Term.info ~doc cmdname)
let measure_contract =
let f source_file entry_point syntax display_format =
toplevel ~display_format @@
let value =
let%bind contract = Compile.Utils.compile_file source_file syntax entry_point in
let open Tezos_utils in
ok @@ Format.asprintf "%d bytes\n" (Michelson.measure contract)
ok @@ Tezos_utils.Michelson.measure contract in
let format = Display.bind_format Formatter.contract_size_format Main.Formatter.error_format in
toplevel ~display_format (Display.Displayable { value ; format }) value
in
let term =
Term.(const f $ source_file 0 $ entry_point 1 $ syntax $ display_format) in
@ -240,11 +275,11 @@ let measure_contract =
let compile_parameter =
let f source_file entry_point expression syntax amount balance sender source predecessor_timestamp display_format michelson_format =
toplevel ~display_format @@
return_result ~display_format (Tezos_utils.Michelson.michelson_format michelson_format) @@
let%bind typed_prg,state = Compile.Utils.type_file source_file syntax (Contract entry_point) in
let%bind mini_c_prg = Compile.Of_typed.compile typed_prg in
let%bind michelson_prg = Compile.Of_mini_c.aggregate_and_compile_contract mini_c_prg entry_point in
let env = Ast_typed.program_environment typed_prg in
let env = Ast_typed.program_environment Environment.default typed_prg in
let%bind (_contract: Tezos_utils.Michelson.michelson) =
(* fails if the given entry point is not a valid contract *)
Compile.Of_michelson.build_contract michelson_prg in
@ -255,8 +290,7 @@ let compile_parameter =
let%bind () = Compile.Of_typed.assert_equal_contract_type Check_parameter entry_point typed_prg typed_param in
let%bind () = Compile.Of_michelson.assert_equal_contract_type Check_parameter michelson_prg compiled_param in
let%bind options = Run.make_dry_run_options {predecessor_timestamp ; amount ; balance ; sender ; source } in
let%bind value = Run.evaluate_expression ~options compiled_param.expr compiled_param.expr_ty in
ok @@ Format.asprintf "%a\n" (Main.Display.michelson_pp michelson_format) value
Run.evaluate_expression ~options compiled_param.expr compiled_param.expr_ty
in
let term =
Term.(const f $ source_file 0 $ entry_point 1 $ expression "PARAMETER" 2 $ syntax $ amount $ balance $ sender $ source $ predecessor_timestamp $ display_format $ michelson_code_format) in
@ -266,27 +300,21 @@ let compile_parameter =
let interpret =
let f expression init_file syntax amount balance sender source predecessor_timestamp display_format =
toplevel ~display_format @@
return_result ~display_format (Decompile.Formatter.expression_format) @@
let%bind (decl_list,state,env) = match init_file with
| Some init_file ->
let%bind typed_prg,state = Compile.Utils.type_file init_file syntax Env in
let%bind mini_c_prg = Compile.Of_typed.compile typed_prg in
let env = Ast_typed.program_environment typed_prg in
let env = Ast_typed.program_environment Environment.default typed_prg in
ok (mini_c_prg,state,env)
| None -> ok ([],Typer.Solver.initial_state,Ast_typed.Environment.full_empty) in
| None -> ok ([],Typer.Solver.initial_state,Environment.default) in
let%bind (typed_exp,_) = Compile.Utils.type_expression init_file syntax expression env state in
let%bind mini_c_exp = Compile.Of_typed.compile_expression typed_exp in
let%bind compiled_exp = Compile.Of_mini_c.aggregate_and_compile_expression decl_list mini_c_exp in
let%bind options = Run.make_dry_run_options {predecessor_timestamp ; amount ; balance ; sender ; source } in
let%bind runres = Run.run_expression ~options compiled_exp.expr compiled_exp.expr_ty in
match runres with
| Fail fail_res ->
let%bind failstring = Run.failwith_to_string fail_res in
ok @@ Format.asprintf "%s" failstring
| Success value' ->
let%bind core_output = Uncompile.uncompile_expression typed_exp.type_expression value' in
ok @@ Format.asprintf "%a\n" Ast_core.PP.expression core_output
Decompile.Of_michelson.decompile_expression typed_exp.type_expression runres
in
let term =
Term.(const f $ expression "EXPRESSION" 0 $ init_file $ syntax $ amount $ balance $ sender $ source $ predecessor_timestamp $ display_format ) in
@ -296,10 +324,9 @@ let interpret =
let temp_ligo_interpreter =
let f source_file syntax display_format =
toplevel ~display_format @@
return_result ~display_format (Ligo_interpreter.Formatter.program_format) @@
let%bind typed,_ = Compile.Utils.type_file source_file syntax Env in
let%bind res = Compile.Of_typed.some_interpret typed in
ok @@ Format.asprintf "%s\n" res
Compile.Of_typed.some_interpret typed
in
let term =
Term.(const f $ source_file 0 $ syntax $ display_format ) in
@ -309,11 +336,11 @@ let temp_ligo_interpreter =
let compile_storage =
let f source_file entry_point expression syntax amount balance sender source predecessor_timestamp display_format michelson_format =
toplevel ~display_format @@
return_result ~display_format (Tezos_utils.Michelson.michelson_format michelson_format) @@
let%bind typed_prg,state = Compile.Utils.type_file source_file syntax (Contract entry_point) in
let%bind mini_c_prg = Compile.Of_typed.compile typed_prg in
let%bind michelson_prg = Compile.Of_mini_c.aggregate_and_compile_contract mini_c_prg entry_point in
let env = Ast_typed.program_environment typed_prg in
let env = Ast_typed.program_environment Environment.default typed_prg in
let%bind (_contract: Tezos_utils.Michelson.michelson) =
(* fails if the given entry point is not a valid contract *)
Compile.Of_michelson.build_contract michelson_prg in
@ -324,9 +351,7 @@ let compile_storage =
let%bind () = Compile.Of_typed.assert_equal_contract_type Check_storage entry_point typed_prg typed_param in
let%bind () = Compile.Of_michelson.assert_equal_contract_type Check_storage michelson_prg compiled_param in
let%bind options = Run.make_dry_run_options {predecessor_timestamp ; amount ; balance ; sender ; source } in
let%bind value = Run.evaluate_expression ~options compiled_param.expr compiled_param.expr_ty in
ok @@ Format.asprintf "%a\n" (Main.Display.michelson_pp michelson_format) value
in
Run.evaluate_expression ~options compiled_param.expr compiled_param.expr_ty in
let term =
Term.(const f $ source_file 0 $ entry_point 1 $ expression "STORAGE" 2 $ syntax $ amount $ balance $ sender $ source $ predecessor_timestamp $ display_format $ michelson_code_format) in
let cmdname = "compile-storage" in
@ -335,9 +360,9 @@ let compile_storage =
let dry_run =
let f source_file entry_point storage input amount balance sender source predecessor_timestamp syntax display_format =
toplevel ~display_format @@
return_result ~display_format (Decompile.Formatter.expression_format) @@
let%bind typed_prg,state = Compile.Utils.type_file source_file syntax (Contract entry_point) in
let env = Ast_typed.program_environment typed_prg in
let env = Ast_typed.program_environment Environment.default typed_prg in
let%bind mini_c_prg = Compile.Of_typed.compile typed_prg in
let%bind michelson_prg = Compile.Of_mini_c.aggregate_and_compile_contract mini_c_prg entry_point in
let%bind (_contract: Tezos_utils.Michelson.michelson) =
@ -349,13 +374,7 @@ let dry_run =
let%bind options = Run.make_dry_run_options {predecessor_timestamp ; amount ; balance ; sender ; source } in
let%bind runres = Run.run_contract ~options michelson_prg.expr michelson_prg.expr_ty args_michelson in
match runres with
| Fail fail_res ->
let%bind failstring = Run.failwith_to_string fail_res in
ok @@ Format.asprintf "%s" failstring
| Success michelson_output ->
let%bind core_output = Uncompile.uncompile_typed_program_entry_function_result typed_prg entry_point michelson_output in
ok @@ Format.asprintf "%a\n" Ast_core.PP.expression core_output
Decompile.Of_michelson.decompile_typed_program_entry_function_result typed_prg entry_point runres
in
let term =
Term.(const f $ source_file 0 $ entry_point 1 $ expression "PARAMETER" 2 $ expression "STORAGE" 3 $ amount $ balance $ sender $ source $ predecessor_timestamp $ syntax $ display_format) in
@ -365,9 +384,9 @@ let dry_run =
let run_function =
let f source_file entry_point parameter amount balance sender source predecessor_timestamp syntax display_format =
toplevel ~display_format @@
return_result ~display_format (Decompile.Formatter.expression_format) @@
let%bind typed_prg,state = Compile.Utils.type_file source_file syntax Env in
let env = Ast_typed.program_environment typed_prg in
let env = Ast_typed.program_environment Environment.default typed_prg in
let%bind mini_c_prg = Compile.Of_typed.compile typed_prg in
@ -382,13 +401,7 @@ let run_function =
let%bind michelson = Compile.Of_mini_c.aggregate_and_compile_expression mini_c_prg compiled_applied in
let%bind options = Run.make_dry_run_options {predecessor_timestamp ; amount ; balance ; sender ; source } in
let%bind runres = Run.run_expression ~options michelson.expr michelson.expr_ty in
match runres with
| Fail fail_res ->
let%bind failstring = Run.failwith_to_string fail_res in
ok @@ Format.asprintf "%s" failstring
| Success michelson_output ->
let%bind core_output = Uncompile.uncompile_typed_program_entry_function_result typed_prg entry_point michelson_output in
ok @@ Format.asprintf "%a\n" Ast_core.PP.expression core_output
Decompile.Of_michelson.decompile_typed_program_entry_function_result typed_prg entry_point runres
in
let term =
Term.(const f $ source_file 0 $ entry_point 1 $ expression "PARAMETER" 2 $ amount $ balance $ sender $ source $ predecessor_timestamp $ syntax $ display_format) in
@ -398,15 +411,14 @@ let run_function =
let evaluate_value =
let f source_file entry_point amount balance sender source predecessor_timestamp syntax display_format =
toplevel ~display_format @@
return_result ~display_format Decompile.Formatter.expression_format @@
let%bind typed_prg,_ = Compile.Utils.type_file source_file syntax Env in
let%bind mini_c = Compile.Of_typed.compile typed_prg in
let%bind (exp,_) = Mini_c.get_entry mini_c entry_point in
let%bind (exp,_) = trace_option Main_errors.entrypoint_not_found @@ Mini_c.get_entry mini_c entry_point in
let%bind compiled = Compile.Of_mini_c.aggregate_and_compile_expression mini_c exp in
let%bind options = Run.make_dry_run_options {predecessor_timestamp ; amount ; balance ; sender ; source } in
let%bind michelson_output = Run.run_no_failwith ~options compiled.expr compiled.expr_ty in
let%bind core_output = Uncompile.uncompile_typed_program_entry_expression_result typed_prg entry_point michelson_output in
ok @@ Format.asprintf "%a\n" Ast_core.PP.expression core_output
let%bind runres = Run.run_expression ~options compiled.expr compiled.expr_ty in
Decompile.Of_michelson.decompile_typed_program_entry_expression_result typed_prg entry_point runres
in
let term =
Term.(const f $ source_file 0 $ entry_point 1 $ amount $ balance $ sender $ source $ predecessor_timestamp $ syntax $ display_format) in
@ -416,12 +428,11 @@ let evaluate_value =
let compile_expression =
let f expression syntax display_format michelson_format =
toplevel ~display_format @@
let env = Ast_typed.Environment.full_empty in
return_result ~display_format (Tezos_utils.Michelson.michelson_format michelson_format) @@
let env = Environment.default in
let state = Typer.Solver.initial_state in
let%bind compiled_exp = Compile.Utils.compile_expression None syntax expression env state in
let%bind value = Run.evaluate_expression compiled_exp.expr compiled_exp.expr_ty in
ok @@ Format.asprintf "%a\n" (Main.Display.michelson_pp michelson_format) value
Run.evaluate_expression compiled_exp.expr compiled_exp.expr_ty
in
let term =
Term.(const f $ expression "" 1 $ req_syntax 0 $ display_format $ michelson_code_format) in
@ -430,7 +441,10 @@ let compile_expression =
(Term.ret term , Term.info ~doc cmdname)
let dump_changelog =
let f display_format = toplevel ~display_format @@ (ok @@ [%blob "../../CHANGELOG.md"]) in
let f display_format =
let value = [%blob "../../CHANGELOG.md"] in
let format = Formatter.changelog_format in
toplevel ~display_format (Display.Displayable {value ; format}) (ok value) in
let term =
Term.(const f $ display_format) in
let cmdname = "changelog" in
@ -438,18 +452,64 @@ let dump_changelog =
(Term.ret term , Term.info ~doc cmdname)
let list_declarations =
let f source_file syntax =
toplevel ~display_format:(`Human_readable) @@
let f source_file syntax display_format =
return_result ~display_format Formatter.declarations_format @@
let%bind core_prg = Compile.Utils.to_core source_file syntax in
let json_decl = List.map (fun decl -> `String decl) @@ Compile.Of_core.list_declarations core_prg in
ok @@ J.to_string @@ `Assoc [ ("source_file", `String source_file) ; ("declarations", `List json_decl) ]
let declarations = Compile.Of_core.list_declarations core_prg in
ok (source_file, declarations)
in
let term =
Term.(const f $ source_file 0 $ syntax ) in
Term.(const f $ source_file 0 $ syntax $ display_format ) in
let cmdname = "list-declarations" in
let doc = "Subcommand: List all the top-level declarations." in
(Term.ret term , Term.info ~doc cmdname)
let transpile_contract =
let f source_file new_syntax syntax display_format =
return_result ~display_format (Parser.Formatter.ppx_format) @@
let%bind core = Compile.Utils.to_core source_file syntax in
let%bind sugar = Decompile.Of_core.decompile core in
let%bind imperative = Decompile.Of_sugar.decompile sugar in
let%bind buffer = Decompile.Of_imperative.decompile imperative (Syntax_name new_syntax) in
ok @@ buffer
in
let term =
Term.(const f $ source_file 0 $ req_syntax 1 $ syntax $ display_format) in
let cmdname = "transpile-contract" in
let doc = "Subcommand: Transpile a contract to another syntax." in
(Term.ret term , Term.info ~doc cmdname)
let transpile_expression =
let f expression new_syntax syntax display_format =
return_result ~display_format (Parser.Formatter.ppx_format) @@
let%bind v_syntax = Helpers.syntax_to_variant (Syntax_name syntax) None in
let%bind n_syntax = Decompile.Helpers.syntax_to_variant (Syntax_name new_syntax) None in
let%bind imperative = Compile.Of_source.compile_expression v_syntax expression in
let%bind sugar = Compile.Of_imperative.compile_expression imperative in
let%bind core = Compile.Of_sugar.compile_expression sugar in
let%bind sugar = Decompile.Of_core.decompile_expression core in
let%bind imperative = Decompile.Of_sugar.decompile_expression sugar in
let%bind buffer = Decompile.Of_imperative.decompile_expression imperative n_syntax in
ok @@ buffer
in
let term =
Term.(const f $ expression "" 1 $ req_syntax 2 $ req_syntax 0 $ display_format) in
let cmdname = "transpile-expression" in
let doc = "Subcommand: Transpile an expression to another syntax." in
(Term.ret term , Term.info ~doc cmdname)
let get_scope =
let f source_file syntax display_format with_types =
return_result ~display_format Ligo.Scopes.Formatter.scope_format @@
Ligo.Scopes.scopes ~with_types source_file syntax
in
let term =
Term.(const f $ source_file 0 $ syntax $ display_format $ with_types) in
let cmdname = "get-scope" in
let doc = "Subcommand: Return the JSON encoded environment for a given file." in
(Term.ret term , Term.info ~doc cmdname)
let run ?argv () =
Term.eval_choice ?argv main [
temp_ligo_interpreter ;
@ -458,6 +518,8 @@ let run ?argv () =
compile_parameter ;
compile_storage ;
compile_expression ;
transpile_contract ;
transpile_expression ;
interpret ;
dry_run ;
run_function ;
@ -470,4 +532,7 @@ let run ?argv () =
print_ast_typed ;
print_mini_c ;
list_declarations ;
preprocess;
pretty_print;
get_scope;
]

View File

@ -1,23 +1,28 @@
open Cmdliner
open Trace
open Main.Display
let error_suggest: string = "\n If you're not sure how to fix this error, you can
do one of the following:
let return_good v = `Ok v
let return_bad v = `Error (false, Format.asprintf "@[<hv>error@ %s@]" v)
* Visit our documentation: https://ligolang.org/docs/intro/what-and-why/
* Ask a question on our Discord: https://discord.gg/9rhYaEt
* Open a gitlab issue: https://gitlab.com/ligolang/ligo/issues/new
* Check the changelog by running 'ligo changelog'\n"
let toplevel : ?output_file:string option -> display_format:ex_display_format -> displayable -> ('value, Main_errors.Types.all) result -> unit Term.ret =
fun ?(output_file=None) ~display_format disp value ->
let (Ex_display_format t) = display_format in
let as_str : string =
match t with
| Human_readable -> convert ~display_format:t disp ;
| Dev -> convert ~display_format:t disp ;
| Json -> Yojson.to_string @@ convert ~display_format:t disp
in
match value with
| Ok _ ->
let fmt = match output_file with
| Some file_path -> Format.formatter_of_out_channel @@ open_out file_path
| None -> Format.std_formatter
in
return_good @@ Format.fprintf fmt "%s\n" as_str
| Error _ -> return_bad as_str
let toplevel ~(display_format : display_format) (x : string result) : unit Term.ret =
match x with
| Ok _ -> Format.printf "%a%!" (formatted_string_result_pp display_format) x;
`Ok ()
| Error _ ->
begin
match display_format with
| `Human_readable -> print_string error_suggest ;
| _ -> ()
end ;
`Error (false, Format.asprintf "%a%!" (formatted_string_result_pp display_format) x)
let return_result : ?output_file:string option -> display_format:ex_display_format -> 'value format -> ('value, Main_errors.Types.all) result -> unit Term.ret =
fun ?(output_file=None) ~display_format value_format value ->
let format = bind_format value_format Main.Formatter.error_format in
toplevel ~output_file ~display_format (Displayable {value ; format}) value

View File

@ -1,4 +1,5 @@
open Cmdliner
open Trace
open Display
val toplevel : display_format : Main.Display.display_format -> string result -> unit Term.ret
val toplevel : ?output_file:string option -> display_format:ex_display_format -> displayable -> ('value, Main_errors.Types.all) result -> unit Term.ret
val return_result : ?output_file:string option -> display_format:ex_display_format -> 'value format -> ('value, Main_errors.Types.all) result -> unit Term.ret

Some files were not shown because too many files have changed in this diff Show More