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

Retrofit {Hex,Decimal}NumberExpression from v2 into v0/v1 spec #657

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Split the NumericExpression CST tests
Now that we can't reliably expose this parser starting from DSL v2,
let's test individual choices
  • Loading branch information
Xanewok committed Nov 15, 2023
commit 9246eb03732355576c5b67b6c7eb091f68932299

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

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

This file was deleted.

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

4 changes: 2 additions & 2 deletions crates/solidity/outputs/npm/tests/src/tests/cst-cursor.ts
Original file line number Diff line number Diff line change
@@ -61,7 +61,7 @@ test("use cursor", () => {
expectRule(cursor.node(), RuleKind.Expression);
expect(cursor.goToNext()).toBe(true);

expectRule(cursor.node(), RuleKind.NumericExpression);
expectRule(cursor.node(), RuleKind.DecimalNumberExpression);
expect(cursor.goToNext()).toBe(true);

expectRule(cursor.node(), RuleKind.LeadingTrivia);
@@ -85,7 +85,7 @@ test("use cursor", () => {
expectRule(cursor.node(), RuleKind.Expression);
expect(cursor.goToNext()).toBe(true);

expectRule(cursor.node(), RuleKind.NumericExpression);
expectRule(cursor.node(), RuleKind.DecimalNumberExpression);
expect(cursor.goToNext()).toBe(true);

expectRule(cursor.node(), RuleKind.LeadingTrivia);
4 changes: 2 additions & 2 deletions crates/solidity/outputs/npm/tests/src/tests/cst-output.ts
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@ test("parse token", () => {
const source = "5_286_981";
const language = new Language("0.8.1");

const parseTree = language.parse(ProductionKind.NumericExpression, source).tree();
expectRule(parseTree, RuleKind.NumericExpression);
const parseTree = language.parse(ProductionKind.DecimalNumberExpression, source).tree();
expectRule(parseTree, RuleKind.DecimalNumberExpression);

const children = parseTree.children();
expect(children).toHaveLength(1);
Original file line number Diff line number Diff line change
@@ -6,6 +6,6 @@ Source: >
Errors: []

Tree:
- NumericExpression (Rule): # 0..7 "10 days"
- DecimalNumberExpression (Rule): # 0..7 "10 days"
- DecimalLiteral (Token): "10" # 0..2
- DaysKeyword (Token): "days" # 3..7
Original file line number Diff line number Diff line change
@@ -6,5 +6,5 @@ Source: >
Errors: []

Tree:
- NumericExpression (Rule): # 0..9 "123456789"
- DecimalNumberExpression (Rule): # 0..9 "123456789"
- DecimalLiteral (Token): "123456789" # 0..9
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@ Source: >

Errors: # 1 total
- >
Error: Expected DecimalLiteral or HexLiteral.
╭─[crates/solidity/testing/snapshots/cst_output/NumericExpression/decimal_trailing_ident_start/input.sol:1:1]
Error: Expected DecimalLiteral.
╭─[crates/solidity/testing/snapshots/cst_output/DecimalNumberExpression/decimal_trailing_ident_start/input.sol:1:1]
1 │ 1a
│ ─┬─
Original file line number Diff line number Diff line change
@@ -6,6 +6,6 @@ Source: >
Errors: []

Tree:
- NumericExpression (Rule): # 0..8 "10 ether"
- DecimalNumberExpression (Rule): # 0..8 "10 ether"
- DecimalLiteral (Token): "10" # 0..2
- EtherKeyword (Token): "ether" # 3..8
Original file line number Diff line number Diff line change
@@ -6,5 +6,5 @@ Source: >
Errors: []

Tree:
- NumericExpression (Rule): # 0..3 "1.2"
- DecimalNumberExpression (Rule): # 0..3 "1.2"
- DecimalLiteral (Token): "1.2" # 0..3
Original file line number Diff line number Diff line change
@@ -6,5 +6,5 @@ Source: >
Errors: []

Tree:
- NumericExpression (Rule): # 0..2 "1."
- DecimalNumberExpression (Rule): # 0..2 "1."
- DecimalLiteral (Token): "1." # 0..2
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@ Source: >

Errors: # 1 total
- >
Error: Expected DecimalLiteral or HexLiteral.
╭─[crates/solidity/testing/snapshots/cst_output/NumericExpression/float_no_fraction/input.sol:1:1]
Error: Expected DecimalLiteral.
╭─[crates/solidity/testing/snapshots/cst_output/DecimalNumberExpression/float_no_fraction/input.sol:1:1]
1 │ 1.
│ ─┬
Original file line number Diff line number Diff line change
@@ -6,5 +6,5 @@ Source: >
Errors: []

Tree:
- NumericExpression (Rule): # 0..2 ".2"
- DecimalNumberExpression (Rule): # 0..2 ".2"
- DecimalLiteral (Token): ".2" # 0..2
Original file line number Diff line number Diff line change
@@ -6,5 +6,5 @@ Source: >
Errors: []

Tree:
- NumericExpression (Rule): # 0..3 "123"
- DecimalNumberExpression (Rule): # 0..3 "123"
- DecimalLiteral (Token): "123" # 0..3
Original file line number Diff line number Diff line change
@@ -6,5 +6,5 @@ Source: >
Errors: []

Tree:
- NumericExpression (Rule): # 0..3 "1e2"
- DecimalNumberExpression (Rule): # 0..3 "1e2"
- DecimalLiteral (Token): "1e2" # 0..3
Original file line number Diff line number Diff line change
@@ -6,5 +6,5 @@ Source: >
Errors: []

Tree:
- NumericExpression (Rule): # 0..5 "1_2_3"
- DecimalNumberExpression (Rule): # 0..5 "1_2_3"
- DecimalLiteral (Token): "1_2_3" # 0..5
Original file line number Diff line number Diff line change
@@ -6,6 +6,6 @@ Source: >
Errors: []

Tree:
- NumericExpression (Rule): # 0..9 "10 years\n"
- DecimalNumberExpression (Rule): # 0..9 "10 years\n"
- DecimalLiteral (Token): "10" # 0..2
- YearsKeyword (Token): "years" # 3..8
Original file line number Diff line number Diff line change
@@ -6,14 +6,14 @@ Source: >
Errors: # 1 total
- >
Error: Expected DaysKeyword or EtherKeyword or FinneyKeyword or HoursKeyword or MinutesKeyword or SecondsKeyword or SzaboKeyword or WeeksKeyword or WeiKeyword.
╭─[crates/solidity/testing/snapshots/cst_output/NumericExpression/years_unit/input.sol:1:3]
╭─[crates/solidity/testing/snapshots/cst_output/DecimalNumberExpression/years_unit/input.sol:1:3]
1 │ 10 years
│ ───┬───
│ ╰───── Error occurred here.
───╯

Tree:
- NumericExpression (Rule): # 0..9 "10 years\n"
- DecimalNumberExpression (Rule): # 0..9 "10 years\n"
- DecimalLiteral (Token): "10" # 0..2
- SKIPPED (Token): " years\n" # 2..9
Loading