-
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.
implement source type to hold file content in memory (fixes #26)
- Loading branch information
1 parent
8ef749c
commit f220e38
Showing
19 changed files
with
194 additions
and
135 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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
module Source = Pinc_Core.Source | ||
module Ast = Pinc_Frontend.Ast | ||
module Parser = Pinc_Frontend.Parser | ||
|
||
|
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 @@ | ||
module Source = Pinc_Source |
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 @@ | ||
type t = | ||
| Empty | ||
| File of string | ||
| String of string option * string | ||
|
||
let empty = Empty | ||
let of_string ?filename content = String (filename, content) | ||
let of_file path = File path | ||
|
||
let name = function | ||
| Empty -> None | ||
| File name -> Some name | ||
| String (name, _) -> name | ||
;; | ||
|
||
let length = function | ||
| Empty -> 0 | ||
| File filename -> ( | ||
try In_channel.(with_open_bin filename length) |> Int64.to_int | ||
with _ -> invalid_arg "file size is larger than an OCaml 63-bit integer") | ||
| String (_name, content) -> String.length content | ||
;; | ||
|
||
let content = function | ||
| Empty -> "" | ||
| File filename -> In_channel.(with_open_bin filename input_all) | ||
| String (_name, content) -> content | ||
;; |
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,8 @@ | ||
type t | ||
|
||
val empty : t | ||
val of_string : ?filename:string -> string -> t | ||
val of_file : string -> t | ||
val name : t -> string option | ||
val length : t -> int | ||
val content : t -> 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,5 @@ | ||
(library | ||
(name Pinc_Core) | ||
(public_name pinc-lang.core) | ||
(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
type t = { | ||
filename : string; | ||
source : Pinc_Core.Source.t; | ||
line : int; | ||
beginning_of_line : int; | ||
column : int; | ||
} | ||
|
||
let make ~filename ~line ~column = { filename; line; beginning_of_line = 0; column } | ||
let make ~source ~line ~column = { source; line; beginning_of_line = 0; column } |
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,8 +1,8 @@ | ||
type t = { | ||
filename : string; | ||
source : Pinc_Core.Source.t; | ||
line : int; | ||
beginning_of_line : int; | ||
column : int; | ||
} | ||
|
||
val make : filename:string -> line:int -> column:int -> t | ||
val make : source:Pinc_Core.Source.t -> line:int -> column:int -> t |
Oops, something went wrong.