Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport {Uint,Int,Fixed,Ufixed}Keyword from DSL v2 to v0/v1 #662

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions crates/codegen/schema/src/validation/rules/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,5 @@ pub fn is_a_keyword_scanner(reference_name: &str) -> bool {
// In the meantime, let's just skip them from this validation.
// https://github.com/NomicFoundation/slang/issues/505

return match reference_name {
"FixedBytesType"
| "SignedFixedType"
| "UnsignedFixedType"
| "SignedIntegerType"
| "UnsignedIntegerType" => true,
keyword if keyword.contains("Keyword") || keyword.contains("ReservedWord") => true,
_ => false,
};
reference_name.contains("Keyword") || reference_name.contains("ReservedWord")
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@
- reference: "ByteKeyword"
- reference: "StringKeyword"
- reference: "AddressType"
- reference: "FixedBytesType"
- reference: "SignedIntegerType"
- reference: "UnsignedIntegerType"
- reference: "SignedFixedType"
- reference: "UnsignedFixedType"
- reference: "BytesKeyword"
- reference: "IntKeyword"
- reference: "UintKeyword"
- reference: "FixedKeyword"
- reference: "UfixedKeyword"
0.8.0:
# removed: ByteKeyword
choice:
- reference: "BoolKeyword"
- reference: "StringKeyword"
- reference: "AddressType"
- reference: "FixedBytesType"
- reference: "SignedIntegerType"
- reference: "UnsignedIntegerType"
- reference: "SignedFixedType"
- reference: "UnsignedFixedType"
- reference: "BytesKeyword"
- reference: "IntKeyword"
- reference: "UintKeyword"
- reference: "FixedKeyword"
- reference: "UfixedKeyword"

- name: "AddressType"
kind: "Parser"
Expand All @@ -37,7 +37,7 @@
reference: "PayableKeyword"
- reference: "PayableKeyword"

- name: "FixedBytesType"
- name: "BytesKeyword"
kind: "Scanner"
unversioned:
trailingContext:
Expand Down Expand Up @@ -86,7 +86,7 @@
- terminal: "31"
- terminal: "32"

- name: "SignedIntegerType"
- name: "IntKeyword"
kind: "Scanner"
unversioned:
trailingContext:
Expand All @@ -98,7 +98,7 @@
notFollowedBy:
reference: "IdentifierPart"

- name: "UnsignedIntegerType"
- name: "UintKeyword"
kind: "Scanner"
unversioned:
trailingContext:
Expand Down Expand Up @@ -148,7 +148,7 @@
- terminal: "248"
- terminal: "256"

- name: "SignedFixedType"
- name: "FixedKeyword"
kind: "Scanner"
unversioned:
trailingContext:
Expand All @@ -160,7 +160,7 @@
notFollowedBy:
reference: "IdentifierPart"

- name: "UnsignedFixedType"
- name: "UfixedKeyword"
kind: "Scanner"
unversioned:
trailingContext:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
unversioned:
choice:
# Types
- reference: "FixedBytesType"
- reference: "SignedFixedType"
- reference: "UnsignedFixedType"
- reference: "SignedIntegerType"
- reference: "UnsignedIntegerType"
- reference: "BytesKeyword"
- reference: "FixedKeyword"
- reference: "UfixedKeyword"
- reference: "IntKeyword"
- reference: "UintKeyword"
# Keywords
- reference: "AddressKeyword"
- reference: "AnonymousKeyword"
Expand Down
12 changes: 6 additions & 6 deletions crates/solidity/inputs/language/src/dsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ slang_grammar! {
parser DoWhileStatement = ((DoKeyword Statement WhileKeyword (Expression delimited by OpenParen and CloseParen)) terminated by Semicolon) ;

inline parser ElementaryType = (
BoolKeyword | StringKeyword | AddressType | FixedBytesType | SignedIntegerType | UnsignedIntegerType | SignedFixedType | UnsignedFixedType |
BoolKeyword | StringKeyword | AddressType | BytesKeyword | IntKeyword | UintKeyword | FixedKeyword | UfixedKeyword |
{ removed in "0.8.0" ByteKeyword}
) ;

Expand Down Expand Up @@ -768,11 +768,11 @@ slang_grammar! {

// Constructed Identifiers (Typenames)

scanner FixedBytesType = ("bytes" FixedBytesTypeSize) ;
scanner SignedFixedType = ("fixed" (FixedTypeSize ?)) ;
scanner SignedIntegerType = ("int" (IntegerTypeSize ?)) ;
scanner UnsignedFixedType = ("ufixed" (FixedTypeSize ?)) ;
scanner UnsignedIntegerType = ("uint" (IntegerTypeSize ?)) ;
scanner BytesKeyword = ("bytes" FixedBytesTypeSize) ;
scanner FixedKeyword = ("fixed" (FixedTypeSize ?)) ;
scanner IntKeyword = ("int" (IntegerTypeSize ?)) ;
scanner UfixedKeyword = ("ufixed" (FixedTypeSize ?)) ;
scanner UintKeyword = ("uint" (IntegerTypeSize ?)) ;

scanner FixedBytesTypeSize = (
"1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" |
Expand Down
10 changes: 5 additions & 5 deletions crates/solidity/outputs/cargo/crate/src/generated/kinds.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading