-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Split every `KeywordItem` into multiple `KeywordDefinition`s, each having their own versioning. This is to account for things like `fixed8x8` and `fixed256x80` being reserved/unreserved in different versions. - Duplicate keywords between Solidity and Yul, since the same keyword can be reserved in different versions between the two. - Now all keywords have correct versioning. - Added a script that will fetch `solc` binaries and test all variants of keywords (10777) against the actual compiler output. It has a few hacks around parsing/skipping errors, so it is not stable enough (yet) to run in CI/unguided, but it definitely helped running locally and observing the output.
- Loading branch information
1 parent
1f6c8c9
commit e37d803
Showing
29 changed files
with
3,803 additions
and
302 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
6 changes: 3 additions & 3 deletions
6
crates/codegen/language/definition/src/compiler/analysis/reachability.rs
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,6 +1,5 @@ | ||
mod analysis; | ||
mod emitter; | ||
mod versions; | ||
|
||
use crate::{ | ||
compiler::{analysis::Analysis, emitter::LanguageEmitter}, | ||
|
2 changes: 1 addition & 1 deletion
2
crates/codegen/language/definition/src/internals/parse_input_tokens/adapter.rs
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
2 changes: 1 addition & 1 deletion
2
crates/codegen/language/definition/src/internals/write_output_tokens/implementations.rs
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,6 +1,5 @@ | ||
mod compiler; | ||
mod internals; | ||
mod model; | ||
|
||
pub use compiler::*; | ||
pub use model::*; | ||
pub mod compiler; | ||
pub mod model; | ||
pub mod utils; |
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
121 changes: 121 additions & 0 deletions
121
crates/codegen/language/definition/src/utils/keywords.rs
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,121 @@ | ||
use crate::model::KeywordValue; | ||
use itertools::Itertools; | ||
|
||
impl KeywordValue { | ||
/// Collects all possible variations generated by this value. | ||
pub fn collect_variations(&self) -> Vec<String> { | ||
match self { | ||
KeywordValue::Atom { atom } => { | ||
return vec![atom.to_owned()]; | ||
} | ||
KeywordValue::Optional { value } => { | ||
let mut results = value.collect_variations(); | ||
results.insert(0, String::new()); | ||
return results; | ||
} | ||
KeywordValue::Choice { values } => { | ||
return values | ||
.iter() | ||
.flat_map(|value| value.collect_variations()) | ||
.collect_vec(); | ||
} | ||
KeywordValue::Sequence { values } => { | ||
let matrix = values | ||
.iter() | ||
.map(|value| value.collect_variations()) | ||
.collect_vec(); | ||
|
||
let results_len = matrix.iter().map(|values| values.len()).product(); | ||
let mut results = (0..results_len).map(|_| String::new()).collect_vec(); | ||
|
||
let mut span = results_len; | ||
|
||
for variations in matrix { | ||
span /= variations.len(); | ||
|
||
for j in 0..results_len { | ||
results[j].push_str(&variations[j / span % variations.len()]); | ||
} | ||
} | ||
|
||
return results; | ||
} | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_atom() { | ||
let value = KeywordValue::Atom { atom: "foo".into() }; | ||
|
||
assert_eq!(value.collect_variations(), vec!["foo"]); | ||
} | ||
|
||
#[test] | ||
fn test_optional() { | ||
let value = KeywordValue::Optional { | ||
value: KeywordValue::Atom { atom: "foo".into() }.into(), | ||
}; | ||
|
||
assert_eq!(value.collect_variations(), vec!["", "foo"]); | ||
} | ||
|
||
#[test] | ||
fn test_choice() { | ||
let value = KeywordValue::Choice { | ||
values: vec![ | ||
KeywordValue::Atom { atom: "foo".into() }, | ||
KeywordValue::Atom { atom: "bar".into() }, | ||
], | ||
}; | ||
|
||
assert_eq!(value.collect_variations(), vec!["foo", "bar"]); | ||
} | ||
|
||
#[test] | ||
fn test_sequence() { | ||
let value = KeywordValue::Sequence { | ||
values: vec![ | ||
KeywordValue::Atom { atom: "foo".into() }, | ||
KeywordValue::Atom { atom: "bar".into() }, | ||
], | ||
}; | ||
|
||
assert_eq!(value.collect_variations(), vec!["foobar"]); | ||
} | ||
|
||
#[test] | ||
fn test_all() { | ||
let value = KeywordValue::Sequence { | ||
values: vec![ | ||
KeywordValue::Atom { atom: "foo".into() }, | ||
KeywordValue::Optional { | ||
value: KeywordValue::Sequence { | ||
values: vec![ | ||
KeywordValue::Atom { atom: "_".into() }, | ||
KeywordValue::Choice { | ||
values: vec![ | ||
KeywordValue::Atom { atom: "1".into() }, | ||
KeywordValue::Atom { atom: "2".into() }, | ||
KeywordValue::Atom { atom: "3".into() }, | ||
KeywordValue::Atom { atom: "4".into() }, | ||
KeywordValue::Atom { atom: "5".into() }, | ||
], | ||
}, | ||
], | ||
} | ||
.into(), | ||
}, | ||
], | ||
}; | ||
|
||
assert_eq!( | ||
value.collect_variations(), | ||
vec!["foo", "foo_1", "foo_2", "foo_3", "foo_4", "foo_5",] | ||
); | ||
} | ||
} |
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 @@ | ||
mod keywords; | ||
mod versions; | ||
|
||
pub use keywords::*; | ||
pub use versions::*; |
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
Oops, something went wrong.