first commit
This commit is contained in:
commit
0d417bbbe5
12 changed files with 524 additions and 0 deletions
50
src/grammar/mod.rs
Normal file
50
src/grammar/mod.rs
Normal file
|
@ -0,0 +1,50 @@
|
|||
use crate::ir::{Atom, OwnedAtom};
|
||||
pub(crate) mod parser;
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
struct Module {
|
||||
objs: Vec<(String, Region)>,
|
||||
}
|
||||
|
||||
/// A region of memory.
|
||||
/// Either a structured field list or an atomic type.
|
||||
#[derive(PartialEq, Debug)]
|
||||
enum Region {
|
||||
Fields(Vec<(Range, FieldRegion)>),
|
||||
Atom { ty: Type },
|
||||
}
|
||||
|
||||
/// Content of a field.
|
||||
/// Can be a region or a constant.
|
||||
#[derive(PartialEq, Debug)]
|
||||
enum FieldRegion {
|
||||
Subfield { name: String, content: Region },
|
||||
Const { name: String, value: OwnedAtom },
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug)]
|
||||
pub(crate) enum Type {
|
||||
Bool,
|
||||
// unsigned numbers
|
||||
U8,
|
||||
U16,
|
||||
U32,
|
||||
U64,
|
||||
U128,
|
||||
UX(usize),
|
||||
// signed numbers
|
||||
I8,
|
||||
I16,
|
||||
I32,
|
||||
I64,
|
||||
I128,
|
||||
IX(usize),
|
||||
// float
|
||||
F32,
|
||||
F64,
|
||||
// strings
|
||||
Utf8,
|
||||
}
|
||||
|
||||
/// position of field relative to parent
|
||||
type Range = (usize, usize);
|
Loading…
Add table
Add a link
Reference in a new issue