Comments (4)
We might want to build up an abstract semantic graph at some stage to assist in compilation. Petgraph is a good library for working with graph data structures in Rust - might be good to take advantage of it. In fact LALRPOP actually uses it for this purpose!
from fathom.
Here's a sketch of what an owned IR might look like.
Source data description:
Pixel = struct {
r : u8,
g : u8,
b : u8,
};
Bitmap = struct {
w : u32le,
h : u32le,
data : [Pixel; w * h],
};
Bmp = Bitmap;
Owned IR:
define Pixel {
type = struct {
r : u8,
g : u8,
b : u8,
};
parse = \buf -> do {
(r, buf1) <- parse_u32le_to_u32 buf;
(g, buf2) <- parse_u32le_to_u32 buf1;
(b, buf3) <- parse_u32le_to_u32 buf2;
wrap (struct { w = w, h = h, data = data }, buf3);
}
};
define Bitmap {
type = struct {
w : u32,
h : u32,
data : Vec u8,
};
parse = \buf -> do {
(w, buf1) <- parse_u32le_to_u32 buf;
(h, buf2) <- parse_u32le_to_u32 buf1;
(data, buf3) <- parse_array_to_vec Pixel::parse (w * h) buf2;
wrap (struct { w = w, h = h, data = data }, buf3);
};
};
define Bmp {
type = Bitmap;
parse = Bitmap::parse;
};
from fathom.
I'm thinking that instead of those monadic expressions for the owned IR, maybe I could have a small set of parser combinators:
define Pixel {
type = struct {
r : u32le::type,
g : u32le::type,
b : u32le::type,
};
parser = struct {
r = u32le::parser,
g = u32le::parser,
b = u32le::parser,
};
};
define Bitmap {
type = struct {
w : u32le::type,
h : u32le::type,
data : Vec Pixel::type,
};
parser = struct {
w = u32le::parser,
h = u32le::parser,
data = vec_len_parser Pixel::parser (w * h),
};
};
define Bmp {
type = Bitmap::type;
parser = Bitmap::parser;
};
That would do implicit passing of the buffer around - an extra detail that would be added later.
from fathom.
Another pass on what a parser combinator IR might look like:
define Pixel {
type = struct {
r : u8,
g : u8,
b : u8,
};
parser =
(r : u32be) (g : u32be) (b : u32be) =>
(struct { w, h, data });
};
define Bitmap {
type = struct {
w : u32,
h : u32,
data : Vec Pixel,
};
parser =
(w : u32be) (h : u32be) (data : many Pixel (w * h)) =>
(struct { w, h, data});
};
define Bmp {
type = Bitmap;
parser = Bitmap;
};
from fathom.
Related Issues (20)
- Pretty print type information in elaboration diagnostics HOT 1
- Sequences of unspecified length
- Constrained representation types HOT 3
- Cover more unification codepaths in the testsuite
- Let formats HOT 2
- Sugar for guarded fields in record formats
- Challenges arising from the OpenType `glyf` table HOT 2
- Inconsistency between synthesised function literals and checked function literals HOT 1
- Sum types? HOT 4
- Semantic Interpretation Revisited
- Inconsistency between tuple types and record types
- Compile time benchmarks in CI? HOT 1
- Add documentation for implicit arguments HOT 1
- Lazy evaluation HOT 6
- OpenType data description
- Distillation crashes in some cases HOT 1
- Implementation annoyances HOT 1
- Multiple modules HOT 1
- Global string interner HOT 8
- Separate name resolution from elaboration HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fathom.