Merge branch 'dev' of gitlab.com:ligolang/ligo into rinderknecht@pprint

This commit is contained in:
Christian Rinderknecht 2020-05-18 11:01:54 +02:00
commit 281477bbaf
9 changed files with 14068 additions and 5007 deletions

View File

@ -17,6 +17,7 @@ stages:
- ide-deploy - ide-deploy
- nix - nix
- nix-push - nix-push
- versioning
# TODO provide sensible CI for master # TODO provide sensible CI for master
dont-merge-to-master: dont-merge-to-master:
@ -99,6 +100,13 @@ dont-merge-to-master:
- eval $(opam config env) - eval $(opam config env)
- scripts/setup_repos.sh - scripts/setup_repos.sh
version_scheduled_job:
stage: versioning
script:
- scripts/versioning.sh
only:
- schedules
local-dune-job: local-dune-job:
<<: *before_script <<: *before_script
stage: test stage: test
@ -113,6 +121,8 @@ local-dune-job:
only: only:
- merge_requests - merge_requests
- dev - dev
- tags
- triggers
- /^.*-run-dev$/ - /^.*-run-dev$/
# Run a docker build without publishing to the registry # Run a docker build without publishing to the registry
@ -158,6 +168,7 @@ build-and-package-debian-9:
<<: *build_binary <<: *build_binary
only: only:
- dev - dev
- tags
- /^.*-run-dev$/ - /^.*-run-dev$/
build-and-package-debian-10: build-and-package-debian-10:
@ -175,6 +186,7 @@ build-and-package-debian-10:
only: only:
- merge_requests - merge_requests
- dev - dev
- tags
- /^.*-run-dev$/ - /^.*-run-dev$/
build-and-package-ubuntu-18-04: build-and-package-ubuntu-18-04:
@ -188,6 +200,7 @@ build-and-package-ubuntu-18-04:
<<: *build_binary <<: *build_binary
only: only:
- dev - dev
- tags
- /^.*-run-dev$/ - /^.*-run-dev$/
build-and-package-ubuntu-19-10: build-and-package-ubuntu-19-10:
@ -201,6 +214,7 @@ build-and-package-ubuntu-19-10:
<<: *build_binary <<: *build_binary
only: only:
- dev - dev
- tags
- /^.*-run-dev$/ - /^.*-run-dev$/
# Pages are deployed from dev, be careful not to override 'next' # Pages are deployed from dev, be careful not to override 'next'
@ -232,7 +246,8 @@ run-webide-unit-tests:
- npm ci - npm ci
- export LIGO_CMD=/bin/ligo && npm run test - export LIGO_CMD=/bin/ligo && npm run test
rules: rules:
- changes: - if: '$TAG_JOB != "true"'
changes:
- tools/webide/** - tools/webide/**
when: always when: always
@ -256,10 +271,11 @@ build-publish-ide-image:
. .
- docker push "${WEBIDE_IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}" - docker push "${WEBIDE_IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}"
rules: rules:
- changes: - if: '$TAG_JOB != "true"'
changes:
- tools/webide/** - tools/webide/**
when: always when: always
- if: '$CI_COMMIT_REF_NAME == "dev"' if: '$CI_COMMIT_REF_NAME == "dev"'
when: always when: always
run-webide-e2e-tests: run-webide-e2e-tests:
@ -271,10 +287,11 @@ run-webide-e2e-tests:
- export WEBIDE_IMAGE="${WEBIDE_IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}" - export WEBIDE_IMAGE="${WEBIDE_IMAGE_NAME}:${CI_COMMIT_SHORT_SHA}"
- docker-compose run e2e - docker-compose run e2e
rules: rules:
- changes: - if: '$TAG_JOB != "true"'
changes:
- tools/webide/** - tools/webide/**
when: always when: always
- if: '$CI_COMMIT_REF_NAME == "dev"' if: '$CI_COMMIT_REF_NAME == "dev"'
when: always when: always
deploy-handoff: deploy-handoff:

View File

@ -549,7 +549,7 @@ You can run the `compare` function defined above using the LIGO compiler
like this: like this:
```shell ```shell
ligo run-function 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) # Outputs: Large(Unit)
``` ```
@ -590,7 +590,7 @@ You can run the `compare` function defined above using the LIGO compiler
like this: like this:
```shell ```shell
ligo run-function 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 # Outputs: Large
``` ```
@ -613,7 +613,7 @@ You can run the `compare` function defined above using the LIGO compiler
like this: like this:
```shell ```shell
ligo run-function 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 # Outputs: Large
``` ```

File diff suppressed because it is too large Load Diff

View File

@ -31,4 +31,4 @@
"@docusaurus/plugin-sitemap": "^2.0.0-alpha.37", "@docusaurus/plugin-sitemap": "^2.0.0-alpha.37",
"@ligo/syntax": "file:src/@ligo/syntax" "@ligo/syntax": "file:src/@ligo/syntax"
} }
} }

View File

@ -17,10 +17,10 @@
"homepage": "", "homepage": "",
"owner": "serokell", "owner": "serokell",
"repo": "nix-npm-buildpackage", "repo": "nix-npm-buildpackage",
"rev": "14d03b37cd421b281835ae245b6cbf5b84c26e80", "rev": "0450c7d88dc3d0a26461b05cfa36f45d551f4d63",
"sha256": "13lz138rcy2vfd13sa4l2r4y5nx7v5pslxfy1vdq2phpmnn9j9yb", "sha256": "1w0k4jxw141win67rk66nvg323j5i3s4m1w3icf1g1f0p2zyf531",
"type": "tarball", "type": "tarball",
"url": "https://github.com/serokell/nix-npm-buildpackage/archive/14d03b37cd421b281835ae245b6cbf5b84c26e80.tar.gz", "url": "https://github.com/serokell/nix-npm-buildpackage/archive/0450c7d88dc3d0a26461b05cfa36f45d551f4d63.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}, },
"nixpkgs": { "nixpkgs": {

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

@ -33,6 +33,7 @@ type error =
| File_not_found of string | File_not_found of string
| Invalid_character of char | Invalid_character of char
| Unterminated_comment of string | Unterminated_comment of string
| Unterminated_inclusion
val format : val format :
?offsets:bool -> error Region.reg -> file:bool -> string Region.reg ?offsets:bool -> error Region.reg -> file:bool -> string Region.reg

View File

@ -119,6 +119,7 @@ type error =
| File_not_found of string | File_not_found of string
| Invalid_character of char | Invalid_character of char
| Unterminated_comment of string | Unterminated_comment of string
| Unterminated_inclusion
let error_to_string = function let error_to_string = function
Directive_inside_line -> Directive_inside_line ->
@ -178,8 +179,11 @@ let error_to_string = function
| Invalid_character c -> | Invalid_character c ->
E_Lexer.error_to_string (E_Lexer.Invalid_character c) E_Lexer.error_to_string (E_Lexer.Invalid_character c)
| Unterminated_comment ending -> | Unterminated_comment ending ->
sprintf "Unterminated comment.\n\ sprintf "Unterminated comment.\n\
Hint: Close with \"%s\"." ending Hint: Close with \"%s\"." ending
| Unterminated_inclusion ->
sprintf "Unterminated #include directive.\n\
Hint: Add as a string the name of the file to be included."
let format ?(offsets=true) Region.{region; value} ~file = let format ?(offsets=true) Region.{region; value} ~file =
let msg = error_to_string value let msg = error_to_string value
@ -492,26 +496,28 @@ rule scan state = parse
and file = Lexing.(lexbuf.lex_curr_p.pos_fname) in and file = Lexing.(lexbuf.lex_curr_p.pos_fname) in
let base = Filename.basename file let base = Filename.basename file
and reg, incl_file = scan_inclusion state lexbuf in and reg, incl_file = scan_inclusion state lexbuf in
let incl_dir = Filename.dirname incl_file in if state.mode = Copy then
let path = mk_path state in let incl_dir = Filename.dirname incl_file in
let incl_path, incl_chan = let path = mk_path state in
match find path incl_file state.opt#libs with let incl_path, incl_chan =
Some p -> p match find path incl_file state.opt#libs with
| None -> stop (File_not_found incl_file) state reg in Some p -> p
let () = print state (sprintf "\n# 1 \"%s\" 1\n" incl_path) in | None -> stop (File_not_found incl_file) state reg in
let incl_buf = Lexing.from_channel incl_chan in let () = print state (sprintf "\n# 1 \"%s\" 1\n" incl_path) in
let () = let incl_buf = Lexing.from_channel incl_chan in
let open Lexing in let () =
incl_buf.lex_curr_p <- let open Lexing in
{incl_buf.lex_curr_p with pos_fname = incl_file} in incl_buf.lex_curr_p <-
let state = {state with incl = incl_chan::state.incl} in {incl_buf.lex_curr_p with pos_fname = incl_file} in
let state' = {state with mode=Copy; trace=[]} in let state = {state with incl = incl_chan::state.incl} in
let state' = scan (push_dir incl_dir state') incl_buf in let state' = {state with mode=Copy; trace=[]} in
let state = {state with env=state'.env; incl=state'.incl} in let state' = scan (push_dir incl_dir state') incl_buf in
let path = if path = "" then base let state = {state with env=state'.env; incl=state'.incl} in
else path ^ Filename.dir_sep ^ base in let path = if path = "" then base
print state (sprintf "\n# %i \"%s\" 2" (line+1) path); else path ^ Filename.dir_sep ^ base in
scan state lexbuf let () = print state (sprintf "\n# %i \"%s\" 2" (line+1) path)
in scan state lexbuf
else scan state lexbuf
| "if" -> | "if" ->
let mode = expr state lexbuf in let mode = expr state lexbuf in
let mode = if state.mode = Copy then mode else Skip in let mode = if state.mode = Copy then mode else Skip in
@ -539,16 +545,22 @@ rule scan state = parse
scan (reduce_cond state region) lexbuf scan (reduce_cond state region) lexbuf
| "define" -> | "define" ->
let id, region = variable state lexbuf in let id, region = variable state lexbuf in
if id="true" || id="false" if state.mode = Copy then
then stop (Reserved_symbol id) state region; if id="true" || id="false"
if Env.mem id state.env then stop (Reserved_symbol id) state region
then stop (Multiply_defined_symbol id) state region; else
let state = {state with env = Env.add id state.env} if Env.mem id state.env
in scan state lexbuf then stop (Multiply_defined_symbol id) state region
else
let state = {state with env = Env.add id state.env}
in scan state lexbuf
else scan state lexbuf
| "undef" -> | "undef" ->
let id, _ = variable state lexbuf in let id, _ = variable state lexbuf in
let state = {state with env = Env.remove id state.env} if state.mode = Copy then
in scan state lexbuf let state = {state with env = Env.remove id state.env}
in scan state lexbuf
else scan state lexbuf
| "error" -> | "error" ->
stop (Error_directive (message [] lexbuf)) state region stop (Error_directive (message [] lexbuf)) state region
| "region" -> | "region" ->
@ -563,15 +575,15 @@ rule scan state = parse
| _ -> assert false | _ -> assert false
} }
| eof { if state.trace = [] then state | eof { if state.trace = [] then state
else fail Missing_endif state lexbuf } else fail Missing_endif state lexbuf }
| '"' { if state.mode = Copy then | '"' { if state.mode = Copy then
begin begin
copy state lexbuf; copy state lexbuf;
scan (in_string (mk_reg lexbuf) state lexbuf) lexbuf scan (in_string (mk_reg lexbuf) state lexbuf) lexbuf
end end
else scan state lexbuf } else scan state lexbuf }
| block_comment_openings { | block_comment_openings {
let lexeme = Lexing.lexeme lexbuf in let lexeme = Lexing.lexeme lexbuf in
@ -633,20 +645,22 @@ and symbol state = parse
and skip_line state = parse and skip_line state = parse
nl { proc_nl state lexbuf } nl { proc_nl state lexbuf }
| blank+ { skip_line state lexbuf } | eof { rollback lexbuf }
| _ { () } | blank+
| _ { skip_line state lexbuf }
and message acc = parse and message acc = parse
nl { Lexing.new_line lexbuf; nl { Lexing.new_line lexbuf;
mk_str (List.length acc) acc } mk_str (List.length acc) acc }
| eof { mk_str (List.length acc) acc } | eof { rollback lexbuf;
mk_str (List.length acc) acc }
| _ as c { message (c::acc) lexbuf } | _ as c { message (c::acc) lexbuf }
(* Comments *) (* Comments *)
and in_line_com state = parse and in_line_com state = parse
nl { proc_nl state lexbuf; state } nl { proc_nl state lexbuf; state }
| eof { state } | eof { rollback lexbuf; state }
| _ { if state.mode = Copy then copy state lexbuf; | _ { if state.mode = Copy then copy state lexbuf;
in_line_com state lexbuf } in_line_com state lexbuf }
@ -684,13 +698,13 @@ and in_block block opening state = parse
(* Included filename *) (* Included filename *)
and scan_inclusion state = parse and scan_inclusion state = parse
blank+ { scan_inclusion state lexbuf } blank+ { scan_inclusion state lexbuf }
| '"' { in_inclusion (mk_reg lexbuf) [] 0 state lexbuf } | '"' { in_inclusion (mk_reg lexbuf) [] 0 state lexbuf }
| nl | eof { fail Unterminated_inclusion state lexbuf }
and in_inclusion opening acc len state = parse and in_inclusion opening acc len state = parse
'"' { let closing = mk_reg lexbuf '"' { let closing = mk_reg lexbuf
in Region.cover opening closing, in Region.cover opening closing, mk_str len acc }
mk_str len acc }
| nl { fail Newline_in_string state lexbuf } | nl { fail Newline_in_string state lexbuf }
| eof { stop Unterminated_string state opening } | eof { stop Unterminated_string state opening }
| _ as c { in_inclusion opening (c::acc) (len+1) state lexbuf } | _ as c { in_inclusion opening (c::acc) (len+1) state lexbuf }
@ -700,7 +714,7 @@ and in_inclusion opening acc len state = parse
and in_string opening state = parse and in_string opening state = parse
"\\\"" { copy state lexbuf; in_string opening state lexbuf } "\\\"" { copy state lexbuf; in_string opening state lexbuf }
| '"' { copy state lexbuf; state } | '"' { copy state lexbuf; state }
| eof { state } | eof { rollback lexbuf; state }
| _ { copy state lexbuf; in_string opening state lexbuf } | _ { copy state lexbuf; in_string opening state lexbuf }
and preproc state = parse and preproc state = parse

View File

@ -4,7 +4,7 @@ module Region = Simple_utils.Region
module Preproc = Preprocessor.Preproc module Preproc = Preprocessor.Preproc
module EvalOpt = Preprocessor.EvalOpt module EvalOpt = Preprocessor.EvalOpt
let highlight msg = Printf.eprintf "\027[31m%s\027[0m%!" msg let highlight msg = Printf.eprintf "\027[31m%s\027[0m\n%!" msg
let options = let options =
let open EvalOpt in let open EvalOpt in