-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fuck around and find out: trying to come up with a design for the shi…
…n asm tool
- Loading branch information
Showing
8 changed files
with
347 additions
and
15 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,16 @@ | ||
use shin_core::format::scenario::instructions::MemoryAddress; | ||
|
||
pub enum Preserve { | ||
// TODO: instead of "just" a MemoryAddress, the user should be able to use aliases | ||
Single(MemoryAddress), | ||
Range(MemoryAddress, MemoryAddress), | ||
} | ||
|
||
pub struct Preserves(pub Vec<Preserve>); | ||
|
||
pub struct Function { | ||
pub arg_aliases: Vec<String>, // TODO | ||
pub preserves: Preserves, | ||
} | ||
|
||
// struct S |
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,15 +1,5 @@ | ||
use shin_core::format::scenario::instructions::MemoryAddress; | ||
#[macro_use] | ||
extern crate pest_derive; | ||
|
||
pub enum Preserve { | ||
Single(MemoryAddress), | ||
Range(MemoryAddress, MemoryAddress), | ||
} | ||
|
||
pub struct Preserves(pub Vec<Preserve>); | ||
|
||
pub struct Function { | ||
pub arg_aliases: Vec<String>, // TODO | ||
pub preserves: Preserves, | ||
} | ||
|
||
// struct S | ||
pub mod ast; | ||
pub mod 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
WHITESPACE = _{ " " | "\t" } | ||
COMMENT = _{ "/*" ~ (!"*/" ~ ANY)* ~ "*/" } | ||
|
||
digit = @{ '0'..'9' } | ||
|
||
identifier = @{ XID_START ~ XID_CONTINUE* } | ||
|
||
integer = @{ | ||
"-" ~ digit+ | ||
| digit+ | ||
} | ||
float = @{ | ||
"-" ~ digit+ ~ "." ~ digit+ | ||
| digit+ ~ "." ~ digit+ | ||
} | ||
|
||
register_name_inner = @{ digit | "a" ~ digit | identifier } | ||
register_name = @{ "%" ~ register_name_inner } | ||
|
||
label_specifier = { identifier ~ ":" } | ||
|
||
// TODO: lists.. | ||
expr = { float | integer | register_name | identifier } | ||
|
||
generic_instruction_argument = { | ||
expr ~ "," | | ||
expr | ||
} | ||
generic_instruction = { | ||
identifier ~ (generic_instruction_argument)* | ||
} | ||
|
||
|
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,23 @@ | ||
mod syntax_kind; | ||
|
||
use pest::Parser; | ||
use pest_derive::Parser; | ||
|
||
#[derive(Parser)] | ||
#[grammar = "parser/grammar.pest"] | ||
struct ShinAsmParser; | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use super::{Rule, ShinAsmParser}; | ||
use pest::Parser; | ||
|
||
#[test] | ||
fn test() { | ||
let pairs = ShinAsmParser::parse(Rule::identifier, "test").unwrap(); | ||
let pairs = ShinAsmParser::parse(Rule::identifier, "a123").unwrap(); | ||
let pairs = ShinAsmParser::parse(Rule::generic_instruction, "aboba 123.0, 12").unwrap(); | ||
// let pairs = ShinAsmParser::parse(Rule::, "123").unwrap(); | ||
println!("{:#?}", pairs); | ||
} | ||
} |
Oops, something went wrong.