diff --git a/docs/src/style.md b/docs/src/style.md index 688f7b0..9ddc173 100644 --- a/docs/src/style.md +++ b/docs/src/style.md @@ -18,7 +18,7 @@ To get an idea what the format looks like, here's a typical proc definition - everything fits on one line, nice! ```nim -proc covers(entry: AttestationEntry; bits: CommitteeValidatorsBits): bool = +proc function(par0: SomeType): bool = ... ``` @@ -26,8 +26,8 @@ If we add more arguments, it starts getting long - nph will try with a version where the arguments sit on a line of their own: ```nim -proc addAttestation( - entry: var AttestationEntry; attestation: Attestation; signature: CookedSig +proc function( + par0: SomeType, par1: SomeType ): bool = ... ``` @@ -35,21 +35,20 @@ proc addAttestation( The above idea extends to most formatting: if something is simple, format it in a simple way - if not, use a bit of style to break down what's going on into more easily consumable pieces - here's a function with several information-dense -parameters and a complex return type: +parameters and a pragma: ```nim -proc validateBlsToExecutionChange*( - pool: ValidatorChangePool; - batchCrypto: ref BatchCrypto; - signed_address_change: SignedBLSToExecutionChange; - wallEpoch: Epoch -): Future[Result[void, ValidationError]] {.async.} = +proc function( + par0: SomeType, + par1, par2: SomeOtherType, + par3 = default(SomeType), +): bool {.inline.} = ... ``` ```admonish info "Example styling" The examples are illustrative and not based on exact rendering semantics - in -particular, a different line length was used to keep them readable +particular, a different line length was used to make the point ``` ## Lists @@ -64,7 +63,7 @@ If the whole list fits on the current line, it is rendered in-place. Short sequences, single-parameter functions etc usually fit into this category: ```nim -import folder/module +import dir/module const v = [1, 2, 3] @@ -77,12 +76,11 @@ name takes up space ```nim import - folder/[module1, module2, module3] + dir/[module1, module2, module3, module4] -const - mylongvariablename = [ - 100000000, 2000000000, 300000000000 - ] +const mylongvariablename = [ + 100000000, 200000000, 300000000 +] proc function( param0: int, param1: int, param2: int @@ -97,22 +95,22 @@ happens most often for function parameters and other information-dense construct ```nim import - folder/[module1, module2, module3], - folder2/[ - module4, module5, module6, module7, module8, - module9 + dir/[module1, module2, module3], + dir2/[ + module4, module5, module6, module7, + module8, module9 ] -let - myVariable = [ - functionCall(a, b, c), - functionCall(a, b, c, d), - ] +let myVariable = [ + functionCall(a, b, c), + functionCall(a, b, c, d) +] functionCall( functionCall(a, b, c), functionCall(a, b, c, d), ) + ``` ```admonish info "Extra separator" @@ -123,11 +121,10 @@ this makes it easier to reorder entries and reduces git conflicts! For simple values, we use a compact style that fits several items per row: ```nim -const - values = [ - 10000000, 2000000000, 3000000000, - 40000000, 5000000000 - ] +const values = [ + 10000000, 2000000000, 3000000000, + 40000000, 5000000000 +] functionCall( 10000000, 2000000000, 3000000000, @@ -166,9 +163,8 @@ template notthesame(a, b) = discard # Semicolons cannot be used at all for inline procedures: proc f( myParameter = 0, - callback: SomeCallback = - proc() = - discard + callback: SomeCallback = proc() = + discard , nextParameter = 1, ) @@ -201,7 +197,7 @@ Expressions appear in many places, such as after certain keywords (`return`, Whenever possible, `nph` will try to keep the full expression on a single line: ```nim -let myvariable = somelongexpression(abc) +let myvariable = shortexpression(abc) ``` If this is not possible, the second preference is to move the whole expression @@ -209,7 +205,7 @@ to a new line, assuming it fits: ```nim let myvariable = - someevenlongerexpression(abc, def) + someevenlongerexpression(abc, def) ``` If the expression still doesn't fit, we'll split it up on multiple lines: diff --git a/src/phrenderer.nim b/src/phrenderer.nim index 072356f..21a1b67 100644 --- a/src/phrenderer.nim +++ b/src/phrenderer.nim @@ -26,7 +26,7 @@ when defined(nimPreviewSlimSystem): const IndentWidth = 2 longIndentWid = IndentWidth * 2 - MaxLineLen = 88 + MaxLineLen = when defined(nphBookExamples): 44 else: 88 blankAfterComplex = {nkObjectTy, nkEnumTy, nkTypeSection, nkProcDef .. nkIteratorDef} ## If a statment is sufficiently complex as measured by the number of lines ## it occupies, add a blank line after it diff --git a/tests/after/style.nim b/tests/after/style.nim new file mode 100644 index 0000000..2294866 --- /dev/null +++ b/tests/after/style.nim @@ -0,0 +1,57 @@ +# Style examples - compile with `-d:nphBookExamples` to regenerate them +# for the book + +proc function(par0: SomeType): bool = + discard + +proc function(par0: SomeType, par1: SomeType): bool = + discard + +proc function( + par0: SomeType, par1, par2: SomeOtherType, par3 = default(SomeType) +): bool {.inline.} = + discard + +import dir/module + +const v = [1, 2, 3] + +type T = proc(a, b: int) + +import dir/[module1, module2, module3, module4] + +const mylongvariablename = [100000000, 200000000, 300000000] + +proc function(param0: int, param1: int, param2: int) + +import + dir/[module1, module2, module3], + dir2/[module4, module5, module6, module7, module8, module9] + +let myVariable = [functionCall(a, b, c), functionCall(a, b, c, d)] + +functionCall(functionCall(a, b, c), functionCall(a, b, c, d)) + +const values = [10000000, 2000000000, 3000000000, 40000000, 5000000000] + +functionCall(10000000, 2000000000, 3000000000, 40000000, 5000000000) + +proc f( + myParameter = 0, + callback: SomeCallback = proc() = + discard + , + nextParameter = 1, +) + +let myvariable = shortexpression(abc) + +let myvariable = someevenlongerexpression(abc, def) + +let myvariable = someevenlongerexpression(aaa, bbb, ccc, ddd) + +return + if condition: + complex(call) + else: + alsocomplex(call) diff --git a/tests/after/style.nim.nph.yaml b/tests/after/style.nim.nph.yaml new file mode 100644 index 0000000..98b3896 --- /dev/null +++ b/tests/after/style.nim.nph.yaml @@ -0,0 +1,467 @@ +kind: "nkStmtList" +sons: + - kind: "nkCommentStmt" + "comment": "# Style examples - compile with `-d:nphBookExamples` to regenerate them" + - kind: "nkCommentStmt" + "comment": "# for the book" + - kind: "nkProcDef" + sons: + - kind: "nkIdent" + ident: "function" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkFormalParams" + sons: + - kind: "nkIdent" + ident: "bool" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "par0" + - kind: "nkIdent" + ident: "SomeType" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkStmtList" + sons: + - kind: "nkDiscardStmt" + sons: + - kind: "nkEmpty" + - kind: "nkProcDef" + sons: + - kind: "nkIdent" + ident: "function" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkFormalParams" + sons: + - kind: "nkIdent" + ident: "bool" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "par0" + - kind: "nkIdent" + ident: "SomeType" + - kind: "nkEmpty" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "par1" + - kind: "nkIdent" + ident: "SomeType" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkStmtList" + sons: + - kind: "nkDiscardStmt" + sons: + - kind: "nkEmpty" + - kind: "nkProcDef" + sons: + - kind: "nkIdent" + ident: "function" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkFormalParams" + sons: + - kind: "nkIdent" + ident: "bool" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "par0" + - kind: "nkIdent" + ident: "SomeType" + - kind: "nkEmpty" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "par1" + - kind: "nkIdent" + ident: "par2" + - kind: "nkIdent" + ident: "SomeOtherType" + - kind: "nkEmpty" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "par3" + - kind: "nkEmpty" + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "default" + - kind: "nkIdent" + ident: "SomeType" + - kind: "nkPragma" + sons: + - kind: "nkIdent" + ident: "inline" + - kind: "nkEmpty" + - kind: "nkStmtList" + sons: + - kind: "nkDiscardStmt" + sons: + - kind: "nkEmpty" + - kind: "nkImportStmt" + sons: + - kind: "nkInfix" + sons: + - kind: "nkIdent" + ident: "/" + - kind: "nkIdent" + ident: "dir" + - kind: "nkIdent" + ident: "module" + - kind: "nkConstSection" + sons: + - kind: "nkConstDef" + sons: + - kind: "nkIdent" + ident: "v" + - kind: "nkEmpty" + - kind: "nkBracket" + sons: + - kind: "nkIntLit" + intVal: 1 + - kind: "nkIntLit" + intVal: 2 + - kind: "nkIntLit" + intVal: 3 + - kind: "nkTypeSection" + sons: + - kind: "nkTypeDef" + sons: + - kind: "nkIdent" + ident: "T" + - kind: "nkEmpty" + - kind: "nkProcTy" + sons: + - kind: "nkFormalParams" + sons: + - kind: "nkEmpty" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "a" + - kind: "nkIdent" + ident: "b" + - kind: "nkIdent" + ident: "int" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkImportStmt" + sons: + - kind: "nkInfix" + sons: + - kind: "nkIdent" + ident: "/" + - kind: "nkIdent" + ident: "dir" + - kind: "nkBracket" + sons: + - kind: "nkIdent" + ident: "module1" + - kind: "nkIdent" + ident: "module2" + - kind: "nkIdent" + ident: "module3" + - kind: "nkIdent" + ident: "module4" + - kind: "nkConstSection" + sons: + - kind: "nkConstDef" + sons: + - kind: "nkIdent" + ident: "mylongvariablename" + - kind: "nkEmpty" + - kind: "nkBracket" + sons: + - kind: "nkIntLit" + intVal: 100000000 + - kind: "nkIntLit" + intVal: 200000000 + - kind: "nkIntLit" + intVal: 300000000 + - kind: "nkProcDef" + sons: + - kind: "nkIdent" + ident: "function" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkFormalParams" + sons: + - kind: "nkEmpty" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "param0" + - kind: "nkIdent" + ident: "int" + - kind: "nkEmpty" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "param1" + - kind: "nkIdent" + ident: "int" + - kind: "nkEmpty" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "param2" + - kind: "nkIdent" + ident: "int" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkImportStmt" + sons: + - kind: "nkInfix" + sons: + - kind: "nkIdent" + ident: "/" + - kind: "nkIdent" + ident: "dir" + - kind: "nkBracket" + sons: + - kind: "nkIdent" + ident: "module1" + - kind: "nkIdent" + ident: "module2" + - kind: "nkIdent" + ident: "module3" + - kind: "nkInfix" + sons: + - kind: "nkIdent" + ident: "/" + - kind: "nkIdent" + ident: "dir2" + - kind: "nkBracket" + sons: + - kind: "nkIdent" + ident: "module4" + - kind: "nkIdent" + ident: "module5" + - kind: "nkIdent" + ident: "module6" + - kind: "nkIdent" + ident: "module7" + - kind: "nkIdent" + ident: "module8" + - kind: "nkIdent" + ident: "module9" + - kind: "nkLetSection" + sons: + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "myVariable" + - kind: "nkEmpty" + - kind: "nkBracket" + sons: + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "functionCall" + - kind: "nkIdent" + ident: "a" + - kind: "nkIdent" + ident: "b" + - kind: "nkIdent" + ident: "c" + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "functionCall" + - kind: "nkIdent" + ident: "a" + - kind: "nkIdent" + ident: "b" + - kind: "nkIdent" + ident: "c" + - kind: "nkIdent" + ident: "d" + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "functionCall" + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "functionCall" + - kind: "nkIdent" + ident: "a" + - kind: "nkIdent" + ident: "b" + - kind: "nkIdent" + ident: "c" + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "functionCall" + - kind: "nkIdent" + ident: "a" + - kind: "nkIdent" + ident: "b" + - kind: "nkIdent" + ident: "c" + - kind: "nkIdent" + ident: "d" + - kind: "nkConstSection" + sons: + - kind: "nkConstDef" + sons: + - kind: "nkIdent" + ident: "values" + - kind: "nkEmpty" + - kind: "nkBracket" + sons: + - kind: "nkIntLit" + intVal: 10000000 + - kind: "nkIntLit" + intVal: 2000000000 + - kind: "nkInt64Lit" + intVal: 3000000000 + - kind: "nkIntLit" + intVal: 40000000 + - kind: "nkInt64Lit" + intVal: 5000000000 + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "functionCall" + - kind: "nkIntLit" + intVal: 10000000 + - kind: "nkIntLit" + intVal: 2000000000 + - kind: "nkInt64Lit" + intVal: 3000000000 + - kind: "nkIntLit" + intVal: 40000000 + - kind: "nkInt64Lit" + intVal: 5000000000 + - kind: "nkProcDef" + sons: + - kind: "nkIdent" + ident: "f" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkFormalParams" + sons: + - kind: "nkEmpty" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "myParameter" + - kind: "nkEmpty" + - kind: "nkIntLit" + intVal: 0 + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "callback" + - kind: "nkIdent" + ident: "SomeCallback" + - kind: "nkLambda" + sons: + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkFormalParams" + sons: + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkStmtList" + sons: + - kind: "nkDiscardStmt" + sons: + - kind: "nkEmpty" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "nextParameter" + - kind: "nkEmpty" + - kind: "nkIntLit" + intVal: 1 + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkLetSection" + sons: + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "myvariable" + - kind: "nkEmpty" + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "shortexpression" + - kind: "nkIdent" + ident: "abc" + - kind: "nkLetSection" + sons: + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "myvariable" + - kind: "nkEmpty" + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "someevenlongerexpression" + - kind: "nkIdent" + ident: "abc" + - kind: "nkIdent" + ident: "def" + - kind: "nkLetSection" + sons: + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "myvariable" + - kind: "nkEmpty" + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "someevenlongerexpression" + - kind: "nkIdent" + ident: "aaa" + - kind: "nkIdent" + ident: "bbb" + - kind: "nkIdent" + ident: "ccc" + - kind: "nkIdent" + ident: "ddd" + - kind: "nkReturnStmt" + sons: + - kind: "nkIfExpr" + sons: + - kind: "nkElifExpr" + sons: + - kind: "nkIdent" + ident: "condition" + - kind: "nkStmtList" + sons: + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "complex" + - kind: "nkIdent" + ident: "call" + - kind: "nkElseExpr" + sons: + - kind: "nkStmtList" + sons: + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "alsocomplex" + - kind: "nkIdent" + ident: "call" diff --git a/tests/before/style.nim b/tests/before/style.nim new file mode 100644 index 0000000..b80e26f --- /dev/null +++ b/tests/before/style.nim @@ -0,0 +1,82 @@ +# Style examples - compile with `-d:nphBookExamples` to regenerate them +# for the book + +proc function(par0: SomeType): bool = + discard + +proc function( + par0: SomeType, par1: SomeType, +): bool = + discard + +proc function( + par0: SomeType, par1, par2: SomeOtherType, par3 = default(SomeType) +): bool {.inline.} = + discard + +import dir/module + +const v = [1, 2, 3] + +type T = proc(a, b: int) + +import + dir/[module1, module2, module3, module4] + +const mylongvariablename = + [100000000, 200000000, 300000000] + +proc function( + param0: int, param1: int, param2: int +) + +import + dir/[module1, module2, module3], + dir2/[ + module4, module5, module6, module7, module8, + module9 + ] + +let myVariable = [ + functionCall(a, b, c), + functionCall(a, b, c, d), +] + +functionCall( + functionCall(a, b, c), + functionCall(a, b, c, d), +) + +const values = [ + 10000000, 2000000000, 3000000000, + 40000000, 5000000000 +] + +functionCall( + 10000000, 2000000000, 3000000000, + 40000000, 5000000000 +) + +proc f( + myParameter = 0, + callback: SomeCallback = + proc() = + discard + , + nextParameter = 1, +) + +let myvariable = shortexpression(abc) + +let myvariable = + someevenlongerexpression(abc, def) + +let myvariable = someevenlongerexpression( + aaa, bbb, ccc, ddd +) + +return + if condition: + complex(call) + else: + alsocomplex(call) diff --git a/tests/before/style.nim.nph.yaml b/tests/before/style.nim.nph.yaml new file mode 100644 index 0000000..98b3896 --- /dev/null +++ b/tests/before/style.nim.nph.yaml @@ -0,0 +1,467 @@ +kind: "nkStmtList" +sons: + - kind: "nkCommentStmt" + "comment": "# Style examples - compile with `-d:nphBookExamples` to regenerate them" + - kind: "nkCommentStmt" + "comment": "# for the book" + - kind: "nkProcDef" + sons: + - kind: "nkIdent" + ident: "function" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkFormalParams" + sons: + - kind: "nkIdent" + ident: "bool" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "par0" + - kind: "nkIdent" + ident: "SomeType" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkStmtList" + sons: + - kind: "nkDiscardStmt" + sons: + - kind: "nkEmpty" + - kind: "nkProcDef" + sons: + - kind: "nkIdent" + ident: "function" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkFormalParams" + sons: + - kind: "nkIdent" + ident: "bool" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "par0" + - kind: "nkIdent" + ident: "SomeType" + - kind: "nkEmpty" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "par1" + - kind: "nkIdent" + ident: "SomeType" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkStmtList" + sons: + - kind: "nkDiscardStmt" + sons: + - kind: "nkEmpty" + - kind: "nkProcDef" + sons: + - kind: "nkIdent" + ident: "function" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkFormalParams" + sons: + - kind: "nkIdent" + ident: "bool" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "par0" + - kind: "nkIdent" + ident: "SomeType" + - kind: "nkEmpty" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "par1" + - kind: "nkIdent" + ident: "par2" + - kind: "nkIdent" + ident: "SomeOtherType" + - kind: "nkEmpty" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "par3" + - kind: "nkEmpty" + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "default" + - kind: "nkIdent" + ident: "SomeType" + - kind: "nkPragma" + sons: + - kind: "nkIdent" + ident: "inline" + - kind: "nkEmpty" + - kind: "nkStmtList" + sons: + - kind: "nkDiscardStmt" + sons: + - kind: "nkEmpty" + - kind: "nkImportStmt" + sons: + - kind: "nkInfix" + sons: + - kind: "nkIdent" + ident: "/" + - kind: "nkIdent" + ident: "dir" + - kind: "nkIdent" + ident: "module" + - kind: "nkConstSection" + sons: + - kind: "nkConstDef" + sons: + - kind: "nkIdent" + ident: "v" + - kind: "nkEmpty" + - kind: "nkBracket" + sons: + - kind: "nkIntLit" + intVal: 1 + - kind: "nkIntLit" + intVal: 2 + - kind: "nkIntLit" + intVal: 3 + - kind: "nkTypeSection" + sons: + - kind: "nkTypeDef" + sons: + - kind: "nkIdent" + ident: "T" + - kind: "nkEmpty" + - kind: "nkProcTy" + sons: + - kind: "nkFormalParams" + sons: + - kind: "nkEmpty" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "a" + - kind: "nkIdent" + ident: "b" + - kind: "nkIdent" + ident: "int" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkImportStmt" + sons: + - kind: "nkInfix" + sons: + - kind: "nkIdent" + ident: "/" + - kind: "nkIdent" + ident: "dir" + - kind: "nkBracket" + sons: + - kind: "nkIdent" + ident: "module1" + - kind: "nkIdent" + ident: "module2" + - kind: "nkIdent" + ident: "module3" + - kind: "nkIdent" + ident: "module4" + - kind: "nkConstSection" + sons: + - kind: "nkConstDef" + sons: + - kind: "nkIdent" + ident: "mylongvariablename" + - kind: "nkEmpty" + - kind: "nkBracket" + sons: + - kind: "nkIntLit" + intVal: 100000000 + - kind: "nkIntLit" + intVal: 200000000 + - kind: "nkIntLit" + intVal: 300000000 + - kind: "nkProcDef" + sons: + - kind: "nkIdent" + ident: "function" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkFormalParams" + sons: + - kind: "nkEmpty" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "param0" + - kind: "nkIdent" + ident: "int" + - kind: "nkEmpty" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "param1" + - kind: "nkIdent" + ident: "int" + - kind: "nkEmpty" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "param2" + - kind: "nkIdent" + ident: "int" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkImportStmt" + sons: + - kind: "nkInfix" + sons: + - kind: "nkIdent" + ident: "/" + - kind: "nkIdent" + ident: "dir" + - kind: "nkBracket" + sons: + - kind: "nkIdent" + ident: "module1" + - kind: "nkIdent" + ident: "module2" + - kind: "nkIdent" + ident: "module3" + - kind: "nkInfix" + sons: + - kind: "nkIdent" + ident: "/" + - kind: "nkIdent" + ident: "dir2" + - kind: "nkBracket" + sons: + - kind: "nkIdent" + ident: "module4" + - kind: "nkIdent" + ident: "module5" + - kind: "nkIdent" + ident: "module6" + - kind: "nkIdent" + ident: "module7" + - kind: "nkIdent" + ident: "module8" + - kind: "nkIdent" + ident: "module9" + - kind: "nkLetSection" + sons: + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "myVariable" + - kind: "nkEmpty" + - kind: "nkBracket" + sons: + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "functionCall" + - kind: "nkIdent" + ident: "a" + - kind: "nkIdent" + ident: "b" + - kind: "nkIdent" + ident: "c" + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "functionCall" + - kind: "nkIdent" + ident: "a" + - kind: "nkIdent" + ident: "b" + - kind: "nkIdent" + ident: "c" + - kind: "nkIdent" + ident: "d" + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "functionCall" + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "functionCall" + - kind: "nkIdent" + ident: "a" + - kind: "nkIdent" + ident: "b" + - kind: "nkIdent" + ident: "c" + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "functionCall" + - kind: "nkIdent" + ident: "a" + - kind: "nkIdent" + ident: "b" + - kind: "nkIdent" + ident: "c" + - kind: "nkIdent" + ident: "d" + - kind: "nkConstSection" + sons: + - kind: "nkConstDef" + sons: + - kind: "nkIdent" + ident: "values" + - kind: "nkEmpty" + - kind: "nkBracket" + sons: + - kind: "nkIntLit" + intVal: 10000000 + - kind: "nkIntLit" + intVal: 2000000000 + - kind: "nkInt64Lit" + intVal: 3000000000 + - kind: "nkIntLit" + intVal: 40000000 + - kind: "nkInt64Lit" + intVal: 5000000000 + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "functionCall" + - kind: "nkIntLit" + intVal: 10000000 + - kind: "nkIntLit" + intVal: 2000000000 + - kind: "nkInt64Lit" + intVal: 3000000000 + - kind: "nkIntLit" + intVal: 40000000 + - kind: "nkInt64Lit" + intVal: 5000000000 + - kind: "nkProcDef" + sons: + - kind: "nkIdent" + ident: "f" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkFormalParams" + sons: + - kind: "nkEmpty" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "myParameter" + - kind: "nkEmpty" + - kind: "nkIntLit" + intVal: 0 + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "callback" + - kind: "nkIdent" + ident: "SomeCallback" + - kind: "nkLambda" + sons: + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkFormalParams" + sons: + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkStmtList" + sons: + - kind: "nkDiscardStmt" + sons: + - kind: "nkEmpty" + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "nextParameter" + - kind: "nkEmpty" + - kind: "nkIntLit" + intVal: 1 + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkEmpty" + - kind: "nkLetSection" + sons: + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "myvariable" + - kind: "nkEmpty" + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "shortexpression" + - kind: "nkIdent" + ident: "abc" + - kind: "nkLetSection" + sons: + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "myvariable" + - kind: "nkEmpty" + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "someevenlongerexpression" + - kind: "nkIdent" + ident: "abc" + - kind: "nkIdent" + ident: "def" + - kind: "nkLetSection" + sons: + - kind: "nkIdentDefs" + sons: + - kind: "nkIdent" + ident: "myvariable" + - kind: "nkEmpty" + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "someevenlongerexpression" + - kind: "nkIdent" + ident: "aaa" + - kind: "nkIdent" + ident: "bbb" + - kind: "nkIdent" + ident: "ccc" + - kind: "nkIdent" + ident: "ddd" + - kind: "nkReturnStmt" + sons: + - kind: "nkIfExpr" + sons: + - kind: "nkElifExpr" + sons: + - kind: "nkIdent" + ident: "condition" + - kind: "nkStmtList" + sons: + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "complex" + - kind: "nkIdent" + ident: "call" + - kind: "nkElseExpr" + sons: + - kind: "nkStmtList" + sons: + - kind: "nkCall" + sons: + - kind: "nkIdent" + ident: "alsocomplex" + - kind: "nkIdent" + ident: "call"