-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into afromher_shifts
- Loading branch information
Showing
123 changed files
with
14,396 additions
and
9,673 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
on: | ||
push: | ||
branches-ignore: [ '_**' ] | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
nix: | ||
#runs-on: ubuntu-latest | ||
runs-on: [self-hosted, linux, nix] | ||
steps: | ||
#- uses: cachix/install-nix-action@v22 | ||
- uses: actions/checkout@v4 | ||
- run: nix build -L .#charon | ||
- run: nix build -L .#checks.x86_64-linux.tests | ||
- run: nix build -L .#checks.x86_64-linux.tests-polonius | ||
- run: nix build -L .#charon-ml | ||
- run: nix build -L .#checks.x86_64-linux.charon-ml-tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# This file is generated by dune, edit dune-project instead | ||
opam-version: "2.0" | ||
version: "0.1" | ||
synopsis: "Parser to define name matchers" | ||
description: "" | ||
authors: ["Son Ho" "Jonathan Protzenko" "Aymeric Fromherz" "Sidney Congard"] | ||
license: "Apache-2.0" | ||
homepage: "https://github.com/AeneasVerif/charon" | ||
bug-reports: "https://github.com/AeneasVerif/charon/issues" | ||
depends: [ | ||
"dune" {>= "3.7"} | ||
"odoc" {with-doc} | ||
] | ||
build: [ | ||
["dune" "subst"] {dev} | ||
[ | ||
"dune" | ||
"build" | ||
"-p" | ||
name | ||
"-j" | ||
jobs | ||
"@install" | ||
"@runtest" {with-test} | ||
"@doc" {with-doc} | ||
] | ||
] | ||
dev-repo: "git+https://github.com/AeneasVerif/charon.git" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
(* TODO: this duplicates PrimitiveValues *) | ||
type big_int = Z.t | ||
|
||
let pp_big_int (fmt : Format.formatter) (bi : big_int) : unit = | ||
Format.pp_print_string fmt (Z.to_string bi) | ||
|
||
let compare_big_int (bi0 : big_int) (bi1 : big_int) : int = Z.compare bi0 bi1 | ||
let show_big_int (bi : big_int) : string = Z.to_string bi | ||
|
||
type var = VarName of string | VarIndex of int [@@deriving show, ord] | ||
|
||
type literal = LInt of big_int | LBool of bool | LChar of char | ||
[@@deriving show, ord] | ||
|
||
(*type const_generic = CgVar of const_generic_var option | CgValue of Z.t*) | ||
type ref_kind = RMut | RShared [@@deriving show, ord] | ||
type region = RVar of var option | RStatic [@@deriving show, ord] | ||
type primitive_adt = TTuple | TArray | TSlice [@@deriving show, ord] | ||
|
||
type pattern = pattern_elem list | ||
and pattern_elem = PIdent of string * generic_args | PImpl of expr | ||
|
||
(** An expression can be a type or a trait ref. | ||
Note that we put in separate cases the tuple, array, slice and reference | ||
types because they have special syntax. | ||
*) | ||
and expr = | ||
| EComp of pattern | ||
(** Compound expression: instantiated adt, primitive type, constant, etc. | ||
Note that if a type has generic arguments, they will be grouped with | ||
the last pattern elem. | ||
*) | ||
| EPrimAdt of primitive_adt * generic_args | ||
| ERef of region * expr * ref_kind | ||
| EVar of var option | ||
|
||
and generic_arg = GExpr of expr | GValue of literal | GRegion of region | ||
and generic_args = generic_arg list [@@deriving show, ord] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
open Lexing | ||
include Ast | ||
|
||
let colnum pos = pos.pos_cnum - pos.pos_bol - 1 | ||
|
||
let pos_string pos = | ||
let l = string_of_int pos.pos_lnum and c = string_of_int (colnum pos + 1) in | ||
"line " ^ l ^ ", column " ^ c | ||
|
||
let parse_pattern (s : string) : pattern = | ||
let lexbuf = Lexing.from_string s in | ||
try Parser.full_pattern Lexer.token lexbuf | ||
with Parser.Error -> | ||
raise | ||
(Failure ("Parse error at " ^ pos_string lexbuf.lex_curr_p ^ ":\n" ^ s)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
open Parser | ||
open Ast | ||
} | ||
|
||
let digit = ['0'-'9'] | ||
let alpha = ['a'-'z' 'A'-'Z'] | ||
let ident = (alpha) (alpha | digit | '_')* | ||
let whitespace = [' ']+ | ||
|
||
(* Rules *) | ||
rule token = parse | ||
| "::" { SEP } | ||
| "mut" { MUT } | ||
| "'static" { STATIC_REGION } | ||
| ''' { REGION (index lexbuf) } | ||
| "true" { TRUE } | ||
| "false" { FALSE } | ||
| ident { IDENT (Lexing.lexeme lexbuf) } | ||
| digit { INT (Z.of_string (Lexing.lexeme lexbuf)) } | ||
| '(' { LEFT_BRACKET } | ||
| ')' { RIGHT_BRACKET } | ||
| '{' { LEFT_CURLY } | ||
| '}' { RIGHT_CURLY } | ||
| '[' { LEFT_SQUARE } | ||
| ']' { RIGHT_SQUARE } | ||
| "@" { VAR(index lexbuf) } | ||
| ';' { SEMICOL } | ||
| '&' { AMPERSAND } | ||
| whitespace { token lexbuf } | ||
| eof { EOF } | ||
| '<' { LEFT_ANGLE } | ||
| '>' { RIGHT_ANGLE } | ||
| ',' { COMMA } | ||
| _ { raise (Failure ("Character not allowed in source text: '" ^ Lexing.lexeme lexbuf ^ "'")) } | ||
|
||
and index = parse | ||
| ident { Some (VarName (Lexing.lexeme lexbuf)) } | ||
| digit+ { Some (VarIndex (int_of_string (Lexing.lexeme lexbuf))) } | ||
| '_' { None } | ||
| "" { None } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
%{ | ||
open Ast | ||
%} | ||
|
||
%token <string> IDENT | ||
%token <Ast.var option> VAR // For types and const generics | ||
%token <Ast.var option> REGION | ||
%token <Z.t> INT | ||
%token STATIC_REGION | ||
%token SEP TRUE FALSE | ||
%token LEFT_BRACKET RIGHT_BRACKET | ||
%token LEFT_CURLY RIGHT_CURLY | ||
%token LEFT_SQUARE RIGHT_SQUARE | ||
%token LEFT_ANGLE RIGHT_ANGLE | ||
%token SEMICOL AMPERSAND MUT COMMA EOF | ||
|
||
/* Types */ | ||
|
||
%type <pattern> full_pattern | ||
%type <pattern> pattern | ||
%type <pattern_elem> pattern_elem | ||
%type <expr> expr | ||
%type <region> region | ||
%type <generic_args> generic_args | ||
%type <generic_arg> generic_arg | ||
|
||
/* Entry point */ | ||
|
||
%start full_pattern | ||
|
||
%% | ||
|
||
full_pattern: | ||
| n=pattern EOF { n } | ||
|
||
pattern: | ||
| e=pattern_elem { [e] } | ||
| e=pattern_elem SEP n=pattern { e :: n } | ||
|
||
pattern_elem: | ||
// (Instantiated) identifier | ||
| id=IDENT { PIdent (id, []) } | ||
| id=IDENT; LEFT_ANGLE; g=generic_args; RIGHT_ANGLE { PIdent (id, g) } | ||
// Impl path elem | ||
| LEFT_CURLY; ty=expr; RIGHT_CURLY { PImpl ty } | ||
|
||
expr: | ||
// Compound types - note that if a type has generics, they will be grouped | ||
// with the last pattern_elem of the name | ||
| n=pattern { EComp n } | ||
// Primitive ADT: Tuple | ||
| LEFT_BRACKET; tys=separated_list(COMMA, expr); RIGHT_BRACKET { | ||
EPrimAdt (TTuple, List.map (fun x -> GExpr x) tys) } | ||
// Primitive ADT: Slice | ||
| LEFT_SQUARE; ty=expr; RIGHT_SQUARE { | ||
EPrimAdt (TSlice, [GExpr ty]) } | ||
// Primitive ADT: Array | ||
| LEFT_SQUARE; ty=expr; SEMICOL; cg=expr; RIGHT_SQUARE { | ||
EPrimAdt (TArray, [GExpr ty; GExpr cg]) } | ||
// References | ||
| AMPERSAND; r=region; MUT; ty=expr { | ||
ERef (r, ty, RMut) } | ||
| AMPERSAND; r=region; ty=expr { | ||
ERef (r, ty, RShared) } | ||
// Variables | ||
| v=VAR { EVar v } | ||
; | ||
|
||
region: | ||
| STATIC_REGION { RStatic } | ||
| r=REGION { RVar r } | ||
|
||
generic_args: | ||
| g=generic_arg { [ g ] } | ||
| g=generic_arg; COMMA; gl=generic_args { g :: gl } | ||
|
||
generic_arg: | ||
// Expressions | ||
| e=expr { GExpr e } | ||
// Values | ||
| TRUE { GValue (LBool true) } | ||
| FALSE { GValue (LBool false) } | ||
| v=INT { GValue (LInt v) } | ||
// Regions | ||
| r=region { GRegion r } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
(ocamllex Lexer) | ||
(menhir | ||
(modules Parser) | ||
(flags --explain --inspection --table --dump)) | ||
|
||
(library | ||
(name name_matcher_parser) | ||
(public_name name_matcher_parser) | ||
(preprocess (pps ppx_deriving.show ppx_deriving.ord)) | ||
(libraries zarith menhirLib) | ||
(flags | ||
; menhir generates instances of the "unused rec flag" warning | ||
(:standard -w -39))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.