mirror of
https://github.com/Noratrieb/uwucc.git
synced 2026-01-14 16:45:07 +01:00
crates
This commit is contained in:
parent
f229dd7fdc
commit
92292c756c
8 changed files with 60 additions and 2 deletions
11
Cargo.lock
generated
11
Cargo.lock
generated
|
|
@ -17,6 +17,13 @@ dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "analysis"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"parser",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
|
@ -56,6 +63,10 @@ version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "codegen_x86"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "console"
|
name = "console"
|
||||||
version = "0.15.0"
|
version = "0.15.0"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [".", "./parser"]
|
members = [".", "./parser", "./analysis", "./codegen_x86"]
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "uwucc"
|
name = "uwucc"
|
||||||
|
|
|
||||||
9
analysis/Cargo.toml
Normal file
9
analysis/Cargo.toml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[package]
|
||||||
|
name = "analysis"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
parser = { path = "../parser" }
|
||||||
6
analysis/src/lib.rs
Normal file
6
analysis/src/lib.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#![allow(dead_code)] // TODO: no
|
||||||
|
#![warn(rust_2018_idioms)]
|
||||||
|
|
||||||
|
struct Ctx<'src, P> {
|
||||||
|
parser: P,
|
||||||
|
}
|
||||||
8
codegen_x86/Cargo.toml
Normal file
8
codegen_x86/Cargo.toml
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
[package]
|
||||||
|
name = "codegen_x86"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
6
codegen_x86/src/lib.rs
Normal file
6
codegen_x86/src/lib.rs
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#![allow(dead_code)] // TODO: no
|
||||||
|
#![warn(rust_2018_idioms)]
|
||||||
|
|
||||||
|
pub fn generate() {
|
||||||
|
println!("ud2");
|
||||||
|
}
|
||||||
|
|
@ -12,6 +12,8 @@ mod pre;
|
||||||
mod pretty;
|
mod pretty;
|
||||||
mod token;
|
mod token;
|
||||||
|
|
||||||
|
pub use parser::Parser;
|
||||||
|
|
||||||
pub type Spanned<T> = (T, Span);
|
pub type Spanned<T> = (T, Span);
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Copy, Default)]
|
#[derive(PartialEq, Eq, Clone, Copy, Default)]
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ impl DebugPls for ParserError {
|
||||||
|
|
||||||
type Result<T, E = ParserError> = std::result::Result<T, E>;
|
type Result<T, E = ParserError> = std::result::Result<T, E>;
|
||||||
|
|
||||||
struct Parser<'src, I>
|
pub struct Parser<'src, I>
|
||||||
where
|
where
|
||||||
I: Iterator<Item = (Tok<'src>, Span)>,
|
I: Iterator<Item = (Tok<'src>, Span)>,
|
||||||
{
|
{
|
||||||
|
|
@ -549,6 +549,22 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'src, I> Iterator for Parser<'src, I>
|
||||||
|
where
|
||||||
|
I: Iterator<Item = (Tok<'src>, Span)>,
|
||||||
|
{
|
||||||
|
type Item = Result<Spanned<ExternalDecl>>;
|
||||||
|
|
||||||
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
|
if self.peek_t().is_ok() {
|
||||||
|
let decl = self.external_declaration();
|
||||||
|
Some(decl)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn parse_declarations<'src>(
|
pub fn parse_declarations<'src>(
|
||||||
src: impl Iterator<Item = (Tok<'src>, Span)>,
|
src: impl Iterator<Item = (Tok<'src>, Span)>,
|
||||||
) -> Result<Vec<Spanned<ExternalDecl>>> {
|
) -> Result<Vec<Spanned<ExternalDecl>>> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue