-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d3e9bc
commit c4b7b34
Showing
43 changed files
with
202 additions
and
223 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
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,6 @@ | ||
(library | ||
(name Pinc_Source) | ||
(public_name pinc-lang.source) | ||
(libraries) | ||
(instrumentation | ||
(backend landmarks --auto))) |
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,65 @@ | ||
module Position = struct | ||
type t = { | ||
source : Pinc_Source.t; | ||
line : int; | ||
column : int; | ||
} | ||
|
||
let make ~source ~line ~column = { source; line; column } | ||
let get_line pos = pos.line | ||
let get_column pos = pos.column | ||
let get_source pos = pos.source | ||
end | ||
|
||
type t = { | ||
loc_start : Position.t; | ||
loc_end : Position.t; | ||
} | ||
|
||
let merge ~s ~e () = { loc_start = s.loc_start; loc_end = e.loc_end } | ||
|
||
let make ?e ~s () = | ||
match e with | ||
| None -> { loc_start = s; loc_end = s } | ||
| Some e -> { loc_start = s; loc_end = e } | ||
;; | ||
|
||
let none = | ||
{ | ||
loc_start = Position.make ~source:Pinc_Source.empty ~line:0 ~column:0; | ||
loc_end = Position.make ~source:Pinc_Source.empty ~line:0 ~column:0; | ||
} | ||
;; | ||
|
||
let get_source loc = loc.loc_start.source | ||
let get_start loc = loc.loc_start | ||
let get_end loc = loc.loc_end | ||
|
||
let pp ppf loc = | ||
match (Pinc_Source.name loc.loc_start.source, loc = none) with | ||
| None, _ | _, true -> () | ||
| Some filename, _ -> | ||
let loc_string = | ||
if loc.loc_start.line = loc.loc_end.line then | ||
if loc.loc_start.column = loc.loc_end.column then | ||
Format.sprintf "%i:%i" loc.loc_start.line loc.loc_start.column | ||
else | ||
Format.sprintf | ||
"%i:%i-%i" | ||
loc.loc_start.line | ||
loc.loc_start.column | ||
loc.loc_end.column | ||
else | ||
Format.sprintf | ||
"%i:%i-%i:%i" | ||
loc.loc_start.line | ||
loc.loc_start.column | ||
loc.loc_end.line | ||
loc.loc_end.column | ||
in | ||
Fmt.pf | ||
ppf | ||
"%a" | ||
Fmt.(styled `Faint string) | ||
(Printf.sprintf "in file %s:%s" filename loc_string) | ||
;; |
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 @@ | ||
module Position : sig | ||
type t | ||
|
||
val make : source:Pinc_Source.t -> line:int -> column:int -> t | ||
val get_line : t -> int | ||
val get_column : t -> int | ||
val get_source : t -> Pinc_Source.t | ||
end | ||
|
||
type t | ||
|
||
val merge : s:t -> e:t -> unit -> t | ||
val make : ?e:Position.t -> s:Position.t -> unit -> t | ||
val none : t | ||
val get_source : t -> Pinc_Source.t | ||
val get_start : t -> Position.t | ||
val get_end : t -> Position.t | ||
val pp : Format.formatter -> t -> unit |
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
2 changes: 1 addition & 1 deletion
2
lib/pinc_diagnostics/Pinc_Diagnostics.mli → lib/01_diagnostics/Pinc_Diagnostics.mli
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module Location = Pinc_Location | ||
module Location = Location | ||
|
||
val error : Location.t -> string -> 'a | ||
val warn : Location.t -> string -> unit |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
(library | ||
(name Pinc_Diagnostics) | ||
(public_name pinc-lang.diagnostics) | ||
(libraries Pinc_Core fmt) | ||
(libraries Pinc_Source fmt) | ||
(instrumentation | ||
(backend bisect_ppx))) |
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,4 @@ | ||
type t | ||
|
||
val make : Pinc_Source.t -> t | ||
val scan : t -> Token.t |
2 changes: 0 additions & 2 deletions
2
lib/pinc_frontend/Pinc_Operators.ml → lib/02_parsing/Operators.ml
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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
module Token = Pinc_Token | ||
|
||
type precedence = int | ||
|
||
type associativity = | ||
|
Oops, something went wrong.