syntax
syntax copied to clipboard
Simplify parsing and printing attributes of function and arguments
Regarding issue https://github.com/rescript-lang/rescript-compiler/issues/5735
This PR improves the parsing and printing attributes of functions and arguments so that it makes the implementation simple and clear for future development extensibility.
Parsing looks okay now, but the printing error is due to an infinite loop.
let f12 = @a (@b x) => 3
let f13 = @a @b (~x) => 3
structure_item (tests/printer/expr/asyncAwait.res[97,2562+0]..[97,2562+24])
Pstr_value Nonrec
[
<def>
pattern (tests/printer/expr/asyncAwait.res[97,2562+4]..[97,2562+7])
Ppat_var "f12" (tests/printer/expr/asyncAwait.res[97,2562+4]..[97,2562+7])
expression (tests/printer/expr/asyncAwait.res[97,2562+13]..[97,2562+24])
attribute "a" (tests/printer/expr/asyncAwait.res[97,2562+10]..[97,2562+12])
[]
Pexp_fun
Nolabel
None
pattern (tests/printer/expr/asyncAwait.res[97,2562+17]..[97,2562+18])
attribute "b" (tests/printer/expr/asyncAwait.res[97,2562+14]..[97,2562+16])
[]
Ppat_var "x" (tests/printer/expr/asyncAwait.res[97,2562+17]..[97,2562+18])
expression (tests/printer/expr/asyncAwait.res[97,2562+23]..[97,2562+24])
Pexp_constant PConst_int (3,None)
]
structure_item (tests/printer/expr/asyncAwait.res[98,2587+0]..[98,2587+25])
Pstr_value Nonrec
[
<def>
pattern (tests/printer/expr/asyncAwait.res[98,2587+4]..[98,2587+7])
Ppat_var "f13" (tests/printer/expr/asyncAwait.res[98,2587+4]..[98,2587+7])
expression (tests/printer/expr/asyncAwait.res[98,2587+16]..[98,2587+25])
attribute "a" (tests/printer/expr/asyncAwait.res[98,2587+10]..[98,2587+12])
[]
attribute "b" (tests/printer/expr/asyncAwait.res[98,2587+13]..[98,2587+15])
[]
Pexp_fun
Labelled "x"
None
pattern (tests/printer/expr/asyncAwait.res[98,2587+17]..[98,2587+19])
attribute "ns.namedArgLoc" (tests/printer/expr/asyncAwait.res[98,2587+18]..[98,2587+19])
[]
Ppat_var "x" (tests/printer/expr/asyncAwait.res[98,2587+17]..[98,2587+19])
expression (tests/printer/expr/asyncAwait.res[98,2587+24]..[98,2587+25])
Pexp_constant PConst_int (3,None)
]
The body returned should be "3" in both cases.
Needs to always make progress, and put together a group of args.
expression (tests/printer/expr/asyncAwait.res[97,2562+23]..[97,2562+24]) Pexp_constant PConst_int (3,None)
expression (tests/printer/expr/asyncAwait.res[97,2562+23]..[97,2562+24])
Pexp_constant PConst_int (3,None)
I think this is the body returns "3"
I ran a test of the compiler with the syntax submodule checked out to this branch. The test result looks fine.
$ make test-all
Rebaed to master to resolve the confict in the test txt
Rebased to master
moved to compiler repo