Skip to content

Commit

Permalink
feat: Support the from contextual keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok committed Sep 19, 2023
1 parent 861176b commit 637577c
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 121 deletions.
7 changes: 5 additions & 2 deletions crates/solidity/inputs/language/src/dsl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ slang_grammar! {
| FinalKeyword
| FinneyKeyword
| ForKeyword
| FromKeyword
| FunctionKeyword
| GlobalKeyword
| HexKeyword
Expand Down Expand Up @@ -885,7 +884,6 @@ slang_grammar! {
scanner FinalKeyword = "final" ;
scanner FinneyKeyword = "finney" ;
scanner ForKeyword = "for" ;
scanner FromKeyword = "from" ;
scanner FunctionKeyword = "function" ;
scanner GlobalKeyword = "global" ;
scanner HexKeyword = "hex" ;
Expand Down Expand Up @@ -939,6 +937,11 @@ slang_grammar! {
scanner WhileKeyword = "while" ;
scanner YearsKeyword = "years" ;

scanner FromKeyword = {
/* introduced in "0.2.1" but we support >0.4.11 */
contextual "from" using Identifier
} ;

// introduced in 0.4.21
scanner EmitKeyword = (
{ introduced in "0.4.21" and removed in "0.5.0" contextual "emit" using Identifier } |
Expand Down
80 changes: 41 additions & 39 deletions crates/solidity/outputs/cargo/crate/src/generated/language.rs

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

80 changes: 41 additions & 39 deletions crates/solidity/outputs/npm/crate/src/generated/language.rs

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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Source: >
1 │ event Transfer(address indexed from, address indexed to, uint256 value); │ 0..72
Errors: []

Tree:
- EventDefinition (Rule): # 0..73 "event Transfer(address indexed from, address index..."
- EventKeyword (Token): "event" # 0..5
- Identifier (Token): "Transfer" # 6..14
- OpenParen (Token): "(" # 14..15
- EventParametersList (Rule): # 15..70 "address indexed from, address indexed to, uint256 ..."
- EventParameter (Rule): # 15..35 "address indexed from"
- TypeName (Rule): # 15..22 "address"
- AddressType (Rule): # 15..22 "address"
- AddressKeyword (Token): "address" # 15..22
- IndexedKeyword (Token): "indexed" # 23..30
- Identifier (Token): "from" # 31..35
- Comma (Token): "," # 35..36
- EventParameter (Rule): # 36..55 " address indexed to"
- TypeName (Rule): # 36..44 " address"
- AddressType (Rule): # 36..44 " address"
- AddressKeyword (Token): "address" # 37..44
- IndexedKeyword (Token): "indexed" # 45..52
- Identifier (Token): "to" # 53..55
- Comma (Token): "," # 55..56
- EventParameter (Rule): # 56..70 " uint256 value"
- TypeName (Rule): # 56..64 " uint256"
- UnsignedIntegerType (Token): "uint256" # 57..64
- Identifier (Token): "value" # 65..70
- CloseParen (Token): ")" # 70..71
- Semicolon (Token): ";" # 71..72
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,31 @@
Source: >
1 │ function transferFrom(address from, address to, uint256 amount) external returns (bool); │ 0..88
Errors: # 1 total
- >
Error: Expected CloseParen or Comma.
╭─[crates/solidity/testing/snapshots/cst_output/FunctionDefinition/from_contextual_keyword/input.sol:1:31]
1 │ function transferFrom(address from, address to, uint256 amount) external returns (bool);
│ ────────────────┬───────────────
│ ╰───────────────── Error occurred here.
───╯
Errors: []

Tree:
- FunctionDefinition (Rule): # 0..89 "function transferFrom(address from, address to, ui..."
- FunctionKeyword (Token): "function" # 0..8
- Identifier (Token): "transferFrom" # 9..21
- ParametersDeclaration (Rule): # 21..63 "(address from, address to, uint256 amount)"
- OpenParen (Token): "(" # 21..22
- ParametersList (Rule): # 22..29 "address"
- Parameter (Rule): # 22..29 "address"
- ParametersList (Rule): # 22..62 "address from, address to, uint256 amount"
- Parameter (Rule): # 22..34 "address from"
- TypeName (Rule): # 22..29 "address"
- AddressType (Rule): # 22..29 "address"
- AddressKeyword (Token): "address" # 22..29
- SKIPPED (Token): "from, address to, uint256 amount" # 30..62
- Identifier (Token): "from" # 30..34
- Comma (Token): "," # 34..35
- Parameter (Rule): # 35..46 " address to"
- TypeName (Rule): # 35..43 " address"
- AddressType (Rule): # 35..43 " address"
- AddressKeyword (Token): "address" # 36..43
- Identifier (Token): "to" # 44..46
- Comma (Token): "," # 46..47
- Parameter (Rule): # 47..62 " uint256 amount"
- TypeName (Rule): # 47..55 " uint256"
- UnsignedIntegerType (Token): "uint256" # 48..55
- Identifier (Token): "amount" # 56..62
- CloseParen (Token): ")" # 62..63
- FunctionAttributesList (Rule): # 63..72 " external"
- ExternalKeyword (Token): "external" # 64..72
Expand Down

0 comments on commit 637577c

Please sign in to comment.