From 6517621b2457a801a3db4445a6a6e0bdf5254fc4 Mon Sep 17 00:00:00 2001 From: Nik Silver Date: Sat, 19 Feb 2022 18:13:14 +0000 Subject: [PATCH 01/11] Elm: Rewritten using PackCC PEG parser. --- Units/parser-elm.r/elm-aliases.d/args.ctags | 2 + .../parser-elm.r/elm-aliases.d/expected.tags | 3 + Units/parser-elm.r/elm-aliases.d/input.elm | 11 + Units/parser-elm.r/elm-bad-lines.d/args.ctags | 3 + .../elm-bad-lines.d/expected.tags | 8 + .../parser-elm.r/elm-bad-lines.d/input-1.elm | 8 + .../parser-elm.r/elm-bad-lines.d/input-2.elm | 9 + .../parser-elm.r/elm-bad-lines.d/input-3.elm | 13 + Units/parser-elm.r/elm-bad-lines.d/input.elm | 3 + .../elm-case-statements.d/args.ctags | 3 + .../elm-case-statements.d/expected.tags | 6 + .../elm-case-statements.d/input.elm | 43 + Units/parser-elm.r/elm-comments.d/args.ctags | 3 + .../parser-elm.r/elm-comments.d/expected.tags | 2 + Units/parser-elm.r/elm-comments.d/input.elm | 31 + .../elm-complex-types.d/args.ctags | 3 + .../elm-complex-types.d/expected.tags | 20 + .../elm-complex-types.d/input.elm | 40 + .../elm-constructor-signatures.d/args.ctags | 3 + .../expected.tags | 4 + .../elm-constructor-signatures.d/input.elm | 7 + .../parser-elm.r/elm-expressions.d/args.ctags | 3 + .../elm-expressions.d/expected.tags | 13 + .../parser-elm.r/elm-expressions.d/input.elm | 60 + Units/parser-elm.r/elm-functions.d/args.ctags | 3 + .../elm-functions.d/expected.tags | 5 + Units/parser-elm.r/elm-functions.d/input.elm | 22 + .../elm-if-then-else.d/args.ctags | 3 + .../elm-if-then-else.d/expected.tags | 5 + .../parser-elm.r/elm-if-then-else.d/input.elm | 31 + Units/parser-elm.r/elm-imports.d/args.ctags | 3 + .../parser-elm.r/elm-imports.d/expected.tags | 23 + Units/parser-elm.r/elm-imports.d/input-1.elm | 3 + Units/parser-elm.r/elm-imports.d/input.elm | 21 + .../elm-just-comments.d/expected.tags | 0 .../elm-just-comments.d/input.elm | 21 + Units/parser-elm.r/elm-let-in.d/args.ctags | 3 + Units/parser-elm.r/elm-let-in.d/expected.tags | 12 + Units/parser-elm.r/elm-let-in.d/input.elm | 40 + Units/parser-elm.r/elm-modules.d/args.ctags | 3 + .../parser-elm.r/elm-modules.d/expected.tags | 11 + Units/parser-elm.r/elm-modules.d/input-1.elm | 7 + Units/parser-elm.r/elm-modules.d/input-2.elm | 14 + Units/parser-elm.r/elm-modules.d/input-3.elm | 8 + Units/parser-elm.r/elm-modules.d/input-4.elm | 3 + Units/parser-elm.r/elm-modules.d/input-5.elm | 3 + Units/parser-elm.r/elm-modules.d/input.elm | 4 + .../elm-multiline-strings.d/args.ctags | 3 + .../elm-multiline-strings.d/expected.tags | 3 + .../elm-multiline-strings.d/input.elm | 17 + .../parser-elm.r/elm-namespaces.d/args.ctags | 3 + .../elm-namespaces.d/expected.tags | 5 + Units/parser-elm.r/elm-namespaces.d/input.elm | 6 + .../elm-optlist-compatibility.d/README.md | 4 + .../elm-optlist-compatibility.d}/args.ctags | 0 .../elm-optlist-compatibility.d/expected.tags | 18 + .../elm-optlist-compatibility.d}/input.elm | 0 .../elm-parameter-patterns.d/args.ctags | 3 + .../elm-parameter-patterns.d/expected.tags | 7 + .../elm-parameter-patterns.d/input.elm | 36 + Units/parser-elm.r/elm-ports.d/args.ctags | 3 + Units/parser-elm.r/elm-ports.d/expected.tags | 3 + Units/parser-elm.r/elm-ports.d/input.elm | 6 + .../parser-elm.r/elm-signatures.d/args.ctags | 3 + .../elm-signatures.d/expected.tags | 9 + Units/parser-elm.r/elm-signatures.d/input.elm | 49 + .../elm-single-expressions.d/args.ctags | 3 + .../elm-single-expressions.d/expected.tags | 9 + .../elm-single-expressions.d/input.elm | 50 + Units/parser-elm.r/elm-types.d/args.ctags | 3 + Units/parser-elm.r/elm-types.d/expected.tags | 20 + Units/parser-elm.r/elm-types.d/input-1.elm | 9 + Units/parser-elm.r/elm-types.d/input.elm | 13 + Units/simple-elm.d/expected.tags | 16 - docs/man-pages.rst | 1 + docs/man/ctags-lang-elm.7.rst | 129 + docs/news.rst | 2 +- main/parsers_p.h | 4 +- man/Makefile.am | 1 + man/ctags-lang-elm.7.rst.in | 129 + mk_mvc.mak | 1 + optlib/elm.c | 96 - optlib/elm.ctags | 45 - peg/.gitignore | 1 + peg/elm.c | 6760 +++++++++++++++++ peg/elm.h | 22 + peg/elm.peg | 622 ++ peg/elm_post.h | 155 + peg/elm_pre.h | 102 + source.mak | 2 +- win32/ctags_vs2013.vcxproj | 3 +- win32/ctags_vs2013.vcxproj.filters | 5 +- 92 files changed, 8763 insertions(+), 167 deletions(-) create mode 100644 Units/parser-elm.r/elm-aliases.d/args.ctags create mode 100644 Units/parser-elm.r/elm-aliases.d/expected.tags create mode 100644 Units/parser-elm.r/elm-aliases.d/input.elm create mode 100644 Units/parser-elm.r/elm-bad-lines.d/args.ctags create mode 100644 Units/parser-elm.r/elm-bad-lines.d/expected.tags create mode 100644 Units/parser-elm.r/elm-bad-lines.d/input-1.elm create mode 100644 Units/parser-elm.r/elm-bad-lines.d/input-2.elm create mode 100644 Units/parser-elm.r/elm-bad-lines.d/input-3.elm create mode 100644 Units/parser-elm.r/elm-bad-lines.d/input.elm create mode 100644 Units/parser-elm.r/elm-case-statements.d/args.ctags create mode 100644 Units/parser-elm.r/elm-case-statements.d/expected.tags create mode 100644 Units/parser-elm.r/elm-case-statements.d/input.elm create mode 100644 Units/parser-elm.r/elm-comments.d/args.ctags create mode 100644 Units/parser-elm.r/elm-comments.d/expected.tags create mode 100644 Units/parser-elm.r/elm-comments.d/input.elm create mode 100644 Units/parser-elm.r/elm-complex-types.d/args.ctags create mode 100644 Units/parser-elm.r/elm-complex-types.d/expected.tags create mode 100644 Units/parser-elm.r/elm-complex-types.d/input.elm create mode 100644 Units/parser-elm.r/elm-constructor-signatures.d/args.ctags create mode 100644 Units/parser-elm.r/elm-constructor-signatures.d/expected.tags create mode 100644 Units/parser-elm.r/elm-constructor-signatures.d/input.elm create mode 100644 Units/parser-elm.r/elm-expressions.d/args.ctags create mode 100644 Units/parser-elm.r/elm-expressions.d/expected.tags create mode 100644 Units/parser-elm.r/elm-expressions.d/input.elm create mode 100644 Units/parser-elm.r/elm-functions.d/args.ctags create mode 100644 Units/parser-elm.r/elm-functions.d/expected.tags create mode 100644 Units/parser-elm.r/elm-functions.d/input.elm create mode 100644 Units/parser-elm.r/elm-if-then-else.d/args.ctags create mode 100644 Units/parser-elm.r/elm-if-then-else.d/expected.tags create mode 100644 Units/parser-elm.r/elm-if-then-else.d/input.elm create mode 100644 Units/parser-elm.r/elm-imports.d/args.ctags create mode 100644 Units/parser-elm.r/elm-imports.d/expected.tags create mode 100644 Units/parser-elm.r/elm-imports.d/input-1.elm create mode 100644 Units/parser-elm.r/elm-imports.d/input.elm create mode 100644 Units/parser-elm.r/elm-just-comments.d/expected.tags create mode 100644 Units/parser-elm.r/elm-just-comments.d/input.elm create mode 100644 Units/parser-elm.r/elm-let-in.d/args.ctags create mode 100644 Units/parser-elm.r/elm-let-in.d/expected.tags create mode 100644 Units/parser-elm.r/elm-let-in.d/input.elm create mode 100644 Units/parser-elm.r/elm-modules.d/args.ctags create mode 100644 Units/parser-elm.r/elm-modules.d/expected.tags create mode 100644 Units/parser-elm.r/elm-modules.d/input-1.elm create mode 100644 Units/parser-elm.r/elm-modules.d/input-2.elm create mode 100644 Units/parser-elm.r/elm-modules.d/input-3.elm create mode 100644 Units/parser-elm.r/elm-modules.d/input-4.elm create mode 100644 Units/parser-elm.r/elm-modules.d/input-5.elm create mode 100644 Units/parser-elm.r/elm-modules.d/input.elm create mode 100644 Units/parser-elm.r/elm-multiline-strings.d/args.ctags create mode 100644 Units/parser-elm.r/elm-multiline-strings.d/expected.tags create mode 100644 Units/parser-elm.r/elm-multiline-strings.d/input.elm create mode 100644 Units/parser-elm.r/elm-namespaces.d/args.ctags create mode 100644 Units/parser-elm.r/elm-namespaces.d/expected.tags create mode 100644 Units/parser-elm.r/elm-namespaces.d/input.elm create mode 100644 Units/parser-elm.r/elm-optlist-compatibility.d/README.md rename Units/{simple-elm.d => parser-elm.r/elm-optlist-compatibility.d}/args.ctags (100%) create mode 100644 Units/parser-elm.r/elm-optlist-compatibility.d/expected.tags rename Units/{simple-elm.d => parser-elm.r/elm-optlist-compatibility.d}/input.elm (100%) create mode 100644 Units/parser-elm.r/elm-parameter-patterns.d/args.ctags create mode 100644 Units/parser-elm.r/elm-parameter-patterns.d/expected.tags create mode 100644 Units/parser-elm.r/elm-parameter-patterns.d/input.elm create mode 100644 Units/parser-elm.r/elm-ports.d/args.ctags create mode 100644 Units/parser-elm.r/elm-ports.d/expected.tags create mode 100644 Units/parser-elm.r/elm-ports.d/input.elm create mode 100644 Units/parser-elm.r/elm-signatures.d/args.ctags create mode 100644 Units/parser-elm.r/elm-signatures.d/expected.tags create mode 100644 Units/parser-elm.r/elm-signatures.d/input.elm create mode 100644 Units/parser-elm.r/elm-single-expressions.d/args.ctags create mode 100644 Units/parser-elm.r/elm-single-expressions.d/expected.tags create mode 100644 Units/parser-elm.r/elm-single-expressions.d/input.elm create mode 100644 Units/parser-elm.r/elm-types.d/args.ctags create mode 100644 Units/parser-elm.r/elm-types.d/expected.tags create mode 100644 Units/parser-elm.r/elm-types.d/input-1.elm create mode 100644 Units/parser-elm.r/elm-types.d/input.elm delete mode 100644 Units/simple-elm.d/expected.tags create mode 100644 docs/man/ctags-lang-elm.7.rst create mode 100644 man/ctags-lang-elm.7.rst.in delete mode 100644 optlib/elm.c delete mode 100644 optlib/elm.ctags create mode 100644 peg/elm.c create mode 100644 peg/elm.h create mode 100644 peg/elm.peg create mode 100644 peg/elm_post.h create mode 100644 peg/elm_pre.h diff --git a/Units/parser-elm.r/elm-aliases.d/args.ctags b/Units/parser-elm.r/elm-aliases.d/args.ctags new file mode 100644 index 0000000000..66c8fec799 --- /dev/null +++ b/Units/parser-elm.r/elm-aliases.d/args.ctags @@ -0,0 +1,2 @@ +--sort=no +--fields=+r diff --git a/Units/parser-elm.r/elm-aliases.d/expected.tags b/Units/parser-elm.r/elm-aliases.d/expected.tags new file mode 100644 index 0000000000..b483a30094 --- /dev/null +++ b/Units/parser-elm.r/elm-aliases.d/expected.tags @@ -0,0 +1,3 @@ +MyAlias1 input.elm /^type alias MyAlias1 = String$/;" a roles:def +MyAlias2 input.elm /^type alias MyAlias2 =$/;" a roles:def +MyAlias3 input.elm /^ MyAlias3$/;" a roles:def diff --git a/Units/parser-elm.r/elm-aliases.d/input.elm b/Units/parser-elm.r/elm-aliases.d/input.elm new file mode 100644 index 0000000000..d900981f7d --- /dev/null +++ b/Units/parser-elm.r/elm-aliases.d/input.elm @@ -0,0 +1,11 @@ +type alias MyAlias1 = String + +type alias MyAlias2 = + String + +type + alias + MyAlias3 + = + { x:Float, y:Float } + diff --git a/Units/parser-elm.r/elm-bad-lines.d/args.ctags b/Units/parser-elm.r/elm-bad-lines.d/args.ctags new file mode 100644 index 0000000000..405ad9b9ff --- /dev/null +++ b/Units/parser-elm.r/elm-bad-lines.d/args.ctags @@ -0,0 +1,3 @@ +--sort=no +--extras=+r +--fields=+rS diff --git a/Units/parser-elm.r/elm-bad-lines.d/expected.tags b/Units/parser-elm.r/elm-bad-lines.d/expected.tags new file mode 100644 index 0000000000..6e06f8bb57 --- /dev/null +++ b/Units/parser-elm.r/elm-bad-lines.d/expected.tags @@ -0,0 +1,8 @@ +Input input.elm /^import Input exposing (..)$/;" m roles:imported +input1a input-1.elm /^input1a = 1$/;" f roles:def +input1b input-1.elm /^input1b = 2$/;" f signature:Int roles:def +input2b input-2.elm /^input2b = 1$/;" f roles:def +input2c input-2.elm /^input2c = 3$/;" f roles:def +module2d input-2.elm /^module2d = 4$/;" f roles:def +input3b input-3.elm /^input3b = 1$/;" f roles:def +input3d input-3.elm /^input3d = 1$/;" f roles:def diff --git a/Units/parser-elm.r/elm-bad-lines.d/input-1.elm b/Units/parser-elm.r/elm-bad-lines.d/input-1.elm new file mode 100644 index 0000000000..2393c4b1ba --- /dev/null +++ b/Units/parser-elm.r/elm-bad-lines.d/input-1.elm @@ -0,0 +1,8 @@ +type alias Input1a *= ConsA + +input1a = 1 + +type alias Input1b *= ConsB + +input1b : Int +input1b = 2 diff --git a/Units/parser-elm.r/elm-bad-lines.d/input-2.elm b/Units/parser-elm.r/elm-bad-lines.d/input-2.elm new file mode 100644 index 0000000000..021035bda4 --- /dev/null +++ b/Units/parser-elm.r/elm-bad-lines.d/input-2.elm @@ -0,0 +1,9 @@ +type Input2a = Cons2A1 | Cons2A2 * + +input2b = 1 + +module = 2 + +input2c = 3 + +module2d = 4 diff --git a/Units/parser-elm.r/elm-bad-lines.d/input-3.elm b/Units/parser-elm.r/elm-bad-lines.d/input-3.elm new file mode 100644 index 0000000000..f0246748b4 --- /dev/null +++ b/Units/parser-elm.r/elm-bad-lines.d/input-3.elm @@ -0,0 +1,13 @@ +-- Should be able to ignore a function where only part of the body +-- parses successfully + +input3a i3_1 i3_2 = + (]? x && + +input3b = 1 + +input3c i3_1 i3_2 = + (]? x && + +input3d = 1 + diff --git a/Units/parser-elm.r/elm-bad-lines.d/input.elm b/Units/parser-elm.r/elm-bad-lines.d/input.elm new file mode 100644 index 0000000000..64f7371845 --- /dev/null +++ b/Units/parser-elm.r/elm-bad-lines.d/input.elm @@ -0,0 +1,3 @@ +import Input exposinx?* + +import Input exposing (..) diff --git a/Units/parser-elm.r/elm-case-statements.d/args.ctags b/Units/parser-elm.r/elm-case-statements.d/args.ctags new file mode 100644 index 0000000000..405ad9b9ff --- /dev/null +++ b/Units/parser-elm.r/elm-case-statements.d/args.ctags @@ -0,0 +1,3 @@ +--sort=no +--extras=+r +--fields=+rS diff --git a/Units/parser-elm.r/elm-case-statements.d/expected.tags b/Units/parser-elm.r/elm-case-statements.d/expected.tags new file mode 100644 index 0000000000..898bf660e3 --- /dev/null +++ b/Units/parser-elm.r/elm-case-statements.d/expected.tags @@ -0,0 +1,6 @@ +funcA input.elm /^funcA a1 a2 =$/;" f roles:def +funcB input.elm /^funcB b1 =$/;" f roles:def +funcC input.elm /^funcC c1 c2 =$/;" f roles:def +c2 input.elm /^ c2 = 2$/;" f function:funcC roles:def +c3 input.elm /^ c3 = 3$/;" f function:funcC roles:def +funcD input.elm /^funcD str =$/;" f roles:def diff --git a/Units/parser-elm.r/elm-case-statements.d/input.elm b/Units/parser-elm.r/elm-case-statements.d/input.elm new file mode 100644 index 0000000000..d793911444 --- /dev/null +++ b/Units/parser-elm.r/elm-case-statements.d/input.elm @@ -0,0 +1,43 @@ +-- A function with a case statement + +-- The code below won't compile, but it is +-- syntactically correct + +funcA a1 a2 = + case (complex ex pression + 12) of + "Literal" -> + a + b + 'l' -> + Cons a b + Cons a b -> + a + + b + _ -> + False + +-- Check we can still read a simple function + +funcB b1 = + True + +-- Can we catch functions defined inside case statements? + +funcC c1 c2 = + case (complex ex pression + 12) of + "Literal" -> + let + c2 = 2 + c3 = 3 + in + c2 + c3 + _ -> False + +-- This previously exposed a bug... + +funcD str = + case str of + Just c1 -> + c1 / 255 + _ -> + 0 + diff --git a/Units/parser-elm.r/elm-comments.d/args.ctags b/Units/parser-elm.r/elm-comments.d/args.ctags new file mode 100644 index 0000000000..41f6dbed62 --- /dev/null +++ b/Units/parser-elm.r/elm-comments.d/args.ctags @@ -0,0 +1,3 @@ +--sort=no +--extras=+r +--fields=+r diff --git a/Units/parser-elm.r/elm-comments.d/expected.tags b/Units/parser-elm.r/elm-comments.d/expected.tags new file mode 100644 index 0000000000..ecc5bb5045 --- /dev/null +++ b/Units/parser-elm.r/elm-comments.d/expected.tags @@ -0,0 +1,2 @@ +f input.elm /^f = 6 {- another comment -}$/;" f roles:def +h input.elm /^h = 9$/;" f roles:def diff --git a/Units/parser-elm.r/elm-comments.d/input.elm b/Units/parser-elm.r/elm-comments.d/input.elm new file mode 100644 index 0000000000..7f4aaeed93 --- /dev/null +++ b/Units/parser-elm.r/elm-comments.d/input.elm @@ -0,0 +1,31 @@ +-- a = 1 + +{- b = 2 -} + +{- +c = 3 +-} + +{-* d = 4 -} + +{-* +e = 5 + -} + +{- some comment -} +f = 6 {- another comment -} + + -- This should be ignored + +-- This next line is not top level +{- so should continue the above -} + 1 + +-- A top level statement + +h = 9 + +{- +comment + {- nested comment -} +i = 9 +-} diff --git a/Units/parser-elm.r/elm-complex-types.d/args.ctags b/Units/parser-elm.r/elm-complex-types.d/args.ctags new file mode 100644 index 0000000000..41f6dbed62 --- /dev/null +++ b/Units/parser-elm.r/elm-complex-types.d/args.ctags @@ -0,0 +1,3 @@ +--sort=no +--extras=+r +--fields=+r diff --git a/Units/parser-elm.r/elm-complex-types.d/expected.tags b/Units/parser-elm.r/elm-complex-types.d/expected.tags new file mode 100644 index 0000000000..e38d67da2a --- /dev/null +++ b/Units/parser-elm.r/elm-complex-types.d/expected.tags @@ -0,0 +1,20 @@ +A input.elm /^type A = ACons { x : Float, y : Float }$/;" t roles:def +ACons input.elm /^type A = ACons { x : Float, y : Float }$/;" c type:A roles:def +B input.elm /^type B$/;" t roles:def +B3Cons input.elm /^ | B3Cons$/;" c type:B roles:def +B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B roles:def +B1Cons input.elm /^ = B1Cons$/;" c type:B roles:def +C input.elm /^type C=CCons{x:Float,y:Float}$/;" t roles:def +CCons input.elm /^type C=CCons{x:Float,y:Float}$/;" c type:C roles:def +D input.elm /^type D = DCons (String, Float, {x:String, y:Float})$/;" t roles:def +DCons input.elm /^type D = DCons (String, Float, {x:String, y:Float})$/;" c type:D roles:def +E input.elm /^type E$/;" t roles:def +E2Cons input.elm /^ | E2Cons ()$/;" c type:E roles:def +E1Cons input.elm /^ = E1Cons {}$/;" c type:E roles:def +F input.elm /^type F$/;" t roles:def +F3Cons input.elm /^ | F3Cons$/;" c type:F roles:def +F2Cons input.elm /^ | F2Cons (Float -> String -> (String -> {x:Float, y:Float}))$/;" c type:F roles:def +F1Cons input.elm /^ = F1Cons (String -> Int)$/;" c type:F roles:def +G input.elm /^type G a$/;" t roles:def +G2Cons input.elm /^ | G2Cons { a | name : String}$/;" c type:G roles:def +G1Cons input.elm /^ = G1Cons a Int$/;" c type:G roles:def diff --git a/Units/parser-elm.r/elm-complex-types.d/input.elm b/Units/parser-elm.r/elm-complex-types.d/input.elm new file mode 100644 index 0000000000..6977858454 --- /dev/null +++ b/Units/parser-elm.r/elm-complex-types.d/input.elm @@ -0,0 +1,40 @@ +-- A type with a record spec + +type A = ACons { x : Float, y : Float } + +-- A type with more complex spec + +type B + = B1Cons + { x : Float + , y : Float + } + | B2Cons String Integer + | B3Cons + +-- With a lack of spacing + +type C=CCons{x:Float,y:Float} + +-- Tuples + +type D = DCons (String, Float, {x:String, y:Float}) + +-- Empty records and tuples + +type E + = E1Cons {} + | E2Cons () + +-- With functions as type specifications + +type F + = F1Cons (String -> Int) + | F2Cons (Float -> String -> (String -> {x:Float, y:Float})) + | F3Cons + +-- With vertical bars within the type + +type G a + = G1Cons a Int + | G2Cons { a | name : String} diff --git a/Units/parser-elm.r/elm-constructor-signatures.d/args.ctags b/Units/parser-elm.r/elm-constructor-signatures.d/args.ctags new file mode 100644 index 0000000000..405ad9b9ff --- /dev/null +++ b/Units/parser-elm.r/elm-constructor-signatures.d/args.ctags @@ -0,0 +1,3 @@ +--sort=no +--extras=+r +--fields=+rS diff --git a/Units/parser-elm.r/elm-constructor-signatures.d/expected.tags b/Units/parser-elm.r/elm-constructor-signatures.d/expected.tags new file mode 100644 index 0000000000..43edeb252a --- /dev/null +++ b/Units/parser-elm.r/elm-constructor-signatures.d/expected.tags @@ -0,0 +1,4 @@ +B input.elm /^type B$/;" t roles:def +B3Cons input.elm /^ | B3Cons$/;" c type:B signature: roles:def +B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B signature:String Integer roles:def +B1Cons input.elm /^ = B1Cons$/;" c type:B signature:{ x : Float , y : Float } roles:def diff --git a/Units/parser-elm.r/elm-constructor-signatures.d/input.elm b/Units/parser-elm.r/elm-constructor-signatures.d/input.elm new file mode 100644 index 0000000000..a5be3db21e --- /dev/null +++ b/Units/parser-elm.r/elm-constructor-signatures.d/input.elm @@ -0,0 +1,7 @@ +type B + = B1Cons + { x : Float + , y : Float + } + | B2Cons String Integer + | B3Cons diff --git a/Units/parser-elm.r/elm-expressions.d/args.ctags b/Units/parser-elm.r/elm-expressions.d/args.ctags new file mode 100644 index 0000000000..405ad9b9ff --- /dev/null +++ b/Units/parser-elm.r/elm-expressions.d/args.ctags @@ -0,0 +1,3 @@ +--sort=no +--extras=+r +--fields=+rS diff --git a/Units/parser-elm.r/elm-expressions.d/expected.tags b/Units/parser-elm.r/elm-expressions.d/expected.tags new file mode 100644 index 0000000000..ebbfaef48a --- /dev/null +++ b/Units/parser-elm.r/elm-expressions.d/expected.tags @@ -0,0 +1,13 @@ +funcA input.elm /^funcA =$/;" f roles:def +funcB input.elm /^funcB = (\\b1 b2 b3 -> 42)$/;" f roles:def +funcC input.elm /^funcC =$/;" f roles:def +funcD input.elm /^funcD =$/;" f roles:def +funcE input.elm /^funcE e1 e2 =$/;" f roles:def +funcF input.elm /^funcF = []$/;" f roles:def +funcG input.elm /^funcG =$/;" f roles:def +funcH input.elm /^funcH h =$/;" f roles:def +funcI input.elm /^funcI i1 i2 =$/;" f roles:def +funcJ1 input.elm /^funcJ1 =$/;" f roles:def +funcJ2 input.elm /^funcJ2 =$/;" f roles:def +funcJ3 input.elm /^funcJ3 =$/;" f roles:def +funcJ4 input.elm /^funcJ4 =$/;" f roles:def diff --git a/Units/parser-elm.r/elm-expressions.d/input.elm b/Units/parser-elm.r/elm-expressions.d/input.elm new file mode 100644 index 0000000000..f489d1a64c --- /dev/null +++ b/Units/parser-elm.r/elm-expressions.d/input.elm @@ -0,0 +1,60 @@ +-- Expressions with parentheses + +funcA = + (23 + 34) + +-- Anonymous functions + +funcB = (\b1 b2 b3 -> 42) + +-- Allow us to call constructors as functions + +funcC = + Cons a b + +-- Allow us to functions and constructors using their module names + +funcD = + (List.Deep.Cons a b) + (Main.add a b) + +-- Basic lists + +funcE e1 e2 = + e1 :: [e2, e1 + e2] + +-- Empty lists + +funcF = [] + +-- Tuples, including an empty tuple + +funcG = + (12, 0x034, ('a')) ++ () + +-- Record names as function calls + +funcH h = + (3) + (.age h.family.person) + +-- Binary operators as function calls + +funcI i1 i2 = + (++) (i1 // i2) 99 + +-- Records + +funcJ1 = + {x = 2 , y = 3 , z = 4} + +funcJ2 = + { point | x = point.x + 1 , y = Cons a b } + +funcJ3 = + {} + +-- Record with spaces + +funcJ4 = + { model + | width = width + } diff --git a/Units/parser-elm.r/elm-functions.d/args.ctags b/Units/parser-elm.r/elm-functions.d/args.ctags new file mode 100644 index 0000000000..405ad9b9ff --- /dev/null +++ b/Units/parser-elm.r/elm-functions.d/args.ctags @@ -0,0 +1,3 @@ +--sort=no +--extras=+r +--fields=+rS diff --git a/Units/parser-elm.r/elm-functions.d/expected.tags b/Units/parser-elm.r/elm-functions.d/expected.tags new file mode 100644 index 0000000000..e34fb407b2 --- /dev/null +++ b/Units/parser-elm.r/elm-functions.d/expected.tags @@ -0,0 +1,5 @@ +funcA input.elm /^funcA a1 a2 = a1 + a2$/;" f roles:def +funcB input.elm /^funcB b =$/;" f roles:def +funcC input.elm /^funcC = 2 + 1$/;" f roles:def +funcD input.elm /^funcD d1$/;" f roles:def +funcE input.elm /^funcE=2$/;" f roles:def diff --git a/Units/parser-elm.r/elm-functions.d/input.elm b/Units/parser-elm.r/elm-functions.d/input.elm new file mode 100644 index 0000000000..513647165b --- /dev/null +++ b/Units/parser-elm.r/elm-functions.d/input.elm @@ -0,0 +1,22 @@ +-- Simple function with some parameters. + +funcA a1 a2 = a1 + a2 + +-- Function over multiple lines + +funcB b = + b + 1 + +-- Function with no parameter + +funcC = 2 + 1 + +-- Function with whitespace - ideally this will be stripped in the signature + +funcD d1 + d2 = d1 + d2 + +-- Function with no whitespace after the name + +funcE=2 + diff --git a/Units/parser-elm.r/elm-if-then-else.d/args.ctags b/Units/parser-elm.r/elm-if-then-else.d/args.ctags new file mode 100644 index 0000000000..405ad9b9ff --- /dev/null +++ b/Units/parser-elm.r/elm-if-then-else.d/args.ctags @@ -0,0 +1,3 @@ +--sort=no +--extras=+r +--fields=+rS diff --git a/Units/parser-elm.r/elm-if-then-else.d/expected.tags b/Units/parser-elm.r/elm-if-then-else.d/expected.tags new file mode 100644 index 0000000000..a45ae2d0c6 --- /dev/null +++ b/Units/parser-elm.r/elm-if-then-else.d/expected.tags @@ -0,0 +1,5 @@ +funcA input.elm /^funcA a1 a2 =$/;" f roles:def +funcB input.elm /^funcB b1 =$/;" f roles:def +funcC input.elm /^funcC c1 c2 =$/;" f roles:def +c2 input.elm /^ c2 = 2$/;" f function:funcC roles:def +c3 input.elm /^ c3 = 3$/;" f function:funcC roles:def diff --git a/Units/parser-elm.r/elm-if-then-else.d/input.elm b/Units/parser-elm.r/elm-if-then-else.d/input.elm new file mode 100644 index 0000000000..9178a59843 --- /dev/null +++ b/Units/parser-elm.r/elm-if-then-else.d/input.elm @@ -0,0 +1,31 @@ +-- A function with an if/then/else statement + +-- The code below won't compile, but it is +-- syntactically correct + +funcA a1 a2 = + if (complex ex pression + 12) == "Literal" + then + a + b + else + a + + b + +-- Check we can still read a simple function? + +funcB b1 = + True + +-- Can we catch functions defined inside if statements? + +funcC c1 c2 = + if (complex ex pression + 12) == "Literal" + then + let + c2 = 2 + c3 = 3 + in + c2 + c3 + else + a + + b diff --git a/Units/parser-elm.r/elm-imports.d/args.ctags b/Units/parser-elm.r/elm-imports.d/args.ctags new file mode 100644 index 0000000000..41f6dbed62 --- /dev/null +++ b/Units/parser-elm.r/elm-imports.d/args.ctags @@ -0,0 +1,3 @@ +--sort=no +--extras=+r +--fields=+r diff --git a/Units/parser-elm.r/elm-imports.d/expected.tags b/Units/parser-elm.r/elm-imports.d/expected.tags new file mode 100644 index 0000000000..1f2d61ee28 --- /dev/null +++ b/Units/parser-elm.r/elm-imports.d/expected.tags @@ -0,0 +1,23 @@ +SomeMod input.elm /^module SomeMod exposing (..)$/;" m roles:def +PlainImport input.elm /^import PlainImport$/;" m roles:imported +MyMod input.elm /^import MyMod exposing$/;" m roles:imported +map input.elm /^ ( map, foldl$/;" f module:MyMod roles:imported +foldl input.elm /^ ( map, foldl$/;" f module:MyMod roles:imported +Maybe input.elm /^ , Maybe, Possibly$/;" t module:MyMod roles:imported +Possibly input.elm /^ , Maybe, Possibly$/;" t module:MyMod roles:imported +Result input.elm /^ , Result(..)$/;" t module:MyMod roles:imported +MyList input.elm /^ , MyList(Empty), Tree(Node, Value, Special) )$/;" t module:MyMod roles:imported +Empty input.elm /^ , MyList(Empty), Tree(Node, Value, Special) )$/;" c type:MyMod.MyList roles:imported +Tree input.elm /^ , MyList(Empty), Tree(Node, Value, Special) )$/;" t module:MyMod roles:imported +Node input.elm /^ , MyList(Empty), Tree(Node, Value, Special) )$/;" c type:MyMod.Tree roles:imported +Value input.elm /^ , MyList(Empty), Tree(Node, Value, Special) )$/;" c type:MyMod.Tree roles:imported +Special input.elm /^ , MyList(Empty), Tree(Node, Value, Special) )$/;" c type:MyMod.Tree roles:imported +otherMod input.elm /^import otherMod exposing (Coin)$/;" m roles:imported +Coin input.elm /^import otherMod exposing (Coin)$/;" t module:otherMod roles:imported +Dotted.name.Here input.elm /^import Dotted.name.Here exposing (Dot(Cons))$/;" m roles:imported +Dot input.elm /^import Dotted.name.Here exposing (Dot(Cons))$/;" t module:Dotted.name.Here roles:imported +Cons input.elm /^import Dotted.name.Here exposing (Dot(Cons))$/;" c type:Dotted.name.Here.Dot roles:imported +func input.elm /^func x =$/;" f module:SomeMod roles:def +String input-1.elm /^import String$/;" m roles:imported +A input-1.elm /^type A = B$/;" t roles:def +B input-1.elm /^type A = B$/;" c type:A roles:def diff --git a/Units/parser-elm.r/elm-imports.d/input-1.elm b/Units/parser-elm.r/elm-imports.d/input-1.elm new file mode 100644 index 0000000000..27c2d745f5 --- /dev/null +++ b/Units/parser-elm.r/elm-imports.d/input-1.elm @@ -0,0 +1,3 @@ +import String + +type A = B diff --git a/Units/parser-elm.r/elm-imports.d/input.elm b/Units/parser-elm.r/elm-imports.d/input.elm new file mode 100644 index 0000000000..3f04ecf72d --- /dev/null +++ b/Units/parser-elm.r/elm-imports.d/input.elm @@ -0,0 +1,21 @@ +module SomeMod exposing (..) + +import PlainImport + +import MyMod exposing + ( map, foldl + , Maybe, Possibly + , Result(..) + , MyList(Empty), Tree(Node, Value, Special) ) + +-- Allow a bit of looseness in module naming, even though the +-- compiler will reject it + +import otherMod exposing (Coin) + +-- Allow a dotted module name + +import Dotted.name.Here exposing (Dot(Cons)) + +func x = + 42 + 24 diff --git a/Units/parser-elm.r/elm-just-comments.d/expected.tags b/Units/parser-elm.r/elm-just-comments.d/expected.tags new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Units/parser-elm.r/elm-just-comments.d/input.elm b/Units/parser-elm.r/elm-just-comments.d/input.elm new file mode 100644 index 0000000000..472ddac200 --- /dev/null +++ b/Units/parser-elm.r/elm-just-comments.d/input.elm @@ -0,0 +1,21 @@ +-- a = 1 + +{- b = 2 -} + +{- +c = 3 +-} + +{-* d = 4 -} + +{-* +e = 5 + -} + +{- comment -} {- another comment -} + +{- +comment + {- nested comment -} +g = 7 +-} diff --git a/Units/parser-elm.r/elm-let-in.d/args.ctags b/Units/parser-elm.r/elm-let-in.d/args.ctags new file mode 100644 index 0000000000..405ad9b9ff --- /dev/null +++ b/Units/parser-elm.r/elm-let-in.d/args.ctags @@ -0,0 +1,3 @@ +--sort=no +--extras=+r +--fields=+rS diff --git a/Units/parser-elm.r/elm-let-in.d/expected.tags b/Units/parser-elm.r/elm-let-in.d/expected.tags new file mode 100644 index 0000000000..5390164f88 --- /dev/null +++ b/Units/parser-elm.r/elm-let-in.d/expected.tags @@ -0,0 +1,12 @@ +funcA input.elm /^funcA =$/;" f roles:def +a1 input.elm /^ a1 = 1$/;" f function:funcA roles:def +a2 input.elm /^ a2 x y = x + y$/;" f function:funcA roles:def +funcB input.elm /^funcB b =$/;" f roles:def +b1 input.elm /^ b1 =$/;" f function:funcB roles:def +b2 input.elm /^ b2 x y =$/;" f function:funcB roles:def +b3 input.elm /^ b3 x y =$/;" f function:funcB roles:def +b4 input.elm /^ b4 v w =$/;" f function:funcB roles:def +b5 input.elm /^ b5 i j = i + j$/;" f function:funcB roles:def +funcC input.elm /^funcC =$/;" f roles:def +c1 input.elm /^ c1 = 1$/;" f function:funcC roles:def +c2 input.elm /^ c2 x y = x + y$/;" f function:funcC roles:def diff --git a/Units/parser-elm.r/elm-let-in.d/input.elm b/Units/parser-elm.r/elm-let-in.d/input.elm new file mode 100644 index 0000000000..054e3cc179 --- /dev/null +++ b/Units/parser-elm.r/elm-let-in.d/input.elm @@ -0,0 +1,40 @@ +-- Basic let/in block + +funcA = + let + a1 = 1 + a2 x y = x + y + in + a1 << a2 + +-- Nested let/in blocks + +funcB b = + let + b1 = + let + b2 x y = + let + b3 x y = + x * y + b4 v w = + v * w + in + b3 b2 99 + in + (flip << b2) 77 + b5 i j = i + j + in + b1 b + +-- Let/in block with type annotation + +funcC = + let + c1 : Int + c1 = 1 + + c2 : Int Float -> Something + c2 x y = x + y + in + c1 << c2 diff --git a/Units/parser-elm.r/elm-modules.d/args.ctags b/Units/parser-elm.r/elm-modules.d/args.ctags new file mode 100644 index 0000000000..41f6dbed62 --- /dev/null +++ b/Units/parser-elm.r/elm-modules.d/args.ctags @@ -0,0 +1,3 @@ +--sort=no +--extras=+r +--fields=+r diff --git a/Units/parser-elm.r/elm-modules.d/expected.tags b/Units/parser-elm.r/elm-modules.d/expected.tags new file mode 100644 index 0000000000..a56b934199 --- /dev/null +++ b/Units/parser-elm.r/elm-modules.d/expected.tags @@ -0,0 +1,11 @@ +Amodule input.elm /^module Amodule exposing (expo)$/;" m roles:def +someFunc input.elm /^someFunc a =$/;" f module:Amodule roles:def +A1module input-1.elm /^module A1module exposing (expo)$/;" m roles:def +someFunc1 input-1.elm /^someFunc1 a =$/;" f module:A1module roles:def +expo input-1.elm /^expo a =$/;" f module:A1module roles:def +A2_1 input-2.elm /^module A2_1 exposing (expo)$/;" m roles:def +func2_1 input-2.elm /^func2_1 a =$/;" f module:A2_1 roles:def +func2_2 input-2.elm /^func2_2 a =$/;" f module:A2_1 roles:def +A3Module input-3.elm /^module A3Module exposing$/;" m roles:def +a4Module input-4.elm /^module a4Module exposing (..)$/;" m roles:def +a5.Module.Deep input-5.elm /^module a5.Module.Deep exposing (..)$/;" m roles:def diff --git a/Units/parser-elm.r/elm-modules.d/input-1.elm b/Units/parser-elm.r/elm-modules.d/input-1.elm new file mode 100644 index 0000000000..edcbac89c6 --- /dev/null +++ b/Units/parser-elm.r/elm-modules.d/input-1.elm @@ -0,0 +1,7 @@ +module A1module exposing (expo) + +someFunc1 a = + 42 + 24 + +expo a = + 42 + 24 diff --git a/Units/parser-elm.r/elm-modules.d/input-2.elm b/Units/parser-elm.r/elm-modules.d/input-2.elm new file mode 100644 index 0000000000..5ebb86e484 --- /dev/null +++ b/Units/parser-elm.r/elm-modules.d/input-2.elm @@ -0,0 +1,14 @@ +{- Only the first module declaration should be recognised -} + +module A2_1 exposing (expo) + +module A2_2 exposing (expo) + +func2_1 a = + 42 + 24 + +module A2_3 exposing (expo) + +func2_2 a = + 42 + 24 + diff --git a/Units/parser-elm.r/elm-modules.d/input-3.elm b/Units/parser-elm.r/elm-modules.d/input-3.elm new file mode 100644 index 0000000000..4c1c210084 --- /dev/null +++ b/Units/parser-elm.r/elm-modules.d/input-3.elm @@ -0,0 +1,8 @@ +-- Should be able to parse multiple exposed items in a module declaration + +module A3Module exposing + ( map, foldl + , Maybe, Possibly + , Result(..) + , MyList(Empty), Tree(Node, Value, Special) ) + diff --git a/Units/parser-elm.r/elm-modules.d/input-4.elm b/Units/parser-elm.r/elm-modules.d/input-4.elm new file mode 100644 index 0000000000..9697253ce8 --- /dev/null +++ b/Units/parser-elm.r/elm-modules.d/input-4.elm @@ -0,0 +1,3 @@ +-- Be relaxed about module name capitalisation + +module a4Module exposing (..) diff --git a/Units/parser-elm.r/elm-modules.d/input-5.elm b/Units/parser-elm.r/elm-modules.d/input-5.elm new file mode 100644 index 0000000000..c169128906 --- /dev/null +++ b/Units/parser-elm.r/elm-modules.d/input-5.elm @@ -0,0 +1,3 @@ +-- Be relaxed about module name capitalisation + +module a5.Module.Deep exposing (..) diff --git a/Units/parser-elm.r/elm-modules.d/input.elm b/Units/parser-elm.r/elm-modules.d/input.elm new file mode 100644 index 0000000000..662a090f14 --- /dev/null +++ b/Units/parser-elm.r/elm-modules.d/input.elm @@ -0,0 +1,4 @@ +module Amodule exposing (expo) + +someFunc a = + 42 + 24 diff --git a/Units/parser-elm.r/elm-multiline-strings.d/args.ctags b/Units/parser-elm.r/elm-multiline-strings.d/args.ctags new file mode 100644 index 0000000000..405ad9b9ff --- /dev/null +++ b/Units/parser-elm.r/elm-multiline-strings.d/args.ctags @@ -0,0 +1,3 @@ +--sort=no +--extras=+r +--fields=+rS diff --git a/Units/parser-elm.r/elm-multiline-strings.d/expected.tags b/Units/parser-elm.r/elm-multiline-strings.d/expected.tags new file mode 100644 index 0000000000..08d2dd7691 --- /dev/null +++ b/Units/parser-elm.r/elm-multiline-strings.d/expected.tags @@ -0,0 +1,3 @@ +funcA input.elm /^funcA a1 a2 = a1 + a2$/;" f roles:def +funcB input.elm /^funcB b =$/;" f roles:def +funcD input.elm /^funcD d1 =$/;" f roles:def diff --git a/Units/parser-elm.r/elm-multiline-strings.d/input.elm b/Units/parser-elm.r/elm-multiline-strings.d/input.elm new file mode 100644 index 0000000000..f2513489c3 --- /dev/null +++ b/Units/parser-elm.r/elm-multiline-strings.d/input.elm @@ -0,0 +1,17 @@ +-- We should be able to parse this function + +funcA a1 a2 = a1 + a2 + +-- We should get only funcB, not funcC + +funcB b = + b + """This is a multiline +string, which ends after + +funcC = 3 +""" + +funcD d1 = + (d1 + 34) + +-- The end diff --git a/Units/parser-elm.r/elm-namespaces.d/args.ctags b/Units/parser-elm.r/elm-namespaces.d/args.ctags new file mode 100644 index 0000000000..41f6dbed62 --- /dev/null +++ b/Units/parser-elm.r/elm-namespaces.d/args.ctags @@ -0,0 +1,3 @@ +--sort=no +--extras=+r +--fields=+r diff --git a/Units/parser-elm.r/elm-namespaces.d/expected.tags b/Units/parser-elm.r/elm-namespaces.d/expected.tags new file mode 100644 index 0000000000..88aede10a9 --- /dev/null +++ b/Units/parser-elm.r/elm-namespaces.d/expected.tags @@ -0,0 +1,5 @@ +A1Mod input.elm /^module A1Mod exposing (..)$/;" m roles:def +A1NameSpace input.elm /^import A1Import as A1NameSpace exposing (a1ImpFunc)$/;" n module:A1Mod roles:def moduleName:A1Import +A1Import input.elm /^import A1Import as A1NameSpace exposing (a1ImpFunc)$/;" m roles:imported +a1ImpFunc input.elm /^import A1Import as A1NameSpace exposing (a1ImpFunc)$/;" f module:A1Import roles:imported +func input.elm /^func a1 =$/;" f module:A1Mod roles:def diff --git a/Units/parser-elm.r/elm-namespaces.d/input.elm b/Units/parser-elm.r/elm-namespaces.d/input.elm new file mode 100644 index 0000000000..9c28a9a190 --- /dev/null +++ b/Units/parser-elm.r/elm-namespaces.d/input.elm @@ -0,0 +1,6 @@ +module A1Mod exposing (..) + +import A1Import as A1NameSpace exposing (a1ImpFunc) + +func a1 = + 42 + 24 diff --git a/Units/parser-elm.r/elm-optlist-compatibility.d/README.md b/Units/parser-elm.r/elm-optlist-compatibility.d/README.md new file mode 100644 index 0000000000..36f8878f61 --- /dev/null +++ b/Units/parser-elm.r/elm-optlist-compatibility.d/README.md @@ -0,0 +1,4 @@ +This directory contains the tests from the previous Elm parser, which used +the optlib parser. The tests are included to here to check compatibility. +However, the output from this PEG parser (and hence the contents of +expected.tags) is enhanced. diff --git a/Units/simple-elm.d/args.ctags b/Units/parser-elm.r/elm-optlist-compatibility.d/args.ctags similarity index 100% rename from Units/simple-elm.d/args.ctags rename to Units/parser-elm.r/elm-optlist-compatibility.d/args.ctags diff --git a/Units/parser-elm.r/elm-optlist-compatibility.d/expected.tags b/Units/parser-elm.r/elm-optlist-compatibility.d/expected.tags new file mode 100644 index 0000000000..3b5700d11a --- /dev/null +++ b/Units/parser-elm.r/elm-optlist-compatibility.d/expected.tags @@ -0,0 +1,18 @@ +Main input.elm /^port module Main exposing (..)$/;" m roles:def +List input.elm /^import List$/;" m roles:imported +Maybe input.elm /^import Maybe exposing (withDefault)$/;" m roles:imported +withDefault input.elm /^import Maybe exposing (withDefault)$/;" f module:Maybe roles:imported +Je input.elm /^import Json.Encode as Je$/;" n module:Main roles:def moduleName:Json.Encode +Json.Encode input.elm /^import Json.Encode as Je$/;" m roles:imported +Thing input.elm /^type Thing$/;" t module:Main roles:def +Two input.elm /^ | Two Int$/;" c type:Main.Thing roles:def +One input.elm /^ = One$/;" c type:Main.Thing roles:def +Param input.elm /^type Param a$/;" t module:Main roles:def +Other input.elm /^ | Other a$/;" c type:Main.Param roles:def +Cons input.elm /^ = Cons a$/;" c type:Main.Param roles:def +Num input.elm /^type alias Num =$/;" a module:Main roles:def +outward input.elm /^port outward : String -> Cmd a$/;" p module:Main roles:def +inward input.elm /^port inward : (b -> a) -> Sub a$/;" p module:Main roles:def +foo input.elm /^foo a =$/;" f module:Main roles:def +bar input.elm /^bar =$/;" f module:Main roles:def +bas input.elm /^ bas =$/;" f function:Main.bar roles:def diff --git a/Units/simple-elm.d/input.elm b/Units/parser-elm.r/elm-optlist-compatibility.d/input.elm similarity index 100% rename from Units/simple-elm.d/input.elm rename to Units/parser-elm.r/elm-optlist-compatibility.d/input.elm diff --git a/Units/parser-elm.r/elm-parameter-patterns.d/args.ctags b/Units/parser-elm.r/elm-parameter-patterns.d/args.ctags new file mode 100644 index 0000000000..405ad9b9ff --- /dev/null +++ b/Units/parser-elm.r/elm-parameter-patterns.d/args.ctags @@ -0,0 +1,3 @@ +--sort=no +--extras=+r +--fields=+rS diff --git a/Units/parser-elm.r/elm-parameter-patterns.d/expected.tags b/Units/parser-elm.r/elm-parameter-patterns.d/expected.tags new file mode 100644 index 0000000000..54d386eb47 --- /dev/null +++ b/Units/parser-elm.r/elm-parameter-patterns.d/expected.tags @@ -0,0 +1,7 @@ +funcA input.elm /^funcA (a1, _, a2) =$/;" f roles:def +funcB input.elm /^funcB (b1, b2) (b3, b4) =$/;" f roles:def +funcC input.elm /^funcC {c1} {c2, c3} =$/;" f roles:def +funcD input.elm /^funcD (D1Cons a b) (D2Cons a b, D3Cons a b) =$/;" f roles:def +funcE input.elm /^funcE (D1Cons {a, b} c) d =$/;" f roles:def +funcF input.elm /^funcF (D1Cons ({a, b} as ab) c) (d as d2) =$/;" f roles:def +funcG input.elm /^funcG =$/;" f roles:def diff --git a/Units/parser-elm.r/elm-parameter-patterns.d/input.elm b/Units/parser-elm.r/elm-parameter-patterns.d/input.elm new file mode 100644 index 0000000000..bd7c43d339 --- /dev/null +++ b/Units/parser-elm.r/elm-parameter-patterns.d/input.elm @@ -0,0 +1,36 @@ +-- Patterns can be found at https://elmprogramming.com/pattern-matching.html + +-- Simple tuple + +funcA (a1, _, a2) = + a1 + a2 + +-- Multiple tuples + +funcB (b1, b2) (b3, b4) = + b1 + b2 + +-- Records with named fields + +funcC {c1} {c2, c3} = + c1 + c2 + c3 + +-- Constructor patterns + +funcD (D1Cons a b) (D2Cons a b, D3Cons a b) = + b + 1 + +-- Combining the above + +funcE (D1Cons {a, b} c) d = + c + 1 + +-- Using 'as' clauses + +funcF (D1Cons ({a, b} as ab) c) (d as d2) = + c + 1 + +-- Make sure complex parameters can be used in anonymous functions + +funcG = + (\ (D1Cons {a, b} c) d -> a + b + c + d) diff --git a/Units/parser-elm.r/elm-ports.d/args.ctags b/Units/parser-elm.r/elm-ports.d/args.ctags new file mode 100644 index 0000000000..405ad9b9ff --- /dev/null +++ b/Units/parser-elm.r/elm-ports.d/args.ctags @@ -0,0 +1,3 @@ +--sort=no +--extras=+r +--fields=+rS diff --git a/Units/parser-elm.r/elm-ports.d/expected.tags b/Units/parser-elm.r/elm-ports.d/expected.tags new file mode 100644 index 0000000000..e1d99b5c08 --- /dev/null +++ b/Units/parser-elm.r/elm-ports.d/expected.tags @@ -0,0 +1,3 @@ +Main input.elm /^port module Main exposing (..)$/;" m roles:def +outgoing input.elm /^port outgoing : Enc.Value -> Cmd msg$/;" p module:Main signature:Enc.Value -> Cmd msg roles:def +incoming input.elm /^port incoming : (Enc.Value -> msg) -> Sub msg$/;" p module:Main signature:(Enc.Value -> msg) -> Sub msg roles:def diff --git a/Units/parser-elm.r/elm-ports.d/input.elm b/Units/parser-elm.r/elm-ports.d/input.elm new file mode 100644 index 0000000000..6e6adfa7f9 --- /dev/null +++ b/Units/parser-elm.r/elm-ports.d/input.elm @@ -0,0 +1,6 @@ +port module Main exposing (..) + +port outgoing : Enc.Value -> Cmd msg + +port incoming : (Enc.Value -> msg) -> Sub msg + diff --git a/Units/parser-elm.r/elm-signatures.d/args.ctags b/Units/parser-elm.r/elm-signatures.d/args.ctags new file mode 100644 index 0000000000..405ad9b9ff --- /dev/null +++ b/Units/parser-elm.r/elm-signatures.d/args.ctags @@ -0,0 +1,3 @@ +--sort=no +--extras=+r +--fields=+rS diff --git a/Units/parser-elm.r/elm-signatures.d/expected.tags b/Units/parser-elm.r/elm-signatures.d/expected.tags new file mode 100644 index 0000000000..d28a1da961 --- /dev/null +++ b/Units/parser-elm.r/elm-signatures.d/expected.tags @@ -0,0 +1,9 @@ +funcA input.elm /^funcA a = 1$/;" f signature:Int -> Float -> Float roles:def +funcB input.elm /^funcB b =$/;" f signature:String -> Float roles:def +funcC input.elm /^funcC c = 3$/;" f signature:Int -> {c: String} roles:def +funcD input.elm /^funcD = 4$/;" f signature:(Int, Int) -> String roles:def +funcE input.elm /^funcE = 5$/;" f signature:Float -> (Int -> Int -> Int -> String) roles:def +funcF input.elm /^funcF = 6$/;" f signature:String -> {- Old ->-} Int roles:def +funcG input.elm /^funcG = 7$/;" f signature:G.Int -> G.Other roles:def +funcH input.elm /^funcH h =$/;" f signature:Int -> Int roles:def +h2 input.elm /^ h2 = 34$/;" f function:funcH roles:def diff --git a/Units/parser-elm.r/elm-signatures.d/input.elm b/Units/parser-elm.r/elm-signatures.d/input.elm new file mode 100644 index 0000000000..fc1fd37d23 --- /dev/null +++ b/Units/parser-elm.r/elm-signatures.d/input.elm @@ -0,0 +1,49 @@ +-- Simple function with a signature + +funcA : Int -> Float -> Float +funcA a = 1 + +-- Signature over multiple lines + +funcB : + String -> + Float +funcB b = + b + 1 + +-- Function with a record in the signature + +funcC : Int -> {c: String} +funcC c = 3 + +-- Function with a tuple in the signature + +funcD : (Int, Int) -> String + +funcD = 4 + +-- Functions in the signature + +funcE : Float -> (Int -> Int -> Int -> String) + +funcE = 5 + +-- Comments in the signature + +funcF : -- Comment + String -> {- Old ->-} Int {-- End--} +funcF = 6 + +-- Dotted types in the signature + +funcG : G.Int -> G.Other +funcG = 7 + +-- Functions with type annotations should provide scope + +funcH : Int -> Int +funcH h = + let + h2 = 34 + in + h + h2 diff --git a/Units/parser-elm.r/elm-single-expressions.d/args.ctags b/Units/parser-elm.r/elm-single-expressions.d/args.ctags new file mode 100644 index 0000000000..405ad9b9ff --- /dev/null +++ b/Units/parser-elm.r/elm-single-expressions.d/args.ctags @@ -0,0 +1,3 @@ +--sort=no +--extras=+r +--fields=+rS diff --git a/Units/parser-elm.r/elm-single-expressions.d/expected.tags b/Units/parser-elm.r/elm-single-expressions.d/expected.tags new file mode 100644 index 0000000000..af9de015d6 --- /dev/null +++ b/Units/parser-elm.r/elm-single-expressions.d/expected.tags @@ -0,0 +1,9 @@ +funcA input.elm /^funcA a1 a2 =$/;" f roles:def +funcB input.elm /^funcB b1 b2 =$/;" f roles:def +funcC input.elm /^funcC c1 =$/;" f roles:def +funcD input.elm /^funcD d1 d2 =$/;" f roles:def +funcE input.elm /^funcE e1 =$/;" f roles:def +funcF input.elm /^funcF f1 =$/;" f roles:def +funcG input.elm /^funcG g1 =$/;" f roles:def +funcH input.elm /^funcH h1 =$/;" f roles:def +funcI input.elm /^funcI i1 =$/;" f roles:def diff --git a/Units/parser-elm.r/elm-single-expressions.d/input.elm b/Units/parser-elm.r/elm-single-expressions.d/input.elm new file mode 100644 index 0000000000..0cf2f2ed12 --- /dev/null +++ b/Units/parser-elm.r/elm-single-expressions.d/input.elm @@ -0,0 +1,50 @@ +-- Binary operators and decimals + +funcA a1 a2 = + a1 + a2 - 3.3 * 3e-3 / .1 + +-- More binary operators + +funcB b1 b2 = + b1 |> b2 >> 3.3 /= 4 + 5 + +-- Hex numbers + +funcC c1 = + 0xfa0 /= 0xFAE0 + +-- Parentheses + +funcD d1 d2 = + (3e4 + (5^7 - 0xe) // .2) + +-- Call prefix functions + +funcE e1 = + e1 + myFunc 3 4 + 5 + +-- Multiline strings + +funcF f1 = + f1 ++ """This is a multiline +string, which ends after +this line +""" + +-- Strings + +funcG g1 = + "Double q\"uote, \n, etc" ++ + "uni\u{04FA2}code" + +-- Characters + +funcH h1 = + 'D' ++ '\"' ++ '\'' ++ '\n' ++ + '\u{04FA2}' + +-- Anonymous functions + +funcI i1 = + (\ x y z -> x+y - z) + diff --git a/Units/parser-elm.r/elm-types.d/args.ctags b/Units/parser-elm.r/elm-types.d/args.ctags new file mode 100644 index 0000000000..41f6dbed62 --- /dev/null +++ b/Units/parser-elm.r/elm-types.d/args.ctags @@ -0,0 +1,3 @@ +--sort=no +--extras=+r +--fields=+r diff --git a/Units/parser-elm.r/elm-types.d/expected.tags b/Units/parser-elm.r/elm-types.d/expected.tags new file mode 100644 index 0000000000..d3befc2406 --- /dev/null +++ b/Units/parser-elm.r/elm-types.d/expected.tags @@ -0,0 +1,20 @@ +Apple input.elm /^type Apple = Cox | Braeburn$/;" t roles:def +Braeburn input.elm /^type Apple = Cox | Braeburn$/;" c type:Apple roles:def +Cox input.elm /^type Apple = Cox | Braeburn$/;" c type:Apple roles:def +Box input.elm /^type Box a = Cardboard a | Wooden$/;" t roles:def +Wooden input.elm /^type Box a = Cardboard a | Wooden$/;" c type:Box roles:def +Cardboard input.elm /^type Box a = Cardboard a | Wooden$/;" c type:Box roles:def +Clog input.elm /^type Clog a b = Dutch | English$/;" t roles:def +English input.elm /^type Clog a b = Dutch | English$/;" c type:Clog roles:def +Dutch input.elm /^type Clog a b = Dutch | English$/;" c type:Clog roles:def +DType input.elm /^type DType$/;" t roles:def +D2Cons input.elm /^ | D2Cons Float Float Clog$/;" c type:DType roles:def +D1Cons input.elm /^ = D1Cons { x : String, y:Maybe Int}$/;" c type:DType roles:def +TypesTwo input-1.elm /^module TypesTwo exposing (..)$/;" m roles:def +T2a input-1.elm /^type T2a = T2a_1 | T2a_2$/;" t module:TypesTwo roles:def +T2a_2 input-1.elm /^type T2a = T2a_1 | T2a_2$/;" c type:TypesTwo.T2a roles:def +T2a_1 input-1.elm /^type T2a = T2a_1 | T2a_2$/;" c type:TypesTwo.T2a roles:def +funcT2 input-1.elm /^funcT2 = "T2"$/;" f module:TypesTwo roles:def +T2b input-1.elm /^type T2b = T2b_1 | T2b_2$/;" t module:TypesTwo roles:def +T2b_2 input-1.elm /^type T2b = T2b_1 | T2b_2$/;" c type:TypesTwo.T2b roles:def +T2b_1 input-1.elm /^type T2b = T2b_1 | T2b_2$/;" c type:TypesTwo.T2b roles:def diff --git a/Units/parser-elm.r/elm-types.d/input-1.elm b/Units/parser-elm.r/elm-types.d/input-1.elm new file mode 100644 index 0000000000..30df61a582 --- /dev/null +++ b/Units/parser-elm.r/elm-types.d/input-1.elm @@ -0,0 +1,9 @@ +-- This is to check scoping still works okay + +module TypesTwo exposing (..) + +type T2a = T2a_1 | T2a_2 + +funcT2 = "T2" + +type T2b = T2b_1 | T2b_2 diff --git a/Units/parser-elm.r/elm-types.d/input.elm b/Units/parser-elm.r/elm-types.d/input.elm new file mode 100644 index 0000000000..d9ce206b1a --- /dev/null +++ b/Units/parser-elm.r/elm-types.d/input.elm @@ -0,0 +1,13 @@ +type Apple = Cox | Braeburn + +-- Parameterised types + +type Box a = Cardboard a | Wooden + +type Clog a b = Dutch | English + +-- Constructors with types + +type DType + = D1Cons { x : String, y:Maybe Int} + | D2Cons Float Float Clog diff --git a/Units/simple-elm.d/expected.tags b/Units/simple-elm.d/expected.tags deleted file mode 100644 index 6ea1f7d79c..0000000000 --- a/Units/simple-elm.d/expected.tags +++ /dev/null @@ -1,16 +0,0 @@ -Main input.elm /^port module Main exposing (..)$/;" m roles:def -List input.elm /^import List$/;" m roles:imported -Maybe input.elm /^import Maybe exposing (withDefault)$/;" m roles:imported -Je input.elm /^import Json.Encode as Je$/;" n roles:def -Thing input.elm /^type Thing$/;" t roles:def -One input.elm /^ = One$/;" c type:Thing roles:def -Two input.elm /^ | Two Int$/;" c type:Thing roles:def -Param input.elm /^type Param a$/;" t roles:def -Cons input.elm /^ = Cons a$/;" c type:Param roles:def -Other input.elm /^ | Other a$/;" c type:Param roles:def -Num input.elm /^type alias Num =$/;" a roles:def -outward input.elm /^port outward : String -> Cmd a$/;" p roles:def -inward input.elm /^port inward : (b -> a) -> Sub a$/;" p roles:def -foo input.elm /^foo a =$/;" f roles:def -bar input.elm /^bar =$/;" f roles:def -bas input.elm /^ bas =$/;" f function:bar roles:def diff --git a/docs/man-pages.rst b/docs/man-pages.rst index cae7fad517..8e8a5c1978 100644 --- a/docs/man-pages.rst +++ b/docs/man-pages.rst @@ -15,6 +15,7 @@ Man pages ctags-incompatibilities(7) ctags-faq(7) + ctags-lang-elm(7) ctags-lang-gdscript(7) ctags-lang-inko(7) ctags-lang-iPythonCell(7) diff --git a/docs/man/ctags-lang-elm.7.rst b/docs/man/ctags-lang-elm.7.rst new file mode 100644 index 0000000000..4828886d02 --- /dev/null +++ b/docs/man/ctags-lang-elm.7.rst @@ -0,0 +1,129 @@ +.. _ctags-lang-elm(7): + +============================================================== +ctags-lang-elm +============================================================== + +Random notes about tagging Elm source code with Universal Ctags + +:Version: 5.9.0 +:Manual group: Universal Ctags +:Manual section: 7 + +SYNOPSIS +-------- +| **ctags** ... --languages=+Elm ... +| **ctags** ... --language-force=Elm ... +| **ctags** ... --map-Elm=+.elm ... + +DESCRIPTION +----------- +The Elm parser is a PEG parser using PackCC, which is part of the +ctags infrastructure. It should correctly process all top level +statements, however there is a limitation with functions embedded +in let/in blocks. They will mostly be fine, but sometimes a +function in a let/in block will be omitted. + +EXAMPLES +-------- + +Imports +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Imported items are tagged, but their role is "imported", not "def". + +Imported items are marked as being in the scope of their own module, +not the module that's doing the importing. + +.. code-block:: Elm + + module SomeMod exposing (..) + + import MyMod exposing + ( map + , Maybe + , Result(..) + , MyList(Empty) + ) + +"output.tags" +with "--sort=no --extras=+r --fields=+r" + +.. code-block:: tags + + SomeMod input.elm /^module SomeMod exposing (..)$/;" m roles:def + MyMod input.elm /^import MyMod exposing$/;" m roles:imported + map input.elm /^ ( map$/;" f module:MyMod roles:imported + Maybe input.elm /^ , Maybe$/;" t module:MyMod roles:imported + Result input.elm /^ , Result(..)$/;" t module:MyMod roles:imported + MyList input.elm /^ , MyList(Empty)$/;" t module:MyMod roles:imported + Empty input.elm /^ , MyList(Empty)$/;" c type:MyMod.MyList roles:imported + +Namespaces +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Namespaces are tagged and their role is "def". + +.. code-block:: Elm + + module AMod exposing (..) + + import MyImport as NSpace exposing (impFunc) + +"output.tags" +with "--sort=no --extras=+r --fields=+r" + +.. code-block:: tags + + AMod input.elm /^module AMod exposing (..)$/;" m roles:def + NSpace input.elm /^import MyImport as NSpace exposing (impFunc)$/;" n module:AMod roles:def moduleName:MyImport + MyImport input.elm /^import MyImport as NSpace exposing (impFunc)$/;" m roles:imported + impFunc input.elm /^import MyImport as NSpace exposing (impFunc)$/;" f module:MyImport roles:imported + +Signatures +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Constructors will have signatures. So will any top level function +that has a type annotation. + +.. code-block:: Elm + + funcA : Int -> Int + funcA a = a + 1 + + type B + = B1Cons + { x : Float + , y : Float + } + | B2Cons String Integer + | B3Cons + +"output.tags" +with "--sort=no --extras=+r --fields=+rS" + +.. code-block:: tags + + funcA input.elm /^funcA a = a + 1$/;" f signature:Int -> Int roles:def + B input.elm /^type B$/;" t roles:def + B3Cons input.elm /^ | B3Cons$/;" c type:B signature: roles:def + B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B signature:String Integer roles:def + B1Cons input.elm /^ = B1Cons$/;" c type:B signature:{ x : Float , y : Float } roles:def + +KNOWN LIMITATIONS +----------------- +Elm requires all statements at the same logical level to have the +same indentation. If there is additional indentation that line is part +of the previous one. Therefore without over-complicating the +PEG parser we have the following limitations... + +Sometimes functions in let/in blocks will be omitted. + +Functions in let/in blocks will be marked as being in the scope of their +outer function, regardless of how deeply nested the let/in block is. + +Functions in let/in blocks won't have signatures. + +SEE ALSO +-------- +:ref:`ctags(1) `, :ref:`ctags-client-tools(7) ` diff --git a/docs/news.rst b/docs/news.rst index 3703ebaeec..a4936efb75 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -410,7 +410,7 @@ The following parsers have been added: * DTD * DTS * Elixir *optlib* -* Elm *optlib* +* Elm *peg/packcc* * Falcon * FunctionParameters *perl based subparser* * Gdbinit script *optlib* diff --git a/main/parsers_p.h b/main/parsers_p.h index e6f25891a1..424c47c73b 100644 --- a/main/parsers_p.h +++ b/main/parsers_p.h @@ -39,7 +39,8 @@ #define PEG_PARSER_LIST \ VarlinkParser, \ KotlinParser, \ - ThriftParser + ThriftParser, \ + ElmParser #else #define PEG_PARSER_LIST #endif @@ -79,7 +80,6 @@ DosBatchParser, \ EiffelParser, \ ElixirParser, \ - ElmParser, \ EmacsLispParser, \ ErlangParser, \ FalconParser, \ diff --git a/man/Makefile.am b/man/Makefile.am index 7746be1765..52bbe0dbce 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -37,6 +37,7 @@ GEN_IN_MAN_FILES = \ ctags-lang-r.7 \ ctags-lang-rmarkdown.7 \ ctags-lang-sql.7 \ + ctags-lang-elm.7 \ \ readtags.1 \ tags.5 \ diff --git a/man/ctags-lang-elm.7.rst.in b/man/ctags-lang-elm.7.rst.in new file mode 100644 index 0000000000..6455ea12fd --- /dev/null +++ b/man/ctags-lang-elm.7.rst.in @@ -0,0 +1,129 @@ +.. _ctags-lang-elm(7): + +============================================================== +ctags-lang-elm +============================================================== +------------------------------------------------------------------- +Random notes about tagging Elm source code with Universal Ctags +------------------------------------------------------------------- +:Version: @VERSION@ +:Manual group: Universal Ctags +:Manual section: 7 + +SYNOPSIS +-------- +| **@CTAGS_NAME_EXECUTABLE@** ... --languages=+Elm ... +| **@CTAGS_NAME_EXECUTABLE@** ... --language-force=Elm ... +| **@CTAGS_NAME_EXECUTABLE@** ... --map-Elm=+.elm ... + +DESCRIPTION +----------- +The Elm parser is a PEG parser using PackCC, which is part of the +ctags infrastructure. It should correctly process all top level +statements, however there is a limitation with functions embedded +in let/in blocks. They will mostly be fine, but sometimes a +function in a let/in block will be omitted. + +EXAMPLES +-------- + +Imports +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Imported items are tagged, but their role is "imported", not "def". + +Imported items are marked as being in the scope of their own module, +not the module that's doing the importing. + +.. code-block:: Elm + + module SomeMod exposing (..) + + import MyMod exposing + ( map + , Maybe + , Result(..) + , MyList(Empty) + ) + +"output.tags" +with "--sort=no --extras=+r --fields=+r" + +.. code-block:: tags + + SomeMod input.elm /^module SomeMod exposing (..)$/;" m roles:def + MyMod input.elm /^import MyMod exposing$/;" m roles:imported + map input.elm /^ ( map$/;" f module:MyMod roles:imported + Maybe input.elm /^ , Maybe$/;" t module:MyMod roles:imported + Result input.elm /^ , Result(..)$/;" t module:MyMod roles:imported + MyList input.elm /^ , MyList(Empty)$/;" t module:MyMod roles:imported + Empty input.elm /^ , MyList(Empty)$/;" c type:MyMod.MyList roles:imported + +Namespaces +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Namespaces are tagged and their role is "def". + +.. code-block:: Elm + + module AMod exposing (..) + + import MyImport as NSpace exposing (impFunc) + +"output.tags" +with "--sort=no --extras=+r --fields=+r" + +.. code-block:: tags + + AMod input.elm /^module AMod exposing (..)$/;" m roles:def + NSpace input.elm /^import MyImport as NSpace exposing (impFunc)$/;" n module:AMod roles:def moduleName:MyImport + MyImport input.elm /^import MyImport as NSpace exposing (impFunc)$/;" m roles:imported + impFunc input.elm /^import MyImport as NSpace exposing (impFunc)$/;" f module:MyImport roles:imported + +Signatures +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Constructors will have signatures. So will any top level function +that has a type annotation. + +.. code-block:: Elm + + funcA : Int -> Int + funcA a = a + 1 + + type B + = B1Cons + { x : Float + , y : Float + } + | B2Cons String Integer + | B3Cons + +"output.tags" +with "--sort=no --extras=+r --fields=+rS" + +.. code-block:: tags + + funcA input.elm /^funcA a = a + 1$/;" f signature:Int -> Int roles:def + B input.elm /^type B$/;" t roles:def + B3Cons input.elm /^ | B3Cons$/;" c type:B signature: roles:def + B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B signature:String Integer roles:def + B1Cons input.elm /^ = B1Cons$/;" c type:B signature:{ x : Float , y : Float } roles:def + +KNOWN LIMITATIONS +----------------- +Elm requires all statements at the same logical level to have the +same indentation. If there is additional indentation that line is part +of the previous one. Therefore without over-complicating the +PEG parser we have the following limitations... + +Sometimes functions in let/in blocks will be omitted. + +Functions in let/in blocks will be marked as being in the scope of their +outer function, regardless of how deeply nested the let/in block is. + +Functions in let/in blocks won't have signatures. + +SEE ALSO +-------- +ctags(1), ctags-client-tools(7) diff --git a/mk_mvc.mak b/mk_mvc.mak index c706e01f56..dec16b7e8e 100644 --- a/mk_mvc.mak +++ b/mk_mvc.mak @@ -101,6 +101,7 @@ main\repoinfo.obj: main\repoinfo.c main\repoinfo.h peg\varlink.c peg\varlink.h: peg\varlink.peg $(PACKCC) peg\kotlin.c peg\kotlin.h: peg\kotlin.peg $(PACKCC) peg\thrift.c peg\thrift.h: peg\thrift.peg $(PACKCC) +peg\elm.c peg\elm.h: peg\elm.peg $(PACKCC) $(RES_OBJ): win32/ctags.rc win32/ctags.exe.manifest win32/resource.h $(RC) /nologo /l 0x409 /Fo$@ $*.rc diff --git a/optlib/elm.c b/optlib/elm.c deleted file mode 100644 index 4fe7ecaca6..0000000000 --- a/optlib/elm.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Generated by ./misc/optlib2c from optlib/elm.ctags, Don't edit this manually. - */ -#include "general.h" -#include "parse.h" -#include "routines.h" -#include "field.h" -#include "xtag.h" - - -static void initializeElmParser (const langType language CTAGS_ATTR_UNUSED) -{ -} - -extern parserDefinition* ElmParser (void) -{ - static const char *const extensions [] = { - "elm", - NULL - }; - - static const char *const aliases [] = { - NULL - }; - - static const char *const patterns [] = { - NULL - }; - - static roleDefinition ElmModuleRoleTable [] = { - { true, "imported", "imported module" }, - }; - static kindDefinition ElmKindTable [] = { - { - true, 'm', "module", "Module", - ATTACH_ROLES(ElmModuleRoleTable), - }, - { - true, 'n', "namespace", "Renamed Imported Module", - }, - { - true, 'p', "port", "Port", - }, - { - true, 't', "type", "Type Definition", - }, - { - true, 'c', "constructor", "Type Constructor", - }, - { - true, 'a', "alias", "Type Alias", - }, - { - true, 'f', "function", "Functions", - }, - }; - static tagRegexTable ElmTagRegexTable [] = { - {"^(port[[:blank:]]+)?module[[:blank:]]+([[:upper:]][[:alnum:]_.]*)", "\\2", - "m", "{scope=push}{exclusive}", NULL, false}, - {"^import[[:blank:]]+[[:alnum:]_.]+[[:blank:]]+as[[:blank:]]+([[:alnum:]]+)", "\\1", - "n", "{scope=clear}{exclusive}", NULL, false}, - {"^import[[:blank:]]+([[:alnum:]_.]+)[[:blank:]]exposing", "\\1", - "m", "{scope=clear}{exclusive}{_role=imported}", NULL, false}, - {"^import[[:blank:]]+([[:alnum:]_.]+)", "\\1", - "m", "{scope=clear}{exclusive}{_role=imported}", NULL, false}, - {"^port[[:blank:]]+([[:lower:]][[:alnum:]_]*).*", "\\1", - "p", "{scope=clear}{exclusive}", NULL, false}, - {"^type +([[:upper:]][[:alnum:]_]*).*", "\\1", - "t", "{scope=set}{exclusive}", NULL, false}, - {"^[[:blank:]]+[|=][[:blank:]]+([[:upper:]][[:alnum:]_]*).*$", "\\1", - "c", "{scope=ref}{exclusive}", NULL, false}, - {"^type[[:blank:]]+alias[[:blank:]]+([[:upper:]][[:alnum:]_]*[[:blank:][:alnum:]_]*)", "\\1", - "a", "{scope=set}{exclusive}", NULL, false}, - {"^([[:lower:]_][[:alnum:]_]*)[^=]*=$", "\\1", - "f", "{scope=set}", NULL, false}, - {"^[[:blank:]]+([[:lower:]_][[:alnum:]_]*)[^=]*=$", "\\1", - "f", "{scope=ref}", NULL, false}, - }; - - - parserDefinition* const def = parserNew ("Elm"); - - def->enabled = true; - def->extensions = extensions; - def->patterns = patterns; - def->aliases = aliases; - def->method = METHOD_NOT_CRAFTED|METHOD_REGEX; - def->useCork = CORK_QUEUE; - def->kindTable = ElmKindTable; - def->kindCount = ARRAY_SIZE(ElmKindTable); - def->tagRegexTable = ElmTagRegexTable; - def->tagRegexCount = ARRAY_SIZE(ElmTagRegexTable); - def->initialize = initializeElmParser; - - return def; -} diff --git a/optlib/elm.ctags b/optlib/elm.ctags deleted file mode 100644 index 77290da8d1..0000000000 --- a/optlib/elm.ctags +++ /dev/null @@ -1,45 +0,0 @@ -# -# Copyright (c) 2016, Mark Skipper -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -# USA. -# -# ---langdef=Elm ---map-Elm=+.elm - ---kinddef-Elm=m,module,Module ---kinddef-Elm=n,namespace,Renamed Imported Module ---kinddef-Elm=p,port,Port ---kinddef-Elm=t,type,Type Definition ---kinddef-Elm=c,constructor,Type Constructor ---kinddef-Elm=a,alias,Type Alias ---kinddef-Elm=f,function,Functions ---_roledef-Elm.{module}=imported,imported module - ---regex-Elm=/^(port[[:blank:]]+)?module[[:blank:]]+([[:upper:]][[:alnum:]_.]*)/\2/m/{scope=push}{exclusive} ---regex-Elm=/^import[[:blank:]]+[[:alnum:]_.]+[[:blank:]]+as[[:blank:]]+([[:alnum:]]+)/\1/n/{scope=clear}{exclusive} -# -# Following two patterns are just for clearing scope stack. -# X in "import X" should be captured as a reference tag in the future. -# ---regex-Elm=/^import[[:blank:]]+([[:alnum:]_.]+)[[:blank:]]exposing/\1/m/{scope=clear}{exclusive}{_role=imported} ---regex-Elm=/^import[[:blank:]]+([[:alnum:]_.]+)/\1/m/{scope=clear}{exclusive}{_role=imported} ---regex-Elm=/^port[[:blank:]]+([[:lower:]][[:alnum:]_]*).*/\1/p/{scope=clear}{exclusive} ---regex-Elm=/^type +([[:upper:]][[:alnum:]_]*).*/\1/t/{scope=set}{exclusive} ---regex-Elm=/^[[:blank:]]+[|=][[:blank:]]+([[:upper:]][[:alnum:]_]*).*$/\1/c/{scope=ref}{exclusive} ---regex-Elm=/^type[[:blank:]]+alias[[:blank:]]+([[:upper:]][[:alnum:]_]*[[:blank:][:alnum:]_]*)/\1/a/{scope=set}{exclusive} ---regex-Elm=/^([[:lower:]_][[:alnum:]_]*)[^=]*=$/\1/f/{scope=set} ---regex-Elm=/^[[:blank:]]+([[:lower:]_][[:alnum:]_]*)[^=]*=$/\1/f/{scope=ref} diff --git a/peg/.gitignore b/peg/.gitignore index 74efb2126f..8d4a72d782 100644 --- a/peg/.gitignore +++ b/peg/.gitignore @@ -1,3 +1,4 @@ varlink.[ch] kotlin.[ch] thrift.[ch] +elm.[ch] diff --git a/peg/elm.c b/peg/elm.c new file mode 100644 index 0000000000..867c178839 --- /dev/null +++ b/peg/elm.c @@ -0,0 +1,6760 @@ +/* A packrat parser generated by PackCC 1.6.0 */ + +#include "general.h" +#ifdef _MSC_VER +#undef _CRT_SECURE_NO_WARNINGS +#define _CRT_SECURE_NO_WARNINGS +#endif /* _MSC_VER */ +#include +#include +#include + +#ifndef _MSC_VER +#if defined __GNUC__ && defined _WIN32 /* MinGW */ +#ifndef PCC_USE_SYSTEM_STRNLEN +#define strnlen(str, maxlen) pcc_strnlen(str, maxlen) +static size_t pcc_strnlen(const char *str, size_t maxlen) { + size_t i; + for (i = 0; i < maxlen && str[i]; i++); + return i; +} +#endif /* !PCC_USE_SYSTEM_STRNLEN */ +#endif /* defined __GNUC__ && defined _WIN32 */ +#endif /* !_MSC_VER */ + +#include "./peg/elm.h" + +#include "elm_pre.h" +#include "routines.h" + +/* + * Include these lines to debug the parsing. + * From https://github.com/arithy/packcc#macros + * This will output parsing info to STDERR.tmp in the vent of a failed test. + */ + +/* +static const char *dbg_str[] = { "Evaluating rule", "Matched rule", "Abandoning rule" }; + +#define PCC_DEBUG(auxil, event, rule, level, pos, buffer, length) \ + fprintf(stderr, "%*s%s %s @%zu [%.*s]\n", \ + (int)((level) * 2), "", dbg_str[event], rule, pos, (int)(length), buffer) + */ +#if !defined __has_attribute || defined _MSC_VER +#define __attribute__(x) +#endif + +#ifdef _MSC_VER +#define MARK_USED_FUNC __pragma(warning(suppress:4505)) +#else +#define MARK_USED_FUNC __attribute__((__unused__)) +#endif + +#ifndef PCC_BUFFERSIZE +#define PCC_BUFFERSIZE 256 +#endif /* !PCC_BUFFERSIZE */ + +#ifndef PCC_ARRAYSIZE +#define PCC_ARRAYSIZE 2 +#endif /* !PCC_ARRAYSIZE */ + +#define PCC_DBG_EVALUATE 0 +#define PCC_DBG_MATCH 1 +#define PCC_DBG_NOMATCH 2 + +#define PCC_VOID_VALUE (~(size_t)0) + +typedef enum pcc_bool_tag { + PCC_FALSE = 0, + PCC_TRUE +} pcc_bool_t; + +typedef struct pcc_char_array_tag { + char *buf; + size_t max; + size_t len; +} pcc_char_array_t; + +typedef struct pcc_range_tag { + size_t start; + size_t end; +} pcc_range_t; + +typedef int pcc_value_t; + +typedef struct parserCtx *pcc_auxil_t; + +typedef struct pcc_value_table_tag { + pcc_value_t *buf; + size_t max; + size_t len; +} pcc_value_table_t; + +typedef struct pcc_value_refer_table_tag { + pcc_value_t **buf; + size_t max; + size_t len; +} pcc_value_refer_table_t; + +typedef struct pcc_capture_tag { + pcc_range_t range; + char *string; /* mutable */ +} pcc_capture_t; + +typedef struct pcc_capture_table_tag { + pcc_capture_t *buf; + size_t max; + size_t len; +} pcc_capture_table_t; + +typedef struct pcc_capture_const_table_tag { + const pcc_capture_t **buf; + size_t max; + size_t len; +} pcc_capture_const_table_t; + +typedef struct pcc_thunk_tag pcc_thunk_t; +typedef struct pcc_thunk_array_tag pcc_thunk_array_t; + +typedef void (*pcc_action_t)(pelm_context_t *, pcc_thunk_t *, pcc_value_t *); + +typedef enum pcc_thunk_type_tag { + PCC_THUNK_LEAF, + PCC_THUNK_NODE +} pcc_thunk_type_t; + +typedef struct pcc_thunk_leaf_tag { + pcc_value_refer_table_t values; + pcc_capture_const_table_t capts; + pcc_capture_t capt0; + pcc_action_t action; +} pcc_thunk_leaf_t; + +typedef struct pcc_thunk_node_tag { + const pcc_thunk_array_t *thunks; /* just a reference */ + pcc_value_t *value; /* just a reference */ +} pcc_thunk_node_t; + +typedef union pcc_thunk_data_tag { + pcc_thunk_leaf_t leaf; + pcc_thunk_node_t node; +} pcc_thunk_data_t; + +struct pcc_thunk_tag { + pcc_thunk_type_t type; + pcc_thunk_data_t data; +}; + +struct pcc_thunk_array_tag { + pcc_thunk_t **buf; + size_t max; + size_t len; +}; + +typedef struct pcc_thunk_chunk_tag { + pcc_value_table_t values; + pcc_capture_table_t capts; + pcc_thunk_array_t thunks; + size_t pos; /* the starting position in the character buffer */ +} pcc_thunk_chunk_t; + +typedef struct pcc_lr_entry_tag pcc_lr_entry_t; + +typedef enum pcc_lr_answer_type_tag { + PCC_LR_ANSWER_LR, + PCC_LR_ANSWER_CHUNK +} pcc_lr_answer_type_t; + +typedef union pcc_lr_answer_data_tag { + pcc_lr_entry_t *lr; + pcc_thunk_chunk_t *chunk; +} pcc_lr_answer_data_t; + +typedef struct pcc_lr_answer_tag pcc_lr_answer_t; + +struct pcc_lr_answer_tag { + pcc_lr_answer_type_t type; + pcc_lr_answer_data_t data; + size_t pos; /* the absolute position in the input */ + pcc_lr_answer_t *hold; +}; + +typedef pcc_thunk_chunk_t *(*pcc_rule_t)(pelm_context_t *); + +typedef struct pcc_rule_set_tag { + pcc_rule_t *buf; + size_t max; + size_t len; +} pcc_rule_set_t; + +typedef struct pcc_lr_head_tag pcc_lr_head_t; + +struct pcc_lr_head_tag { + pcc_rule_t rule; + pcc_rule_set_t invol; + pcc_rule_set_t eval; + pcc_lr_head_t *hold; +}; + +typedef struct pcc_lr_memo_tag { + pcc_rule_t rule; + pcc_lr_answer_t *answer; +} pcc_lr_memo_t; + +typedef struct pcc_lr_memo_map_tag { + pcc_lr_memo_t *buf; + size_t max; + size_t len; +} pcc_lr_memo_map_t; + +typedef struct pcc_lr_table_entry_tag { + pcc_lr_head_t *head; /* just a reference */ + pcc_lr_memo_map_t memos; + pcc_lr_answer_t *hold_a; + pcc_lr_head_t *hold_h; +} pcc_lr_table_entry_t; + +typedef struct pcc_lr_table_tag { + pcc_lr_table_entry_t **buf; + size_t max; + size_t len; + size_t ofs; +} pcc_lr_table_t; + +struct pcc_lr_entry_tag { + pcc_rule_t rule; + pcc_thunk_chunk_t *seed; /* just a reference */ + pcc_lr_head_t *head; /* just a reference */ +}; + +typedef struct pcc_lr_stack_tag { + pcc_lr_entry_t **buf; + size_t max; + size_t len; +} pcc_lr_stack_t; + +struct pelm_context_tag { + size_t pos; /* the position in the input of the first character currently buffered */ + size_t cur; /* the current parsing position in the character buffer */ + size_t level; + pcc_char_array_t buffer; + pcc_lr_table_t lrtable; + pcc_lr_stack_t lrstack; + pcc_thunk_array_t thunks; + pcc_auxil_t auxil; +}; + +#ifndef PCC_ERROR +#define PCC_ERROR(auxil) pcc_error() +MARK_USED_FUNC +static void pcc_error(void) { + fprintf(stderr, "Syntax error\n"); + exit(1); +} +#endif /* !PCC_ERROR */ + +#ifndef PCC_GETCHAR +#define PCC_GETCHAR(auxil) getchar() +#endif /* !PCC_GETCHAR */ + +#ifndef PCC_MALLOC +#define PCC_MALLOC(auxil, size) pcc_malloc_e(size) +static void *pcc_malloc_e(size_t size) { + void *const p = malloc(size); + if (p == NULL) { + fprintf(stderr, "Out of memory\n"); + exit(1); + } + return p; +} +#endif /* !PCC_MALLOC */ + +#ifndef PCC_REALLOC +#define PCC_REALLOC(auxil, ptr, size) pcc_realloc_e(ptr, size) +static void *pcc_realloc_e(void *ptr, size_t size) { + void *const p = realloc(ptr, size); + if (p == NULL) { + fprintf(stderr, "Out of memory\n"); + exit(1); + } + return p; +} +#endif /* !PCC_REALLOC */ + +#ifndef PCC_FREE +#define PCC_FREE(auxil, ptr) free(ptr) +#endif /* !PCC_FREE */ + +#ifndef PCC_DEBUG +#define PCC_DEBUG(auxil, event, rule, level, pos, buffer, length) ((void)0) +#endif /* !PCC_DEBUG */ + +static char *pcc_strndup_e(pcc_auxil_t auxil, const char *str, size_t len) { + const size_t m = strnlen(str, len); + char *const s = (char *)PCC_MALLOC(auxil, m + 1); + memcpy(s, str, m); + s[m] = '\0'; + return s; +} + +static void pcc_char_array__init(pcc_auxil_t auxil, pcc_char_array_t *array) { + array->len = 0; + array->max = 0; + array->buf = NULL; +} + +static void pcc_char_array__add(pcc_auxil_t auxil, pcc_char_array_t *array, char ch) { + if (array->max <= array->len) { + const size_t n = array->len + 1; + size_t m = array->max; + if (m == 0) m = PCC_BUFFERSIZE; + while (m < n && m != 0) m <<= 1; + if (m == 0) m = n; + array->buf = (char *)PCC_REALLOC(auxil, array->buf, m); + array->max = m; + } + array->buf[array->len++] = ch; +} + +static void pcc_char_array__term(pcc_auxil_t auxil, pcc_char_array_t *array) { + PCC_FREE(auxil, array->buf); +} + +static void pcc_value_table__init(pcc_auxil_t auxil, pcc_value_table_t *table) { + table->len = 0; + table->max = 0; + table->buf = NULL; +} + +MARK_USED_FUNC +static void pcc_value_table__resize(pcc_auxil_t auxil, pcc_value_table_t *table, size_t len) { + if (table->max < len) { + size_t m = table->max; + if (m == 0) m = PCC_ARRAYSIZE; + while (m < len && m != 0) m <<= 1; + if (m == 0) m = len; + table->buf = (pcc_value_t *)PCC_REALLOC(auxil, table->buf, sizeof(pcc_value_t) * m); + table->max = m; + } + table->len = len; +} + +static void pcc_value_table__term(pcc_auxil_t auxil, pcc_value_table_t *table) { + PCC_FREE(auxil, table->buf); +} + +static void pcc_value_refer_table__init(pcc_auxil_t auxil, pcc_value_refer_table_t *table) { + table->len = 0; + table->max = 0; + table->buf = NULL; +} + +static void pcc_value_refer_table__resize(pcc_auxil_t auxil, pcc_value_refer_table_t *table, size_t len) { + size_t i; + if (table->max < len) { + size_t m = table->max; + if (m == 0) m = PCC_ARRAYSIZE; + while (m < len && m != 0) m <<= 1; + if (m == 0) m = len; + table->buf = (pcc_value_t **)PCC_REALLOC(auxil, table->buf, sizeof(pcc_value_t *) * m); + table->max = m; + } + for (i = table->len; i < len; i++) table->buf[i] = NULL; + table->len = len; +} + +static void pcc_value_refer_table__term(pcc_auxil_t auxil, pcc_value_refer_table_t *table) { + PCC_FREE(auxil, table->buf); +} + +static void pcc_capture_table__init(pcc_auxil_t auxil, pcc_capture_table_t *table) { + table->len = 0; + table->max = 0; + table->buf = NULL; +} + +MARK_USED_FUNC +static void pcc_capture_table__resize(pcc_auxil_t auxil, pcc_capture_table_t *table, size_t len) { + size_t i; + for (i = len; i < table->len; i++) PCC_FREE(auxil, table->buf[i].string); + if (table->max < len) { + size_t m = table->max; + if (m == 0) m = PCC_ARRAYSIZE; + while (m < len && m != 0) m <<= 1; + if (m == 0) m = len; + table->buf = (pcc_capture_t *)PCC_REALLOC(auxil, table->buf, sizeof(pcc_capture_t) * m); + table->max = m; + } + for (i = table->len; i < len; i++) { + table->buf[i].range.start = 0; + table->buf[i].range.end = 0; + table->buf[i].string = NULL; + } + table->len = len; +} + +static void pcc_capture_table__term(pcc_auxil_t auxil, pcc_capture_table_t *table) { + while (table->len > 0) { + table->len--; + PCC_FREE(auxil, table->buf[table->len].string); + } + PCC_FREE(auxil, table->buf); +} + +static void pcc_capture_const_table__init(pcc_auxil_t auxil, pcc_capture_const_table_t *table) { + table->len = 0; + table->max = 0; + table->buf = NULL; +} + +static void pcc_capture_const_table__resize(pcc_auxil_t auxil, pcc_capture_const_table_t *table, size_t len) { + size_t i; + if (table->max < len) { + size_t m = table->max; + if (m == 0) m = PCC_ARRAYSIZE; + while (m < len && m != 0) m <<= 1; + if (m == 0) m = len; + table->buf = (const pcc_capture_t **)PCC_REALLOC(auxil, (pcc_capture_t **)table->buf, sizeof(const pcc_capture_t *) * m); + table->max = m; + } + for (i = table->len; i < len; i++) table->buf[i] = NULL; + table->len = len; +} + +static void pcc_capture_const_table__term(pcc_auxil_t auxil, pcc_capture_const_table_t *table) { + PCC_FREE(auxil, (void *)table->buf); +} + +MARK_USED_FUNC +static pcc_thunk_t *pcc_thunk__create_leaf(pcc_auxil_t auxil, pcc_action_t action, size_t valuec, size_t captc) { + pcc_thunk_t *const thunk = (pcc_thunk_t *)PCC_MALLOC(auxil, sizeof(pcc_thunk_t)); + thunk->type = PCC_THUNK_LEAF; + pcc_value_refer_table__init(auxil, &thunk->data.leaf.values); + pcc_value_refer_table__resize(auxil, &thunk->data.leaf.values, valuec); + pcc_capture_const_table__init(auxil, &thunk->data.leaf.capts); + pcc_capture_const_table__resize(auxil, &thunk->data.leaf.capts, captc); + thunk->data.leaf.capt0.range.start = 0; + thunk->data.leaf.capt0.range.end = 0; + thunk->data.leaf.capt0.string = NULL; + thunk->data.leaf.action = action; + return thunk; +} + +static pcc_thunk_t *pcc_thunk__create_node(pcc_auxil_t auxil, const pcc_thunk_array_t *thunks, pcc_value_t *value) { + pcc_thunk_t *const thunk = (pcc_thunk_t *)PCC_MALLOC(auxil, sizeof(pcc_thunk_t)); + thunk->type = PCC_THUNK_NODE; + thunk->data.node.thunks = thunks; + thunk->data.node.value = value; + return thunk; +} + +static void pcc_thunk__destroy(pcc_auxil_t auxil, pcc_thunk_t *thunk) { + if (thunk == NULL) return; + switch (thunk->type) { + case PCC_THUNK_LEAF: + PCC_FREE(auxil, thunk->data.leaf.capt0.string); + pcc_capture_const_table__term(auxil, &thunk->data.leaf.capts); + pcc_value_refer_table__term(auxil, &thunk->data.leaf.values); + break; + case PCC_THUNK_NODE: + break; + default: /* unknown */ + break; + } + PCC_FREE(auxil, thunk); +} + +static void pcc_thunk_array__init(pcc_auxil_t auxil, pcc_thunk_array_t *array) { + array->len = 0; + array->max = 0; + array->buf = NULL; +} + +static void pcc_thunk_array__add(pcc_auxil_t auxil, pcc_thunk_array_t *array, pcc_thunk_t *thunk) { + if (array->max <= array->len) { + const size_t n = array->len + 1; + size_t m = array->max; + if (m == 0) m = PCC_ARRAYSIZE; + while (m < n && m != 0) m <<= 1; + if (m == 0) m = n; + array->buf = (pcc_thunk_t **)PCC_REALLOC(auxil, array->buf, sizeof(pcc_thunk_t *) * m); + array->max = m; + } + array->buf[array->len++] = thunk; +} + +static void pcc_thunk_array__revert(pcc_auxil_t auxil, pcc_thunk_array_t *array, size_t len) { + while (array->len > len) { + array->len--; + pcc_thunk__destroy(auxil, array->buf[array->len]); + } +} + +static void pcc_thunk_array__term(pcc_auxil_t auxil, pcc_thunk_array_t *array) { + while (array->len > 0) { + array->len--; + pcc_thunk__destroy(auxil, array->buf[array->len]); + } + PCC_FREE(auxil, array->buf); +} + +MARK_USED_FUNC +static pcc_thunk_chunk_t *pcc_thunk_chunk__create(pcc_auxil_t auxil) { + pcc_thunk_chunk_t *const chunk = (pcc_thunk_chunk_t *)PCC_MALLOC(auxil, sizeof(pcc_thunk_chunk_t)); + pcc_value_table__init(auxil, &chunk->values); + pcc_capture_table__init(auxil, &chunk->capts); + pcc_thunk_array__init(auxil, &chunk->thunks); + chunk->pos = 0; + return chunk; +} + +static void pcc_thunk_chunk__destroy(pcc_auxil_t auxil, pcc_thunk_chunk_t *chunk) { + if (chunk == NULL) return; + pcc_thunk_array__term(auxil, &chunk->thunks); + pcc_capture_table__term(auxil, &chunk->capts); + pcc_value_table__term(auxil, &chunk->values); + PCC_FREE(auxil, chunk); +} + +static void pcc_rule_set__init(pcc_auxil_t auxil, pcc_rule_set_t *set) { + set->len = 0; + set->max = 0; + set->buf = NULL; +} + +static size_t pcc_rule_set__index(pcc_auxil_t auxil, const pcc_rule_set_t *set, pcc_rule_t rule) { + size_t i; + for (i = 0; i < set->len; i++) { + if (set->buf[i] == rule) return i; + } + return PCC_VOID_VALUE; +} + +static pcc_bool_t pcc_rule_set__add(pcc_auxil_t auxil, pcc_rule_set_t *set, pcc_rule_t rule) { + const size_t i = pcc_rule_set__index(auxil, set, rule); + if (i != PCC_VOID_VALUE) return PCC_FALSE; + if (set->max <= set->len) { + const size_t n = set->len + 1; + size_t m = set->max; + if (m == 0) m = PCC_ARRAYSIZE; + while (m < n && m != 0) m <<= 1; + if (m == 0) m = n; + set->buf = (pcc_rule_t *)PCC_REALLOC(auxil, set->buf, sizeof(pcc_rule_t) * m); + set->max = m; + } + set->buf[set->len++] = rule; + return PCC_TRUE; +} + +static pcc_bool_t pcc_rule_set__remove(pcc_auxil_t auxil, pcc_rule_set_t *set, pcc_rule_t rule) { + const size_t i = pcc_rule_set__index(auxil, set, rule); + if (i == PCC_VOID_VALUE) return PCC_FALSE; + memmove(set->buf + i, set->buf + (i + 1), sizeof(pcc_rule_t) * (set->len - (i + 1))); + return PCC_TRUE; +} + +static void pcc_rule_set__clear(pcc_auxil_t auxil, pcc_rule_set_t *set) { + set->len = 0; +} + +static void pcc_rule_set__copy(pcc_auxil_t auxil, pcc_rule_set_t *set, const pcc_rule_set_t *src) { + size_t i; + pcc_rule_set__clear(auxil, set); + for (i = 0; i < src->len; i++) { + pcc_rule_set__add(auxil, set, src->buf[i]); + } +} + +static void pcc_rule_set__term(pcc_auxil_t auxil, pcc_rule_set_t *set) { + PCC_FREE(auxil, set->buf); +} + +static pcc_lr_head_t *pcc_lr_head__create(pcc_auxil_t auxil, pcc_rule_t rule) { + pcc_lr_head_t *const head = (pcc_lr_head_t *)PCC_MALLOC(auxil, sizeof(pcc_lr_head_t)); + head->rule = rule; + pcc_rule_set__init(auxil, &head->invol); + pcc_rule_set__init(auxil, &head->eval); + head->hold = NULL; + return head; +} + +static void pcc_lr_head__destroy(pcc_auxil_t auxil, pcc_lr_head_t *head) { + if (head == NULL) return; + pcc_lr_head__destroy(auxil, head->hold); + pcc_rule_set__term(auxil, &head->eval); + pcc_rule_set__term(auxil, &head->invol); + PCC_FREE(auxil, head); +} + +static void pcc_lr_entry__destroy(pcc_auxil_t auxil, pcc_lr_entry_t *lr); + +static pcc_lr_answer_t *pcc_lr_answer__create(pcc_auxil_t auxil, pcc_lr_answer_type_t type, size_t pos) { + pcc_lr_answer_t *answer = (pcc_lr_answer_t *)PCC_MALLOC(auxil, sizeof(pcc_lr_answer_t)); + answer->type = type; + answer->pos = pos; + answer->hold = NULL; + switch (answer->type) { + case PCC_LR_ANSWER_LR: + answer->data.lr = NULL; + break; + case PCC_LR_ANSWER_CHUNK: + answer->data.chunk = NULL; + break; + default: /* unknown */ + PCC_FREE(auxil, answer); + answer = NULL; + } + return answer; +} + +static void pcc_lr_answer__set_chunk(pcc_auxil_t auxil, pcc_lr_answer_t *answer, pcc_thunk_chunk_t *chunk) { + pcc_lr_answer_t *const a = pcc_lr_answer__create(auxil, answer->type, answer->pos); + switch (answer->type) { + case PCC_LR_ANSWER_LR: + a->data.lr = answer->data.lr; + break; + case PCC_LR_ANSWER_CHUNK: + a->data.chunk = answer->data.chunk; + break; + default: /* unknown */ + break; + } + a->hold = answer->hold; + answer->hold = a; + answer->type = PCC_LR_ANSWER_CHUNK; + answer->data.chunk = chunk; +} + +static void pcc_lr_answer__destroy(pcc_auxil_t auxil, pcc_lr_answer_t *answer) { + while (answer != NULL) { + pcc_lr_answer_t *const a = answer->hold; + switch (answer->type) { + case PCC_LR_ANSWER_LR: + pcc_lr_entry__destroy(auxil, answer->data.lr); + break; + case PCC_LR_ANSWER_CHUNK: + pcc_thunk_chunk__destroy(auxil, answer->data.chunk); + break; + default: /* unknown */ + break; + } + PCC_FREE(auxil, answer); + answer = a; + } +} + +static void pcc_lr_memo_map__init(pcc_auxil_t auxil, pcc_lr_memo_map_t *map) { + map->len = 0; + map->max = 0; + map->buf = NULL; +} + +static size_t pcc_lr_memo_map__index(pcc_auxil_t auxil, pcc_lr_memo_map_t *map, pcc_rule_t rule) { + size_t i; + for (i = 0; i < map->len; i++) { + if (map->buf[i].rule == rule) return i; + } + return PCC_VOID_VALUE; +} + +static void pcc_lr_memo_map__put(pcc_auxil_t auxil, pcc_lr_memo_map_t *map, pcc_rule_t rule, pcc_lr_answer_t *answer) { + const size_t i = pcc_lr_memo_map__index(auxil, map, rule); + if (i != PCC_VOID_VALUE) { + pcc_lr_answer__destroy(auxil, map->buf[i].answer); + map->buf[i].answer = answer; + } + else { + if (map->max <= map->len) { + const size_t n = map->len + 1; + size_t m = map->max; + if (m == 0) m = PCC_ARRAYSIZE; + while (m < n && m != 0) m <<= 1; + if (m == 0) m = n; + map->buf = (pcc_lr_memo_t *)PCC_REALLOC(auxil, map->buf, sizeof(pcc_lr_memo_t) * m); + map->max = m; + } + map->buf[map->len].rule = rule; + map->buf[map->len].answer = answer; + map->len++; + } +} + +static pcc_lr_answer_t *pcc_lr_memo_map__get(pcc_auxil_t auxil, pcc_lr_memo_map_t *map, pcc_rule_t rule) { + const size_t i = pcc_lr_memo_map__index(auxil, map, rule); + return (i != PCC_VOID_VALUE) ? map->buf[i].answer : NULL; +} + +static void pcc_lr_memo_map__term(pcc_auxil_t auxil, pcc_lr_memo_map_t *map) { + while (map->len > 0) { + map->len--; + pcc_lr_answer__destroy(auxil, map->buf[map->len].answer); + } + PCC_FREE(auxil, map->buf); +} + +static pcc_lr_table_entry_t *pcc_lr_table_entry__create(pcc_auxil_t auxil) { + pcc_lr_table_entry_t *const entry = (pcc_lr_table_entry_t *)PCC_MALLOC(auxil, sizeof(pcc_lr_table_entry_t)); + entry->head = NULL; + pcc_lr_memo_map__init(auxil, &entry->memos); + entry->hold_a = NULL; + entry->hold_h = NULL; + return entry; +} + +static void pcc_lr_table_entry__destroy(pcc_auxil_t auxil, pcc_lr_table_entry_t *entry) { + if (entry == NULL) return; + pcc_lr_head__destroy(auxil, entry->hold_h); + pcc_lr_answer__destroy(auxil, entry->hold_a); + pcc_lr_memo_map__term(auxil, &entry->memos); + PCC_FREE(auxil, entry); +} + +static void pcc_lr_table__init(pcc_auxil_t auxil, pcc_lr_table_t *table) { + table->ofs = 0; + table->len = 0; + table->max = 0; + table->buf = NULL; +} + +static void pcc_lr_table__resize(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t len) { + size_t i; + for (i = len; i < table->len; i++) pcc_lr_table_entry__destroy(auxil, table->buf[i]); + if (table->max < len) { + size_t m = table->max; + if (m == 0) m = PCC_ARRAYSIZE; + while (m < len && m != 0) m <<= 1; + if (m == 0) m = len; + table->buf = (pcc_lr_table_entry_t **)PCC_REALLOC(auxil, table->buf, sizeof(pcc_lr_table_entry_t *) * m); + table->max = m; + } + for (i = table->len; i < len; i++) table->buf[i] = NULL; + table->len = len; +} + +static void pcc_lr_table__set_head(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t index, pcc_lr_head_t *head) { + index += table->ofs; + if (index >= table->len) pcc_lr_table__resize(auxil, table, index + 1); + if (table->buf[index] == NULL) table->buf[index] = pcc_lr_table_entry__create(auxil); + table->buf[index]->head = head; +} + +static void pcc_lr_table__hold_head(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t index, pcc_lr_head_t *head) { + index += table->ofs; + if (index >= table->len) pcc_lr_table__resize(auxil, table, index + 1); + if (table->buf[index] == NULL) table->buf[index] = pcc_lr_table_entry__create(auxil); + head->hold = table->buf[index]->hold_h; + table->buf[index]->hold_h = head; +} + +static void pcc_lr_table__set_answer(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t index, pcc_rule_t rule, pcc_lr_answer_t *answer) { + index += table->ofs; + if (index >= table->len) pcc_lr_table__resize(auxil, table, index + 1); + if (table->buf[index] == NULL) table->buf[index] = pcc_lr_table_entry__create(auxil); + pcc_lr_memo_map__put(auxil, &table->buf[index]->memos, rule, answer); +} + +static void pcc_lr_table__hold_answer(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t index, pcc_lr_answer_t *answer) { + index += table->ofs; + if (index >= table->len) pcc_lr_table__resize(auxil, table, index + 1); + if (table->buf[index] == NULL) table->buf[index] = pcc_lr_table_entry__create(auxil); + answer->hold = table->buf[index]->hold_a; + table->buf[index]->hold_a = answer; +} + +static pcc_lr_head_t *pcc_lr_table__get_head(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t index) { + index += table->ofs; + if (index >= table->len || table->buf[index] == NULL) return NULL; + return table->buf[index]->head; +} + +static pcc_lr_answer_t *pcc_lr_table__get_answer(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t index, pcc_rule_t rule) { + index += table->ofs; + if (index >= table->len || table->buf[index] == NULL) return NULL; + return pcc_lr_memo_map__get(auxil, &table->buf[index]->memos, rule); +} + +static void pcc_lr_table__shift(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t count) { + size_t i; + if (count > table->len - table->ofs) count = table->len - table->ofs; + for (i = 0; i < count; i++) pcc_lr_table_entry__destroy(auxil, table->buf[table->ofs++]); + if (table->ofs > (table->max >> 1)) { + memmove(table->buf, table->buf + table->ofs, sizeof(pcc_lr_table_entry_t *) * (table->len - table->ofs)); + table->len -= table->ofs; + table->ofs = 0; + } +} + +static void pcc_lr_table__term(pcc_auxil_t auxil, pcc_lr_table_t *table) { + while (table->len > table->ofs) { + table->len--; + pcc_lr_table_entry__destroy(auxil, table->buf[table->len]); + } + PCC_FREE(auxil, table->buf); +} + +static pcc_lr_entry_t *pcc_lr_entry__create(pcc_auxil_t auxil, pcc_rule_t rule) { + pcc_lr_entry_t *const lr = (pcc_lr_entry_t *)PCC_MALLOC(auxil, sizeof(pcc_lr_entry_t)); + lr->rule = rule; + lr->seed = NULL; + lr->head = NULL; + return lr; +} + +static void pcc_lr_entry__destroy(pcc_auxil_t auxil, pcc_lr_entry_t *lr) { + PCC_FREE(auxil, lr); +} + +static void pcc_lr_stack__init(pcc_auxil_t auxil, pcc_lr_stack_t *stack) { + stack->len = 0; + stack->max = 0; + stack->buf = NULL; +} + +static void pcc_lr_stack__push(pcc_auxil_t auxil, pcc_lr_stack_t *stack, pcc_lr_entry_t *lr) { + if (stack->max <= stack->len) { + const size_t n = stack->len + 1; + size_t m = stack->max; + if (m == 0) m = PCC_ARRAYSIZE; + while (m < n && m != 0) m <<= 1; + if (m == 0) m = n; + stack->buf = (pcc_lr_entry_t **)PCC_REALLOC(auxil, stack->buf, sizeof(pcc_lr_entry_t *) * m); + stack->max = m; + } + stack->buf[stack->len++] = lr; +} + +static pcc_lr_entry_t *pcc_lr_stack__pop(pcc_auxil_t auxil, pcc_lr_stack_t *stack) { + return stack->buf[--stack->len]; +} + +static void pcc_lr_stack__term(pcc_auxil_t auxil, pcc_lr_stack_t *stack) { + PCC_FREE(auxil, stack->buf); +} + +static pelm_context_t *pcc_context__create(pcc_auxil_t auxil) { + pelm_context_t *const ctx = (pelm_context_t *)PCC_MALLOC(auxil, sizeof(pelm_context_t)); + ctx->pos = 0; + ctx->cur = 0; + ctx->level = 0; + pcc_char_array__init(auxil, &ctx->buffer); + pcc_lr_table__init(auxil, &ctx->lrtable); + pcc_lr_stack__init(auxil, &ctx->lrstack); + pcc_thunk_array__init(auxil, &ctx->thunks); + ctx->auxil = auxil; + return ctx; +} + +static void pcc_context__destroy(pelm_context_t *ctx) { + if (ctx == NULL) return; + pcc_thunk_array__term(ctx->auxil, &ctx->thunks); + pcc_lr_stack__term(ctx->auxil, &ctx->lrstack); + pcc_lr_table__term(ctx->auxil, &ctx->lrtable); + pcc_char_array__term(ctx->auxil, &ctx->buffer); + PCC_FREE(ctx->auxil, ctx); +} + +static size_t pcc_refill_buffer(pelm_context_t *ctx, size_t num) { + if (ctx->buffer.len >= ctx->cur + num) return ctx->buffer.len - ctx->cur; + while (ctx->buffer.len < ctx->cur + num) { + const int c = PCC_GETCHAR(ctx->auxil); + if (c < 0) break; + pcc_char_array__add(ctx->auxil, &ctx->buffer, (char)c); + } + return ctx->buffer.len - ctx->cur; +} + +MARK_USED_FUNC +static void pcc_commit_buffer(pelm_context_t *ctx) { + memmove(ctx->buffer.buf, ctx->buffer.buf + ctx->cur, ctx->buffer.len - ctx->cur); + ctx->buffer.len -= ctx->cur; + ctx->pos += ctx->cur; + pcc_lr_table__shift(ctx->auxil, &ctx->lrtable, ctx->cur); + ctx->cur = 0; +} + +MARK_USED_FUNC +static const char *pcc_get_capture_string(pelm_context_t *ctx, const pcc_capture_t *capt) { + if (capt->string == NULL) + ((pcc_capture_t *)capt)->string = + pcc_strndup_e(ctx->auxil, ctx->buffer.buf + capt->range.start, capt->range.end - capt->range.start); + return capt->string; +} + +static size_t pcc_get_char_as_utf32(pelm_context_t *ctx, int *out) { /* with checking UTF-8 validity */ + int c, u; + size_t n; + if (pcc_refill_buffer(ctx, 1) < 1) return 0; + c = (int)(unsigned char)ctx->buffer.buf[ctx->cur]; + n = (c < 0x80) ? 1 : + ((c & 0xe0) == 0xc0) ? 2 : + ((c & 0xf0) == 0xe0) ? 3 : + ((c & 0xf8) == 0xf0) ? 4 : 0; + if (n < 1) return 0; + if (pcc_refill_buffer(ctx, n) < n) return 0; + switch (n) { + case 1: + u = c; + break; + case 2: + u = c & 0x1f; + c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 1]; + if ((c & 0xc0) != 0x80) return 0; + u <<= 6; u |= c & 0x3f; + if (u < 0x80) return 0; + break; + case 3: + u = c & 0x0f; + c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 1]; + if ((c & 0xc0) != 0x80) return 0; + u <<= 6; u |= c & 0x3f; + c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 2]; + if ((c & 0xc0) != 0x80) return 0; + u <<= 6; u |= c & 0x3f; + if (u < 0x800) return 0; + break; + case 4: + u = c & 0x07; + c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 1]; + if ((c & 0xc0) != 0x80) return 0; + u <<= 6; u |= c & 0x3f; + c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 2]; + if ((c & 0xc0) != 0x80) return 0; + u <<= 6; u |= c & 0x3f; + c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 3]; + if ((c & 0xc0) != 0x80) return 0; + u <<= 6; u |= c & 0x3f; + if (u < 0x10000 || u > 0x10ffff) return 0; + break; + default: + return 0; + } + if (out) *out = u; + return n; +} + +MARK_USED_FUNC +static pcc_bool_t pcc_apply_rule(pelm_context_t *ctx, pcc_rule_t rule, pcc_thunk_array_t *thunks, pcc_value_t *value) { + static pcc_value_t null; + pcc_thunk_chunk_t *c = NULL; + const size_t p = ctx->pos + ctx->cur; + pcc_bool_t b = PCC_TRUE; + pcc_lr_answer_t *a = pcc_lr_table__get_answer(ctx->auxil, &ctx->lrtable, p, rule); + pcc_lr_head_t *h = pcc_lr_table__get_head(ctx->auxil, &ctx->lrtable, p); + if (h != NULL) { + if (a == NULL && rule != h->rule && pcc_rule_set__index(ctx->auxil, &h->invol, rule) == PCC_VOID_VALUE) { + b = PCC_FALSE; + c = NULL; + } + else if (pcc_rule_set__remove(ctx->auxil, &h->eval, rule)) { + b = PCC_FALSE; + c = rule(ctx); + a = pcc_lr_answer__create(ctx->auxil, PCC_LR_ANSWER_CHUNK, ctx->pos + ctx->cur); + a->data.chunk = c; + pcc_lr_table__hold_answer(ctx->auxil, &ctx->lrtable, p, a); + } + } + if (b) { + if (a != NULL) { + ctx->cur = a->pos - ctx->pos; + switch (a->type) { + case PCC_LR_ANSWER_LR: + if (a->data.lr->head == NULL) { + a->data.lr->head = pcc_lr_head__create(ctx->auxil, rule); + pcc_lr_table__hold_head(ctx->auxil, &ctx->lrtable, p, a->data.lr->head); + } + { + size_t i = ctx->lrstack.len; + while (i > 0) { + i--; + if (ctx->lrstack.buf[i]->head == a->data.lr->head) break; + ctx->lrstack.buf[i]->head = a->data.lr->head; + pcc_rule_set__add(ctx->auxil, &a->data.lr->head->invol, ctx->lrstack.buf[i]->rule); + } + } + c = a->data.lr->seed; + break; + case PCC_LR_ANSWER_CHUNK: + c = a->data.chunk; + break; + default: /* unknown */ + break; + } + } + else { + pcc_lr_entry_t *const e = pcc_lr_entry__create(ctx->auxil, rule); + pcc_lr_stack__push(ctx->auxil, &ctx->lrstack, e); + a = pcc_lr_answer__create(ctx->auxil, PCC_LR_ANSWER_LR, p); + a->data.lr = e; + pcc_lr_table__set_answer(ctx->auxil, &ctx->lrtable, p, rule, a); + c = rule(ctx); + pcc_lr_stack__pop(ctx->auxil, &ctx->lrstack); + a->pos = ctx->pos + ctx->cur; + if (e->head == NULL) { + pcc_lr_answer__set_chunk(ctx->auxil, a, c); + } + else { + e->seed = c; + h = a->data.lr->head; + if (h->rule != rule) { + c = a->data.lr->seed; + a = pcc_lr_answer__create(ctx->auxil, PCC_LR_ANSWER_CHUNK, ctx->pos + ctx->cur); + a->data.chunk = c; + pcc_lr_table__hold_answer(ctx->auxil, &ctx->lrtable, p, a); + } + else { + pcc_lr_answer__set_chunk(ctx->auxil, a, a->data.lr->seed); + if (a->data.chunk == NULL) { + c = NULL; + } + else { + pcc_lr_table__set_head(ctx->auxil, &ctx->lrtable, p, h); + for (;;) { + ctx->cur = p - ctx->pos; + pcc_rule_set__copy(ctx->auxil, &h->eval, &h->invol); + c = rule(ctx); + if (c == NULL || ctx->pos + ctx->cur <= a->pos) break; + pcc_lr_answer__set_chunk(ctx->auxil, a, c); + a->pos = ctx->pos + ctx->cur; + } + pcc_thunk_chunk__destroy(ctx->auxil, c); + pcc_lr_table__set_head(ctx->auxil, &ctx->lrtable, p, NULL); + ctx->cur = a->pos - ctx->pos; + c = a->data.chunk; + } + } + } + } + } + if (c == NULL) return PCC_FALSE; + if (value == NULL) value = &null; + memset(value, 0, sizeof(pcc_value_t)); /* in case */ + pcc_thunk_array__add(ctx->auxil, thunks, pcc_thunk__create_node(ctx->auxil, &c->thunks, value)); + return PCC_TRUE; +} + +MARK_USED_FUNC +static void pcc_do_action(pelm_context_t *ctx, const pcc_thunk_array_t *thunks, pcc_value_t *value) { + size_t i; + for (i = 0; i < thunks->len; i++) { + pcc_thunk_t *const thunk = thunks->buf[i]; + switch (thunk->type) { + case PCC_THUNK_LEAF: + thunk->data.leaf.action(ctx, thunk, value); + break; + case PCC_THUNK_NODE: + pcc_do_action(ctx, thunk->data.node.thunks, thunk->data.node.value); + break; + default: /* unknown */ + break; + } + } +} + +static void pcc_action_file_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { +#define auxil (__pcc_ctx->auxil) +#define __ (*__pcc_out) +#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) +#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) +#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) + ELM_INIT_MODULE_SCOPE; +#undef _0e +#undef _0s +#undef _0 +#undef __ +#undef auxil +} + +static void pcc_action_moduleDeclaration_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { +#define auxil (__pcc_ctx->auxil) +#define __ (*__pcc_out) +#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) +#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) +#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) +#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) +#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) +#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) + elm_module_scope_index = makeElmTagSettingScope(auxil, _1, _1s, K_MODULE, ROLE_DEFINITION_INDEX); +#undef _1e +#undef _1s +#undef _1 +#undef _0e +#undef _0s +#undef _0 +#undef __ +#undef auxil +} + +static void pcc_action_typeAlias_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { +#define auxil (__pcc_ctx->auxil) +#define __ (*__pcc_out) +#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) +#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) +#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) +#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) +#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) +#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) + makeElmTag(auxil, _1, _1s, K_ALIAS, ROLE_DEFINITION_INDEX); +#undef _1e +#undef _1s +#undef _1 +#undef _0e +#undef _0s +#undef _0 +#undef __ +#undef auxil +} + +static void pcc_action_customType_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { +#define auxil (__pcc_ctx->auxil) +#define __ (*__pcc_out) +#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) +#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) +#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) +#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) +#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) +#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) + makeElmTagSettingScope(auxil, _1, _1s, K_TYPE, ROLE_DEFINITION_INDEX); +#undef _1e +#undef _1s +#undef _1 +#undef _0e +#undef _0s +#undef _0 +#undef __ +#undef auxil +} + +static void pcc_action_customType_1(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { +#define auxil (__pcc_ctx->auxil) +#define __ (*__pcc_out) +#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) +#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) +#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) +#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) +#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) +#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) + POP_KIND(auxil, true); +#undef _1e +#undef _1s +#undef _1 +#undef _0e +#undef _0s +#undef _0 +#undef __ +#undef auxil +} + +static void pcc_action_constructorList_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { +#define auxil (__pcc_ctx->auxil) +#define __ (*__pcc_out) +#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) +#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) +#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) +#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) +#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) +#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) +#define _2 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[1]) +#define _2s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.start)) +#define _2e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.end)) + int r = makeElmTag(auxil, _1, _1s, K_CONSTRUCTOR, ROLE_DEFINITION_INDEX); + addElmSignature(r, _2); +#undef _2e +#undef _2s +#undef _2 +#undef _1e +#undef _1s +#undef _1 +#undef _0e +#undef _0s +#undef _0 +#undef __ +#undef auxil +} + +static void pcc_action_portDeclaration_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { +#define auxil (__pcc_ctx->auxil) +#define __ (*__pcc_out) +#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) +#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) +#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) +#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) +#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) +#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) +#define _2 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[1]) +#define _2s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.start)) +#define _2e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.end)) + int r = makeElmTag(auxil, _1, _1s, K_PORT, ROLE_DEFINITION_INDEX); + addElmSignature(r, _2); +#undef _2e +#undef _2s +#undef _2 +#undef _1e +#undef _1s +#undef _1 +#undef _0e +#undef _0s +#undef _0 +#undef __ +#undef auxil +} + +static void pcc_action_importStatement_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { +#define auxil (__pcc_ctx->auxil) +#define __ (*__pcc_out) +#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) +#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) +#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) +#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) +#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) +#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) +#define _2 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[1]) +#define _2s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.start)) +#define _2e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.end)) + // Make the namespace tag first, as it's in the file module's scope + if (_2s > 0) { + int r = makeElmTag(auxil, _2, _2s, K_NAMESPACE, ROLE_DEFINITION_INDEX); + attachParserFieldToCorkEntry (r, ElmFields[F_MODULENAME].ftype, _1); + } + + // Now make the tag for the imported module, as it lives outside + // the scope of the file module + ELM_SAVE_MODULE_SCOPE; + makeElmTagSettingScope(auxil, _1, _1s, K_MODULE, ELM_ROLE_IMPORTED); +#undef _2e +#undef _2s +#undef _2 +#undef _1e +#undef _1s +#undef _1 +#undef _0e +#undef _0s +#undef _0 +#undef __ +#undef auxil +} + +static void pcc_action_importStatement_1(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { +#define auxil (__pcc_ctx->auxil) +#define __ (*__pcc_out) +#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) +#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) +#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) +#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) +#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) +#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) +#define _2 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[1]) +#define _2s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.start)) +#define _2e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.end)) + ELM_RESTORE_MODULE_SCOPE; +#undef _2e +#undef _2s +#undef _2 +#undef _1e +#undef _1s +#undef _1 +#undef _0e +#undef _0s +#undef _0 +#undef __ +#undef auxil +} + +static void pcc_action_importedFunction_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { +#define auxil (__pcc_ctx->auxil) +#define __ (*__pcc_out) +#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) +#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) +#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) +#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) +#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) +#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) + makeElmTag(auxil, _1, _1s, K_FUNCTION, ELM_ROLE_IMPORTED); +#undef _1e +#undef _1s +#undef _1 +#undef _0e +#undef _0s +#undef _0 +#undef __ +#undef auxil +} + +static void pcc_action_importedType_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { +#define auxil (__pcc_ctx->auxil) +#define __ (*__pcc_out) +#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) +#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) +#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) +#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) +#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) +#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) + makeElmTagSettingScope(auxil, _1, _1s, K_TYPE, ELM_ROLE_IMPORTED); +#undef _1e +#undef _1s +#undef _1 +#undef _0e +#undef _0s +#undef _0 +#undef __ +#undef auxil +} + +static void pcc_action_importedType_1(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { +#define auxil (__pcc_ctx->auxil) +#define __ (*__pcc_out) +#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) +#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) +#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) +#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) +#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) +#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) + // We're done with the type and its constructors, so we can pop it + POP_SCOPE(auxil); +#undef _1e +#undef _1s +#undef _1 +#undef _0e +#undef _0s +#undef _0 +#undef __ +#undef auxil +} + +static void pcc_action_importedTypeConstructor_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { +#define auxil (__pcc_ctx->auxil) +#define __ (*__pcc_out) +#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) +#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) +#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) +#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) +#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) +#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) + makeElmTag(auxil, _1, _1s, K_CONSTRUCTOR, ELM_ROLE_IMPORTED); +#undef _1e +#undef _1s +#undef _1 +#undef _0e +#undef _0s +#undef _0 +#undef __ +#undef auxil +} + +static void pcc_action_functionWithTypeAnnotation_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { +#define auxil (__pcc_ctx->auxil) +#define __ (*__pcc_out) +#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) +#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) +#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) +#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) +#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) +#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) +#define _2 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[1]) +#define _2s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.start)) +#define _2e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.end)) +#define _3 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[2]) +#define _3s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[2]->range.start)) +#define _3e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[2]->range.end)) + int r = makeElmTagSettingScope(auxil, _3, _3s, K_FUNCTION, ROLE_DEFINITION_INDEX); + addElmSignature(r, _2); +#undef _3e +#undef _3s +#undef _3 +#undef _2e +#undef _2s +#undef _2 +#undef _1e +#undef _1s +#undef _1 +#undef _0e +#undef _0s +#undef _0 +#undef __ +#undef auxil +} + +static void pcc_action_functionWithTypeAnnotation_1(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { +#define auxil (__pcc_ctx->auxil) +#define __ (*__pcc_out) +#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) +#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) +#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) +#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) +#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) +#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) +#define _2 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[1]) +#define _2s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.start)) +#define _2e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.end)) +#define _3 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[2]) +#define _3s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[2]->range.start)) +#define _3e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[2]->range.end)) + POP_SCOPE(auxil); +#undef _3e +#undef _3s +#undef _3 +#undef _2e +#undef _2s +#undef _2 +#undef _1e +#undef _1s +#undef _1 +#undef _0e +#undef _0s +#undef _0 +#undef __ +#undef auxil +} + +static void pcc_action_functionDefinition_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { +#define auxil (__pcc_ctx->auxil) +#define __ (*__pcc_out) +#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) +#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) +#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) +#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) +#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) +#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) + makeElmTagSettingScope(auxil, _1, _1s, K_FUNCTION, ROLE_DEFINITION_INDEX); +#undef _1e +#undef _1s +#undef _1 +#undef _0e +#undef _0s +#undef _0 +#undef __ +#undef auxil +} + +static void pcc_action_functionDefinition_1(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { +#define auxil (__pcc_ctx->auxil) +#define __ (*__pcc_out) +#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) +#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) +#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) +#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) +#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) +#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) + POP_SCOPE(auxil); +#undef _1e +#undef _1s +#undef _1 +#undef _0e +#undef _0s +#undef _0 +#undef __ +#undef auxil +} + +static void pcc_action_letInFunctionDefinition_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { +#define auxil (__pcc_ctx->auxil) +#define __ (*__pcc_out) +#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) +#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) +#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) +#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) +#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) +#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) + makeElmTag(auxil, _1, _1s, K_FUNCTION, ROLE_DEFINITION_INDEX); +#undef _1e +#undef _1s +#undef _1 +#undef _0e +#undef _0s +#undef _0 +#undef __ +#undef auxil +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_file(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_mainTopLevelStatements(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_topLevelStatement(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_moduleDeclaration(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedList(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedItem(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedFieldOrType(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedFunction(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedItemIgnored(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedTypeConstructorList(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_typeAlias(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_customType(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_typeParameterList(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_constructorList(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_constructorTypes(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_singleTypeSpec(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_recordTypeSpec(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_recordRestrictionPrefix(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_fieldSpec(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_tupleTypeSpec(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_parameterisedTypeSpec(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_functionTypeSpec(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_portDeclaration(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_importStatement(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_importedList(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_importedItem(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_importedFunction(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_importedType(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_importedItemIgnored(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_importedTypeConstructorList(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_importedTypeConstructor(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_functionWithTypeAnnotation(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_typeAnnotation(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_functionDefinition(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_functionParameterList(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_functionParameter(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_plainFunctionParameter(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_tupleFunctionParameter(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_recordFunctionParameter(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_constructorFunctionParameter(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_asClause(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_expression(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_simpleExpression(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_tupleExpression(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_listExpression(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_recordExpression(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_recordExpressionAssignment(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_anonymousFunction(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_functionCall(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_letInBlock(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_letInLine(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_letInFunctionDefinition(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_letInFunctionBody(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_caseStatement(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_caseClauseList(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_caseClause(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_roughCasePatternChar(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_ifThenElseStatement(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_binaryOperator(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_ignoreRestOfStatement(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_multilineString(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_naiveIdentifier(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_upperStartIdentifier(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_lowerStartIdentifier(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_alphanumeric(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_nonKeywordIdentifier(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_keyword(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_dottedIdentifier(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_decimal(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_exponentialDecimal(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_simpleDecimal(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_simpleInteger(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_digits(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_hexNumber(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_oneLineString(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_characterLiteral(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_inStringChar(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_inStringPlainChar(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_inStringEscapedChar(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_inStringUnicodeChar(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_WS(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_NL(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_Non_NL(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_Non_WS_or_NL(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_EOF(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_delimitedComment(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_lineComment(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule__1_short(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule__1_(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule__0_(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_TLSS_short(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_TLSS(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule_EOS(pelm_context_t *ctx); +static pcc_thunk_chunk_t *pcc_evaluate_rule__NL_IND_(pelm_context_t *ctx); + +static pcc_thunk_chunk_t *pcc_evaluate_rule_file(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "file", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_file_0, 0, 0); + thunk->data.leaf.capt0.range.start = chunk->pos; + thunk->data.leaf.capt0.range.end = ctx->cur; + pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); + } + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_TLSS, &chunk->thunks, NULL)) goto L0001; + goto L0002; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0002:; + } + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_moduleDeclaration, &chunk->thunks, NULL)) goto L0003; + goto L0004; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0004:; + } + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_TLSS, &chunk->thunks, NULL)) goto L0005; + goto L0006; + L0005:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0006:; + } + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_mainTopLevelStatements, &chunk->thunks, NULL)) goto L0007; + goto L0008; + L0007:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0008:; + } + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_TLSS, &chunk->thunks, NULL)) goto L0009; + goto L0010; + L0009:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0010:; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_EOF, &chunk->thunks, NULL)) goto L0000; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "file", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "file", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_mainTopLevelStatements(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "mainTopLevelStatements", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_topLevelStatement, &chunk->thunks, NULL)) goto L0000; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_TLSS, &chunk->thunks, NULL)) goto L0001; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_topLevelStatement, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "mainTopLevelStatements", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "mainTopLevelStatements", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_topLevelStatement(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "topLevelStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importStatement, &chunk->thunks, NULL)) goto L0002; + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_typeAlias, &chunk->thunks, NULL)) goto L0003; + goto L0001; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_customType, &chunk->thunks, NULL)) goto L0004; + goto L0001; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_portDeclaration, &chunk->thunks, NULL)) goto L0005; + goto L0001; + L0005:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionWithTypeAnnotation, &chunk->thunks, NULL)) goto L0006; + goto L0001; + L0006:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionDefinition, &chunk->thunks, NULL)) goto L0007; + goto L0001; + L0007:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_ignoreRestOfStatement, &chunk->thunks, NULL)) goto L0008; + goto L0001; + L0008:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0001:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "topLevelStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "topLevelStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_moduleDeclaration(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "moduleDeclaration", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 4) < 4 || + (ctx->buffer.buf + ctx->cur)[0] != 'p' || + (ctx->buffer.buf + ctx->cur)[1] != 'o' || + (ctx->buffer.buf + ctx->cur)[2] != 'r' || + (ctx->buffer.buf + ctx->cur)[3] != 't' + ) goto L0001; + ctx->cur += 4; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0001; + goto L0002; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0002:; + } + if ( + pcc_refill_buffer(ctx, 6) < 6 || + (ctx->buffer.buf + ctx->cur)[0] != 'm' || + (ctx->buffer.buf + ctx->cur)[1] != 'o' || + (ctx->buffer.buf + ctx->cur)[2] != 'd' || + (ctx->buffer.buf + ctx->cur)[3] != 'u' || + (ctx->buffer.buf + ctx->cur)[4] != 'l' || + (ctx->buffer.buf + ctx->cur)[5] != 'e' + ) goto L0000; + ctx->cur += 6; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; + { + const size_t p = ctx->cur; + size_t q; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_dottedIdentifier, &chunk->thunks, NULL)) goto L0000; + q = ctx->cur; + chunk->capts.buf[0].range.start = p; + chunk->capts.buf[0].range.end = q; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 8) < 8 || + (ctx->buffer.buf + ctx->cur)[0] != 'e' || + (ctx->buffer.buf + ctx->cur)[1] != 'x' || + (ctx->buffer.buf + ctx->cur)[2] != 'p' || + (ctx->buffer.buf + ctx->cur)[3] != 'o' || + (ctx->buffer.buf + ctx->cur)[4] != 's' || + (ctx->buffer.buf + ctx->cur)[5] != 'i' || + (ctx->buffer.buf + ctx->cur)[6] != 'n' || + (ctx->buffer.buf + ctx->cur)[7] != 'g' + ) goto L0000; + ctx->cur += 8; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '(' + ) goto L0000; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_exposedList, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ')' + ) goto L0000; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_EOS, &chunk->thunks, NULL)) goto L0000; + { + pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_moduleDeclaration_0, 0, 1); + thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); + thunk->data.leaf.capt0.range.start = chunk->pos; + thunk->data.leaf.capt0.range.end = ctx->cur; + pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "moduleDeclaration", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "moduleDeclaration", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedList(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "exposedList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_exposedItem, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ',' + ) goto L0001; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_exposedList, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "exposedList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "exposedList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedItem(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "exposedItem", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_exposedFieldOrType, &chunk->thunks, NULL)) goto L0002; + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_exposedFunction, &chunk->thunks, NULL)) goto L0003; + goto L0001; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_exposedItemIgnored, &chunk->thunks, NULL)) goto L0004; + goto L0001; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0001:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "exposedItem", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "exposedItem", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedFieldOrType(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "exposedFieldOrType", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1); + { + const size_t p = ctx->cur; + size_t q; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_upperStartIdentifier, &chunk->thunks, NULL)) goto L0000; + q = ctx->cur; + chunk->capts.buf[0].range.start = p; + chunk->capts.buf[0].range.end = q; + } + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '(' + ) goto L0001; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_exposedTypeConstructorList, &chunk->thunks, NULL)) goto L0001; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ')' + ) goto L0001; + ctx->cur++; + goto L0002; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0002:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "exposedFieldOrType", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "exposedFieldOrType", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedFunction(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "exposedFunction", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "exposedFunction", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "exposedFunction", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedItemIgnored(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "exposedItemIgnored", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p0 = ctx->cur; + const size_t n0 = chunk->thunks.len; + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '.' + ) goto L0001; + ctx->cur++; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + if (i < 1) { + ctx->cur = p0; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); + goto L0000; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "exposedItemIgnored", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "exposedItemIgnored", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedTypeConstructorList(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "exposedTypeConstructorList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_upperStartIdentifier, &chunk->thunks, NULL)) goto L0002; + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_exposedItemIgnored, &chunk->thunks, NULL)) goto L0003; + goto L0001; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0001:; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ',' + ) goto L0004; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0004; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_exposedTypeConstructorList, &chunk->thunks, NULL)) goto L0004; + if (ctx->cur == p) break; + continue; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "exposedTypeConstructorList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "exposedTypeConstructorList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_typeAlias(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "typeAlias", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1); + if ( + pcc_refill_buffer(ctx, 4) < 4 || + (ctx->buffer.buf + ctx->cur)[0] != 't' || + (ctx->buffer.buf + ctx->cur)[1] != 'y' || + (ctx->buffer.buf + ctx->cur)[2] != 'p' || + (ctx->buffer.buf + ctx->cur)[3] != 'e' + ) goto L0000; + ctx->cur += 4; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 5) < 5 || + (ctx->buffer.buf + ctx->cur)[0] != 'a' || + (ctx->buffer.buf + ctx->cur)[1] != 'l' || + (ctx->buffer.buf + ctx->cur)[2] != 'i' || + (ctx->buffer.buf + ctx->cur)[3] != 'a' || + (ctx->buffer.buf + ctx->cur)[4] != 's' + ) goto L0000; + ctx->cur += 5; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; + { + const size_t p = ctx->cur; + size_t q; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_upperStartIdentifier, &chunk->thunks, NULL)) goto L0000; + q = ctx->cur; + chunk->capts.buf[0].range.start = p; + chunk->capts.buf[0].range.end = q; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '=' + ) goto L0000; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_ignoreRestOfStatement, &chunk->thunks, NULL)) goto L0000; + { + pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_typeAlias_0, 0, 1); + thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); + thunk->data.leaf.capt0.range.start = chunk->pos; + thunk->data.leaf.capt0.range.end = ctx->cur; + pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "typeAlias", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "typeAlias", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_customType(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "customType", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1); + if ( + pcc_refill_buffer(ctx, 4) < 4 || + (ctx->buffer.buf + ctx->cur)[0] != 't' || + (ctx->buffer.buf + ctx->cur)[1] != 'y' || + (ctx->buffer.buf + ctx->cur)[2] != 'p' || + (ctx->buffer.buf + ctx->cur)[3] != 'e' + ) goto L0000; + ctx->cur += 4; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; + { + const size_t p = ctx->cur; + size_t q; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_upperStartIdentifier, &chunk->thunks, NULL)) goto L0000; + q = ctx->cur; + chunk->capts.buf[0].range.start = p; + chunk->capts.buf[0].range.end = q; + } + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_typeParameterList, &chunk->thunks, NULL)) goto L0001; + goto L0002; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0002:; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '=' + ) goto L0000; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + { + pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_customType_0, 0, 1); + thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); + thunk->data.leaf.capt0.range.start = chunk->pos; + thunk->data.leaf.capt0.range.end = ctx->cur; + pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_constructorList, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_EOS, &chunk->thunks, NULL)) goto L0000; + { + pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_customType_1, 0, 1); + thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); + thunk->data.leaf.capt0.range.start = chunk->pos; + thunk->data.leaf.capt0.range.end = ctx->cur; + pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "customType", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "customType", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_typeParameterList(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "typeParameterList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0001; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "typeParameterList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "typeParameterList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_constructorList(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "constructorList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 2); + { + const size_t p = ctx->cur; + size_t q; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_upperStartIdentifier, &chunk->thunks, NULL)) goto L0000; + q = ctx->cur; + chunk->capts.buf[0].range.start = p; + chunk->capts.buf[0].range.end = q; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + { + const size_t p = ctx->cur; + size_t q; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_constructorTypes, &chunk->thunks, NULL)) goto L0001; + q = ctx->cur; + chunk->capts.buf[1].range.start = p; + chunk->capts.buf[1].range.end = q; + } + goto L0002; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0002:; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '|' + ) goto L0003; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_constructorList, &chunk->thunks, NULL)) goto L0003; + goto L0004; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0004:; + } + { + pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_constructorList_0, 0, 2); + thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); + thunk->data.leaf.capts.buf[1] = &(chunk->capts.buf[1]); + thunk->data.leaf.capt0.range.start = chunk->pos; + thunk->data.leaf.capt0.range.end = ctx->cur; + pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "constructorList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "constructorList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_constructorTypes(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "constructorTypes", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_singleTypeSpec, &chunk->thunks, NULL)) goto L0000; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_constructorTypes, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "constructorTypes", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "constructorTypes", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_singleTypeSpec(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "singleTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_recordTypeSpec, &chunk->thunks, NULL)) goto L0002; + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_tupleTypeSpec, &chunk->thunks, NULL)) goto L0003; + goto L0001; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionTypeSpec, &chunk->thunks, NULL)) goto L0004; + goto L0001; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_parameterisedTypeSpec, &chunk->thunks, NULL)) goto L0005; + goto L0001; + L0005:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0001:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "singleTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "singleTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_recordTypeSpec(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "recordTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '{' + ) goto L0002; + ctx->cur++; + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_recordRestrictionPrefix, &chunk->thunks, NULL)) goto L0003; + goto L0004; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0004:; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_fieldSpec, &chunk->thunks, NULL)) goto L0002; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0005; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ',' + ) goto L0005; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0005; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_fieldSpec, &chunk->thunks, NULL)) goto L0005; + if (ctx->cur == p) break; + continue; + L0005:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '}' + ) goto L0002; + ctx->cur++; + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '{' + ) goto L0006; + ctx->cur++; + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0007; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_recordRestrictionPrefix, &chunk->thunks, NULL)) goto L0007; + goto L0008; + L0007:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0008:; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0006; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '}' + ) goto L0006; + ctx->cur++; + goto L0001; + L0006:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0001:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "recordTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "recordTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_recordRestrictionPrefix(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "recordRestrictionPrefix", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '|' + ) goto L0000; + ctx->cur++; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "recordRestrictionPrefix", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "recordRestrictionPrefix", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_fieldSpec(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "fieldSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ':' + ) goto L0000; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_singleTypeSpec, &chunk->thunks, NULL)) goto L0000; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "fieldSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "fieldSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_tupleTypeSpec(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "tupleTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '(' + ) goto L0002; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_singleTypeSpec, &chunk->thunks, NULL)) goto L0002; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ',' + ) goto L0003; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_singleTypeSpec, &chunk->thunks, NULL)) goto L0003; + if (ctx->cur == p) break; + continue; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ')' + ) goto L0002; + ctx->cur++; + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '(' + ) goto L0004; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0004; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ')' + ) goto L0004; + ctx->cur++; + goto L0001; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0001:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "tupleTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "tupleTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_parameterisedTypeSpec(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "parameterisedTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_dottedIdentifier, &chunk->thunks, NULL)) goto L0000; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0001; + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_singleTypeSpec, &chunk->thunks, NULL)) goto L0003; + goto L0002; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0004; + goto L0002; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0001; + L0002:; + } + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "parameterisedTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "parameterisedTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_functionTypeSpec(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "functionTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_singleTypeSpec, &chunk->thunks, NULL)) goto L0000; + { + const size_t p0 = ctx->cur; + const size_t n0 = chunk->thunks.len; + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '-' || + (ctx->buffer.buf + ctx->cur)[1] != '>' + ) goto L0001; + ctx->cur += 2; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_singleTypeSpec, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + if (i < 1) { + ctx->cur = p0; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); + goto L0000; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "functionTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "functionTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_portDeclaration(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "portDeclaration", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 2); + if ( + pcc_refill_buffer(ctx, 4) < 4 || + (ctx->buffer.buf + ctx->cur)[0] != 'p' || + (ctx->buffer.buf + ctx->cur)[1] != 'o' || + (ctx->buffer.buf + ctx->cur)[2] != 'r' || + (ctx->buffer.buf + ctx->cur)[3] != 't' + ) goto L0000; + ctx->cur += 4; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; + { + const size_t p = ctx->cur; + size_t q; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; + q = ctx->cur; + chunk->capts.buf[0].range.start = p; + chunk->capts.buf[0].range.end = q; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ':' + ) goto L0000; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + { + const size_t p = ctx->cur; + size_t q; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_typeAnnotation, &chunk->thunks, NULL)) goto L0000; + q = ctx->cur; + chunk->capts.buf[1].range.start = p; + chunk->capts.buf[1].range.end = q; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_EOS, &chunk->thunks, NULL)) goto L0000; + { + pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_portDeclaration_0, 0, 2); + thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); + thunk->data.leaf.capts.buf[1] = &(chunk->capts.buf[1]); + thunk->data.leaf.capt0.range.start = chunk->pos; + thunk->data.leaf.capt0.range.end = ctx->cur; + pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "portDeclaration", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "portDeclaration", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_importStatement(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "importStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 2); + if ( + pcc_refill_buffer(ctx, 6) < 6 || + (ctx->buffer.buf + ctx->cur)[0] != 'i' || + (ctx->buffer.buf + ctx->cur)[1] != 'm' || + (ctx->buffer.buf + ctx->cur)[2] != 'p' || + (ctx->buffer.buf + ctx->cur)[3] != 'o' || + (ctx->buffer.buf + ctx->cur)[4] != 'r' || + (ctx->buffer.buf + ctx->cur)[5] != 't' + ) goto L0000; + ctx->cur += 6; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; + { + const size_t p = ctx->cur; + size_t q; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_dottedIdentifier, &chunk->thunks, NULL)) goto L0000; + q = ctx->cur; + chunk->capts.buf[0].range.start = p; + chunk->capts.buf[0].range.end = q; + } + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0001; + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != 'a' || + (ctx->buffer.buf + ctx->cur)[1] != 's' + ) goto L0001; + ctx->cur += 2; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0001; + { + const size_t p = ctx->cur; + size_t q; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_upperStartIdentifier, &chunk->thunks, NULL)) goto L0001; + q = ctx->cur; + chunk->capts.buf[1].range.start = p; + chunk->capts.buf[1].range.end = q; + } + goto L0002; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0002:; + } + { + pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_importStatement_0, 0, 2); + thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); + thunk->data.leaf.capts.buf[1] = &(chunk->capts.buf[1]); + thunk->data.leaf.capt0.range.start = chunk->pos; + thunk->data.leaf.capt0.range.end = ctx->cur; + pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); + } + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0003; + if ( + pcc_refill_buffer(ctx, 8) < 8 || + (ctx->buffer.buf + ctx->cur)[0] != 'e' || + (ctx->buffer.buf + ctx->cur)[1] != 'x' || + (ctx->buffer.buf + ctx->cur)[2] != 'p' || + (ctx->buffer.buf + ctx->cur)[3] != 'o' || + (ctx->buffer.buf + ctx->cur)[4] != 's' || + (ctx->buffer.buf + ctx->cur)[5] != 'i' || + (ctx->buffer.buf + ctx->cur)[6] != 'n' || + (ctx->buffer.buf + ctx->cur)[7] != 'g' + ) goto L0003; + ctx->cur += 8; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '(' + ) goto L0003; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importedList, &chunk->thunks, NULL)) goto L0003; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ')' + ) goto L0003; + ctx->cur++; + goto L0004; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0004:; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_EOS, &chunk->thunks, NULL)) goto L0000; + { + pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_importStatement_1, 0, 2); + thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); + thunk->data.leaf.capts.buf[1] = &(chunk->capts.buf[1]); + thunk->data.leaf.capt0.range.start = chunk->pos; + thunk->data.leaf.capt0.range.end = ctx->cur; + pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "importStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "importStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_importedList(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "importedList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importedItem, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ',' + ) goto L0001; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importedList, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "importedList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "importedList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_importedItem(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "importedItem", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importedFunction, &chunk->thunks, NULL)) goto L0002; + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importedType, &chunk->thunks, NULL)) goto L0003; + goto L0001; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importedItemIgnored, &chunk->thunks, NULL)) goto L0004; + goto L0001; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0001:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "importedItem", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "importedItem", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_importedFunction(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "importedFunction", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1); + { + const size_t p = ctx->cur; + size_t q; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; + q = ctx->cur; + chunk->capts.buf[0].range.start = p; + chunk->capts.buf[0].range.end = q; + } + { + pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_importedFunction_0, 0, 1); + thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); + thunk->data.leaf.capt0.range.start = chunk->pos; + thunk->data.leaf.capt0.range.end = ctx->cur; + pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "importedFunction", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "importedFunction", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_importedType(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "importedType", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1); + { + const size_t p = ctx->cur; + size_t q; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_upperStartIdentifier, &chunk->thunks, NULL)) goto L0000; + q = ctx->cur; + chunk->capts.buf[0].range.start = p; + chunk->capts.buf[0].range.end = q; + } + { + pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_importedType_0, 0, 1); + thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); + thunk->data.leaf.capt0.range.start = chunk->pos; + thunk->data.leaf.capt0.range.end = ctx->cur; + pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); + } + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '(' + ) goto L0001; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importedTypeConstructorList, &chunk->thunks, NULL)) goto L0001; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ')' + ) goto L0001; + ctx->cur++; + goto L0002; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0002:; + } + { + pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_importedType_1, 0, 1); + thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); + thunk->data.leaf.capt0.range.start = chunk->pos; + thunk->data.leaf.capt0.range.end = ctx->cur; + pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "importedType", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "importedType", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_importedItemIgnored(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "importedItemIgnored", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p0 = ctx->cur; + const size_t n0 = chunk->thunks.len; + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '.' + ) goto L0001; + ctx->cur++; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + if (i < 1) { + ctx->cur = p0; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); + goto L0000; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "importedItemIgnored", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "importedItemIgnored", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_importedTypeConstructorList(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "importedTypeConstructorList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importedTypeConstructor, &chunk->thunks, NULL)) goto L0002; + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importedItemIgnored, &chunk->thunks, NULL)) goto L0003; + goto L0001; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0001:; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ',' + ) goto L0004; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0004; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importedTypeConstructorList, &chunk->thunks, NULL)) goto L0004; + if (ctx->cur == p) break; + continue; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "importedTypeConstructorList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "importedTypeConstructorList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_importedTypeConstructor(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "importedTypeConstructor", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1); + { + const size_t p = ctx->cur; + size_t q; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_upperStartIdentifier, &chunk->thunks, NULL)) goto L0000; + q = ctx->cur; + chunk->capts.buf[0].range.start = p; + chunk->capts.buf[0].range.end = q; + } + { + pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_importedTypeConstructor_0, 0, 1); + thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); + thunk->data.leaf.capt0.range.start = chunk->pos; + thunk->data.leaf.capt0.range.end = ctx->cur; + pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "importedTypeConstructor", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "importedTypeConstructor", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_functionWithTypeAnnotation(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "functionWithTypeAnnotation", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 3); + { + const size_t p = ctx->cur; + size_t q; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; + q = ctx->cur; + chunk->capts.buf[0].range.start = p; + chunk->capts.buf[0].range.end = q; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ':' + ) goto L0000; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + { + const size_t p = ctx->cur; + size_t q; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_typeAnnotation, &chunk->thunks, NULL)) goto L0000; + q = ctx->cur; + chunk->capts.buf[1].range.start = p; + chunk->capts.buf[1].range.end = q; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_TLSS, &chunk->thunks, NULL)) goto L0000; + { + const size_t p = ctx->cur; + size_t q; + { + const size_t n = chunk->capts.buf[0].range.end - chunk->capts.buf[0].range.start; + if (pcc_refill_buffer(ctx, n) < n) goto L0000; + if (n > 0) { + const char *const p = ctx->buffer.buf + ctx->cur; + const char *const q = ctx->buffer.buf + chunk->capts.buf[0].range.start; + size_t i; + for (i = 0; i < n; i++) { + if (p[i] != q[i]) goto L0000; + } + ctx->cur += n; + } + } + q = ctx->cur; + chunk->capts.buf[2].range.start = p; + chunk->capts.buf[2].range.end = q; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; + { + pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_functionWithTypeAnnotation_0, 0, 3); + thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); + thunk->data.leaf.capts.buf[1] = &(chunk->capts.buf[1]); + thunk->data.leaf.capts.buf[2] = &(chunk->capts.buf[2]); + thunk->data.leaf.capt0.range.start = chunk->pos; + thunk->data.leaf.capt0.range.end = ctx->cur; + pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); + } + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionParameterList, &chunk->thunks, NULL)) goto L0001; + goto L0002; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0002:; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '=' + ) goto L0000; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_EOS, &chunk->thunks, NULL)) goto L0000; + { + pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_functionWithTypeAnnotation_1, 0, 3); + thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); + thunk->data.leaf.capts.buf[1] = &(chunk->capts.buf[1]); + thunk->data.leaf.capts.buf[2] = &(chunk->capts.buf[2]); + thunk->data.leaf.capt0.range.start = chunk->pos; + thunk->data.leaf.capt0.range.end = ctx->cur; + pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "functionWithTypeAnnotation", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "functionWithTypeAnnotation", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_typeAnnotation(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "typeAnnotation", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_singleTypeSpec, &chunk->thunks, NULL)) goto L0000; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '-' || + (ctx->buffer.buf + ctx->cur)[1] != '>' + ) goto L0001; + ctx->cur += 2; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_singleTypeSpec, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "typeAnnotation", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "typeAnnotation", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_functionDefinition(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "functionDefinition", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1); + { + const size_t p = ctx->cur; + size_t q; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_nonKeywordIdentifier, &chunk->thunks, NULL)) goto L0000; + q = ctx->cur; + chunk->capts.buf[0].range.start = p; + chunk->capts.buf[0].range.end = q; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + { + pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_functionDefinition_0, 0, 1); + thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); + thunk->data.leaf.capt0.range.start = chunk->pos; + thunk->data.leaf.capt0.range.end = ctx->cur; + pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); + } + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionParameterList, &chunk->thunks, NULL)) goto L0001; + goto L0002; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0002:; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '=' + ) goto L0000; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_EOS, &chunk->thunks, NULL)) goto L0000; + { + pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_functionDefinition_1, 0, 1); + thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); + thunk->data.leaf.capt0.range.start = chunk->pos; + thunk->data.leaf.capt0.range.end = ctx->cur; + pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "functionDefinition", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "functionDefinition", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_functionParameterList(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "functionParameterList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionParameter, &chunk->thunks, NULL)) goto L0000; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionParameter, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "functionParameterList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "functionParameterList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_functionParameter(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "functionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_plainFunctionParameter, &chunk->thunks, NULL)) goto L0002; + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_tupleFunctionParameter, &chunk->thunks, NULL)) goto L0003; + goto L0001; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_recordFunctionParameter, &chunk->thunks, NULL)) goto L0004; + goto L0001; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_constructorFunctionParameter, &chunk->thunks, NULL)) goto L0005; + goto L0001; + L0005:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0001:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "functionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "functionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_plainFunctionParameter(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "plainFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_asClause, &chunk->thunks, NULL)) goto L0001; + goto L0002; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0002:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "plainFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "plainFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_tupleFunctionParameter(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "tupleFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '(' + ) goto L0000; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionParameter, &chunk->thunks, NULL)) goto L0000; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ',' + ) goto L0001; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionParameter, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ')' + ) goto L0000; + ctx->cur++; + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_asClause, &chunk->thunks, NULL)) goto L0002; + goto L0003; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0003:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "tupleFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "tupleFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_recordFunctionParameter(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "recordFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '{' + ) goto L0000; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ',' + ) goto L0001; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '}' + ) goto L0000; + ctx->cur++; + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_asClause, &chunk->thunks, NULL)) goto L0002; + goto L0003; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0003:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "recordFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "recordFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_constructorFunctionParameter(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "constructorFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_upperStartIdentifier, &chunk->thunks, NULL)) goto L0000; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionParameter, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_asClause, &chunk->thunks, NULL)) goto L0002; + goto L0003; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0003:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "constructorFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "constructorFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_asClause(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "asClause", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != 'a' || + (ctx->buffer.buf + ctx->cur)[1] != 's' + ) goto L0000; + ctx->cur += 2; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "asClause", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "asClause", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_expression(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "expression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_letInBlock, &chunk->thunks, NULL)) goto L0001; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__NL_IND_, &chunk->thunks, NULL)) goto L0001; + goto L0002; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0002:; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_simpleExpression, &chunk->thunks, NULL)) goto L0000; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_binaryOperator, &chunk->thunks, NULL)) goto L0003; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0003; + if (ctx->cur == p) break; + continue; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "expression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "expression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_simpleExpression(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "simpleExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_hexNumber, &chunk->thunks, NULL)) goto L0002; + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_decimal, &chunk->thunks, NULL)) goto L0003; + goto L0001; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_multilineString, &chunk->thunks, NULL)) goto L0004; + goto L0001; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_characterLiteral, &chunk->thunks, NULL)) goto L0005; + goto L0001; + L0005:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_oneLineString, &chunk->thunks, NULL)) goto L0006; + goto L0001; + L0006:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_tupleExpression, &chunk->thunks, NULL)) goto L0007; + goto L0001; + L0007:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_listExpression, &chunk->thunks, NULL)) goto L0008; + goto L0001; + L0008:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_recordExpression, &chunk->thunks, NULL)) goto L0009; + goto L0001; + L0009:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_caseStatement, &chunk->thunks, NULL)) goto L0010; + goto L0001; + L0010:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_ifThenElseStatement, &chunk->thunks, NULL)) goto L0011; + goto L0001; + L0011:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_anonymousFunction, &chunk->thunks, NULL)) goto L0012; + goto L0001; + L0012:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionCall, &chunk->thunks, NULL)) goto L0013; + goto L0001; + L0013:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0001:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "simpleExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "simpleExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_tupleExpression(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "tupleExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '(' + ) goto L0002; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0002; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ',' + ) goto L0003; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0003; + if (ctx->cur == p) break; + continue; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ')' + ) goto L0002; + ctx->cur++; + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '(' + ) goto L0004; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0004; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ')' + ) goto L0004; + ctx->cur++; + goto L0001; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0001:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "tupleExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "tupleExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_listExpression(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "listExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '[' + ) goto L0002; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0002; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ',' + ) goto L0003; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0003; + if (ctx->cur == p) break; + continue; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ']' + ) goto L0002; + ctx->cur++; + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '[' + ) goto L0004; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0004; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ']' + ) goto L0004; + ctx->cur++; + goto L0001; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0001:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "listExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "listExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_recordExpression(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "recordExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '{' + ) goto L0002; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0003; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '|' + ) goto L0003; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; + goto L0004; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0004:; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_recordExpressionAssignment, &chunk->thunks, NULL)) goto L0002; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0005; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ',' + ) goto L0005; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0005; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_recordExpressionAssignment, &chunk->thunks, NULL)) goto L0005; + if (ctx->cur == p) break; + continue; + L0005:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '}' + ) goto L0002; + ctx->cur++; + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '{' + ) goto L0006; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0006; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '}' + ) goto L0006; + ctx->cur++; + goto L0001; + L0006:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0001:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "recordExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "recordExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_recordExpressionAssignment(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "recordExpressionAssignment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '=' + ) goto L0000; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "recordExpressionAssignment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "recordExpressionAssignment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_anonymousFunction(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "anonymousFunction", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '\\' + ) goto L0000; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionParameterList, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '-' || + (ctx->buffer.buf + ctx->cur)[1] != '>' + ) goto L0000; + ctx->cur += 2; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "anonymousFunction", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "anonymousFunction", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_functionCall(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "functionCall", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_dottedIdentifier, &chunk->thunks, NULL)) goto L0002; + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '.' + ) goto L0003; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0003; + goto L0001; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '(' + ) goto L0004; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_binaryOperator, &chunk->thunks, NULL)) goto L0004; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != ')' + ) goto L0004; + ctx->cur++; + goto L0001; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0001:; + } + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0005; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0005; + if (ctx->cur == p) break; + continue; + L0005:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "functionCall", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "functionCall", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_letInBlock(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "letInBlock", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if ( + pcc_refill_buffer(ctx, 3) < 3 || + (ctx->buffer.buf + ctx->cur)[0] != 'l' || + (ctx->buffer.buf + ctx->cur)[1] != 'e' || + (ctx->buffer.buf + ctx->cur)[2] != 't' + ) goto L0000; + ctx->cur += 3; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__NL_IND_, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_letInLine, &chunk->thunks, NULL)) goto L0000; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__NL_IND_, &chunk->thunks, NULL)) goto L0001; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_letInLine, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__NL_IND_, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != 'i' || + (ctx->buffer.buf + ctx->cur)[1] != 'n' + ) goto L0000; + ctx->cur += 2; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "letInBlock", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "letInBlock", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_letInLine(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "letInLine", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_letInFunctionDefinition, &chunk->thunks, NULL)) goto L0002; + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_letInBlock, &chunk->thunks, NULL)) goto L0003; + goto L0001; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_letInFunctionBody, &chunk->thunks, NULL)) goto L0004; + goto L0001; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0001:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "letInLine", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "letInLine", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_letInFunctionDefinition(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "letInFunctionDefinition", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1); + { + const size_t p = ctx->cur; + size_t q; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_nonKeywordIdentifier, &chunk->thunks, NULL)) goto L0000; + q = ctx->cur; + chunk->capts.buf[0].range.start = p; + chunk->capts.buf[0].range.end = q; + } + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + { + const size_t p0 = ctx->cur; + const size_t n0 = chunk->thunks.len; + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_WS, &chunk->thunks, NULL)) goto L0002; + if (ctx->cur == p) break; + continue; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + if (i < 1) { + ctx->cur = p0; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); + goto L0001; + } + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_nonKeywordIdentifier, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_WS, &chunk->thunks, NULL)) goto L0003; + if (ctx->cur == p) break; + continue; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '=' + ) goto L0000; + ctx->cur++; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_Non_NL, &chunk->thunks, NULL)) goto L0004; + if (ctx->cur == p) break; + continue; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + { + pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_letInFunctionDefinition_0, 0, 1); + thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); + thunk->data.leaf.capt0.range.start = chunk->pos; + thunk->data.leaf.capt0.range.end = ctx->cur; + pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "letInFunctionDefinition", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "letInFunctionDefinition", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_letInFunctionBody(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "letInFunctionBody", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 3) < 3 || + (ctx->buffer.buf + ctx->cur)[0] != 'l' || + (ctx->buffer.buf + ctx->cur)[1] != 'e' || + (ctx->buffer.buf + ctx->cur)[2] != 't' + ) goto L0003; + ctx->cur += 3; + goto L0002; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != 'i' || + (ctx->buffer.buf + ctx->cur)[1] != 'n' + ) goto L0004; + ctx->cur += 2; + goto L0002; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0001; + L0002:; + } + ctx->cur = p; + goto L0000; + L0001:; + ctx->cur = p; + } + { + const size_t p0 = ctx->cur; + const size_t n0 = chunk->thunks.len; + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_Non_NL, &chunk->thunks, NULL)) goto L0005; + if (ctx->cur == p) break; + continue; + L0005:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + if (i < 1) { + ctx->cur = p0; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); + goto L0000; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "letInFunctionBody", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "letInFunctionBody", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_caseStatement(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "caseStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if ( + pcc_refill_buffer(ctx, 4) < 4 || + (ctx->buffer.buf + ctx->cur)[0] != 'c' || + (ctx->buffer.buf + ctx->cur)[1] != 'a' || + (ctx->buffer.buf + ctx->cur)[2] != 's' || + (ctx->buffer.buf + ctx->cur)[3] != 'e' + ) goto L0000; + ctx->cur += 4; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != 'o' || + (ctx->buffer.buf + ctx->cur)[1] != 'f' + ) goto L0000; + ctx->cur += 2; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_caseClauseList, &chunk->thunks, NULL)) goto L0000; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "caseStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "caseStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_caseClauseList(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "caseClauseList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_caseClause, &chunk->thunks, NULL)) goto L0000; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0001; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_caseClause, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "caseClauseList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "caseClauseList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_caseClause(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "caseClause", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_roughCasePatternChar, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '-' || + (ctx->buffer.buf + ctx->cur)[1] != '>' + ) goto L0000; + ctx->cur += 2; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "caseClause", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "caseClause", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_roughCasePatternChar(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "roughCasePatternChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '-' || + (ctx->buffer.buf + ctx->cur)[1] != '>' + ) goto L0003; + ctx->cur += 2; + goto L0002; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_TLSS, &chunk->thunks, NULL)) goto L0004; + goto L0002; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lineComment, &chunk->thunks, NULL)) goto L0005; + goto L0002; + L0005:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_delimitedComment, &chunk->thunks, NULL)) goto L0006; + goto L0002; + L0006:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_NL, &chunk->thunks, NULL)) goto L0007; + goto L0002; + L0007:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0001; + L0002:; + } + ctx->cur = p; + goto L0000; + L0001:; + ctx->cur = p; + } + { + int u; + const size_t n = pcc_get_char_as_utf32(ctx, &u); + if (n == 0) goto L0000; + ctx->cur += n; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "roughCasePatternChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "roughCasePatternChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_ifThenElseStatement(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "ifThenElseStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != 'i' || + (ctx->buffer.buf + ctx->cur)[1] != 'f' + ) goto L0000; + ctx->cur += 2; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 4) < 4 || + (ctx->buffer.buf + ctx->cur)[0] != 't' || + (ctx->buffer.buf + ctx->cur)[1] != 'h' || + (ctx->buffer.buf + ctx->cur)[2] != 'e' || + (ctx->buffer.buf + ctx->cur)[3] != 'n' + ) goto L0000; + ctx->cur += 4; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 4) < 4 || + (ctx->buffer.buf + ctx->cur)[0] != 'e' || + (ctx->buffer.buf + ctx->cur)[1] != 'l' || + (ctx->buffer.buf + ctx->cur)[2] != 's' || + (ctx->buffer.buf + ctx->cur)[3] != 'e' + ) goto L0000; + ctx->cur += 4; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "ifThenElseStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "ifThenElseStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_binaryOperator(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "binaryOperator", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '>' || + (ctx->buffer.buf + ctx->cur)[1] != '>' + ) goto L0002; + ctx->cur += 2; + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '<' || + (ctx->buffer.buf + ctx->cur)[1] != '<' + ) goto L0003; + ctx->cur += 2; + goto L0001; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '|' || + (ctx->buffer.buf + ctx->cur)[1] != '>' + ) goto L0004; + ctx->cur += 2; + goto L0001; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '<' || + (ctx->buffer.buf + ctx->cur)[1] != '|' + ) goto L0005; + ctx->cur += 2; + goto L0001; + L0005:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '/' || + (ctx->buffer.buf + ctx->cur)[1] != '/' + ) goto L0006; + ctx->cur += 2; + goto L0001; + L0006:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '+' || + (ctx->buffer.buf + ctx->cur)[1] != '+' + ) goto L0007; + ctx->cur += 2; + goto L0001; + L0007:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != ':' || + (ctx->buffer.buf + ctx->cur)[1] != ':' + ) goto L0008; + ctx->cur += 2; + goto L0001; + L0008:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '=' || + (ctx->buffer.buf + ctx->cur)[1] != '=' + ) goto L0009; + ctx->cur += 2; + goto L0001; + L0009:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '/' || + (ctx->buffer.buf + ctx->cur)[1] != '=' + ) goto L0010; + ctx->cur += 2; + goto L0001; + L0010:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '&' || + (ctx->buffer.buf + ctx->cur)[1] != '&' + ) goto L0011; + ctx->cur += 2; + goto L0001; + L0011:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '|' || + (ctx->buffer.buf + ctx->cur)[1] != '|' + ) goto L0012; + ctx->cur += 2; + goto L0001; + L0012:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '<' || + (ctx->buffer.buf + ctx->cur)[1] != '=' + ) goto L0013; + ctx->cur += 2; + goto L0001; + L0013:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '>' || + (ctx->buffer.buf + ctx->cur)[1] != '=' + ) goto L0014; + ctx->cur += 2; + goto L0001; + L0014:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '<' + ) goto L0015; + ctx->cur++; + goto L0001; + L0015:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '>' + ) goto L0016; + ctx->cur++; + goto L0001; + L0016:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '+' + ) goto L0017; + ctx->cur++; + goto L0001; + L0017:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '-' + ) goto L0018; + ctx->cur++; + goto L0001; + L0018:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '*' + ) goto L0019; + ctx->cur++; + goto L0001; + L0019:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '/' + ) goto L0020; + ctx->cur++; + goto L0001; + L0020:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '^' + ) goto L0021; + ctx->cur++; + goto L0001; + L0021:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0001:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "binaryOperator", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "binaryOperator", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_ignoreRestOfStatement(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "ignoreRestOfStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_multilineString, &chunk->thunks, NULL)) goto L0002; + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + { + const size_t p0 = ctx->cur; + const size_t n0 = chunk->thunks.len; + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_Non_WS_or_NL, &chunk->thunks, NULL)) goto L0004; + if (ctx->cur == p) break; + continue; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + if (i < 1) { + ctx->cur = p0; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); + goto L0003; + } + } + goto L0001; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0001:; + } + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0005; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_ignoreRestOfStatement, &chunk->thunks, NULL)) goto L0005; + if (ctx->cur == p) break; + continue; + L0005:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "ignoreRestOfStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "ignoreRestOfStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_multilineString(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "multilineString", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if ( + pcc_refill_buffer(ctx, 3) < 3 || + (ctx->buffer.buf + ctx->cur)[0] != '\"' || + (ctx->buffer.buf + ctx->cur)[1] != '\"' || + (ctx->buffer.buf + ctx->cur)[2] != '\"' + ) goto L0000; + ctx->cur += 3; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + { + const size_t p = ctx->cur; + if ( + pcc_refill_buffer(ctx, 3) < 3 || + (ctx->buffer.buf + ctx->cur)[0] != '\"' || + (ctx->buffer.buf + ctx->cur)[1] != '\"' || + (ctx->buffer.buf + ctx->cur)[2] != '\"' + ) goto L0002; + ctx->cur += 3; + ctx->cur = p; + goto L0001; + L0002:; + ctx->cur = p; + } + { + int u; + const size_t n = pcc_get_char_as_utf32(ctx, &u); + if (n == 0) goto L0001; + ctx->cur += n; + } + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + if ( + pcc_refill_buffer(ctx, 3) < 3 || + (ctx->buffer.buf + ctx->cur)[0] != '\"' || + (ctx->buffer.buf + ctx->cur)[1] != '\"' || + (ctx->buffer.buf + ctx->cur)[2] != '\"' + ) goto L0000; + ctx->cur += 3; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "multilineString", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "multilineString", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_naiveIdentifier(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "naiveIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + int u; + const size_t n = pcc_get_char_as_utf32(ctx, &u); + if (n == 0) goto L0000; + if (!( + (u >= 0x000041 && u <= 0x00005a) || + (u >= 0x000061 && u <= 0x00007a) || + u == 0x00005f + )) goto L0000; + ctx->cur += n; + } + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "naiveIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "naiveIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_upperStartIdentifier(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "upperStartIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + int u; + const size_t n = pcc_get_char_as_utf32(ctx, &u); + if (n == 0) goto L0000; + if (!( + (u >= 0x000041 && u <= 0x00005a) + )) goto L0000; + ctx->cur += n; + } + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "upperStartIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "upperStartIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_lowerStartIdentifier(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "lowerStartIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_keyword, &chunk->thunks, NULL)) goto L0001; + ctx->cur = p; + goto L0000; + L0001:; + ctx->cur = p; + } + { + int u; + const size_t n = pcc_get_char_as_utf32(ctx, &u); + if (n == 0) goto L0000; + if (!( + (u >= 0x000061 && u <= 0x00007a) || + u == 0x00005f + )) goto L0000; + ctx->cur += n; + } + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0002; + if (ctx->cur == p) break; + continue; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "lowerStartIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "lowerStartIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_alphanumeric(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "alphanumeric", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + int u; + const size_t n = pcc_get_char_as_utf32(ctx, &u); + if (n == 0) goto L0000; + if (!( + (u >= 0x000041 && u <= 0x00005a) || + (u >= 0x000061 && u <= 0x00007a) || + (u >= 0x000030 && u <= 0x000039) || + u == 0x00005f + )) goto L0000; + ctx->cur += n; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "alphanumeric", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "alphanumeric", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_nonKeywordIdentifier(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "nonKeywordIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_keyword, &chunk->thunks, NULL)) goto L0001; + ctx->cur = p; + goto L0000; + L0001:; + ctx->cur = p; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_naiveIdentifier, &chunk->thunks, NULL)) goto L0000; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "nonKeywordIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "nonKeywordIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_keyword(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "keyword", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 4) < 4 || + (ctx->buffer.buf + ctx->cur)[0] != 't' || + (ctx->buffer.buf + ctx->cur)[1] != 'y' || + (ctx->buffer.buf + ctx->cur)[2] != 'p' || + (ctx->buffer.buf + ctx->cur)[3] != 'e' + ) goto L0002; + ctx->cur += 4; + { + const size_t p = ctx->cur; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0003; + ctx->cur = p; + goto L0002; + L0003:; + ctx->cur = p; + } + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 6) < 6 || + (ctx->buffer.buf + ctx->cur)[0] != 'm' || + (ctx->buffer.buf + ctx->cur)[1] != 'o' || + (ctx->buffer.buf + ctx->cur)[2] != 'd' || + (ctx->buffer.buf + ctx->cur)[3] != 'u' || + (ctx->buffer.buf + ctx->cur)[4] != 'l' || + (ctx->buffer.buf + ctx->cur)[5] != 'e' + ) goto L0004; + ctx->cur += 6; + { + const size_t p = ctx->cur; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0005; + ctx->cur = p; + goto L0004; + L0005:; + ctx->cur = p; + } + goto L0001; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 4) < 4 || + (ctx->buffer.buf + ctx->cur)[0] != 'p' || + (ctx->buffer.buf + ctx->cur)[1] != 'o' || + (ctx->buffer.buf + ctx->cur)[2] != 'r' || + (ctx->buffer.buf + ctx->cur)[3] != 't' + ) goto L0006; + ctx->cur += 4; + { + const size_t p = ctx->cur; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0007; + ctx->cur = p; + goto L0006; + L0007:; + ctx->cur = p; + } + goto L0001; + L0006:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 5) < 5 || + (ctx->buffer.buf + ctx->cur)[0] != 'a' || + (ctx->buffer.buf + ctx->cur)[1] != 'l' || + (ctx->buffer.buf + ctx->cur)[2] != 'i' || + (ctx->buffer.buf + ctx->cur)[3] != 'a' || + (ctx->buffer.buf + ctx->cur)[4] != 's' + ) goto L0008; + ctx->cur += 5; + { + const size_t p = ctx->cur; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0009; + ctx->cur = p; + goto L0008; + L0009:; + ctx->cur = p; + } + goto L0001; + L0008:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != 'a' || + (ctx->buffer.buf + ctx->cur)[1] != 's' + ) goto L0010; + ctx->cur += 2; + { + const size_t p = ctx->cur; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0011; + ctx->cur = p; + goto L0010; + L0011:; + ctx->cur = p; + } + goto L0001; + L0010:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 8) < 8 || + (ctx->buffer.buf + ctx->cur)[0] != 'e' || + (ctx->buffer.buf + ctx->cur)[1] != 'x' || + (ctx->buffer.buf + ctx->cur)[2] != 'p' || + (ctx->buffer.buf + ctx->cur)[3] != 'o' || + (ctx->buffer.buf + ctx->cur)[4] != 's' || + (ctx->buffer.buf + ctx->cur)[5] != 'i' || + (ctx->buffer.buf + ctx->cur)[6] != 'n' || + (ctx->buffer.buf + ctx->cur)[7] != 'g' + ) goto L0012; + ctx->cur += 8; + { + const size_t p = ctx->cur; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0013; + ctx->cur = p; + goto L0012; + L0013:; + ctx->cur = p; + } + goto L0001; + L0012:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 6) < 6 || + (ctx->buffer.buf + ctx->cur)[0] != 'i' || + (ctx->buffer.buf + ctx->cur)[1] != 'm' || + (ctx->buffer.buf + ctx->cur)[2] != 'p' || + (ctx->buffer.buf + ctx->cur)[3] != 'o' || + (ctx->buffer.buf + ctx->cur)[4] != 'r' || + (ctx->buffer.buf + ctx->cur)[5] != 't' + ) goto L0014; + ctx->cur += 6; + { + const size_t p = ctx->cur; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0015; + ctx->cur = p; + goto L0014; + L0015:; + ctx->cur = p; + } + goto L0001; + L0014:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 3) < 3 || + (ctx->buffer.buf + ctx->cur)[0] != 'l' || + (ctx->buffer.buf + ctx->cur)[1] != 'e' || + (ctx->buffer.buf + ctx->cur)[2] != 't' + ) goto L0016; + ctx->cur += 3; + { + const size_t p = ctx->cur; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0017; + ctx->cur = p; + goto L0016; + L0017:; + ctx->cur = p; + } + goto L0001; + L0016:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != 'i' || + (ctx->buffer.buf + ctx->cur)[1] != 'n' + ) goto L0018; + ctx->cur += 2; + { + const size_t p = ctx->cur; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0019; + ctx->cur = p; + goto L0018; + L0019:; + ctx->cur = p; + } + goto L0001; + L0018:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 4) < 4 || + (ctx->buffer.buf + ctx->cur)[0] != 'c' || + (ctx->buffer.buf + ctx->cur)[1] != 'a' || + (ctx->buffer.buf + ctx->cur)[2] != 's' || + (ctx->buffer.buf + ctx->cur)[3] != 'e' + ) goto L0020; + ctx->cur += 4; + { + const size_t p = ctx->cur; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0021; + ctx->cur = p; + goto L0020; + L0021:; + ctx->cur = p; + } + goto L0001; + L0020:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != 'o' || + (ctx->buffer.buf + ctx->cur)[1] != 'f' + ) goto L0022; + ctx->cur += 2; + { + const size_t p = ctx->cur; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0023; + ctx->cur = p; + goto L0022; + L0023:; + ctx->cur = p; + } + goto L0001; + L0022:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != 'i' || + (ctx->buffer.buf + ctx->cur)[1] != 'f' + ) goto L0024; + ctx->cur += 2; + { + const size_t p = ctx->cur; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0025; + ctx->cur = p; + goto L0024; + L0025:; + ctx->cur = p; + } + goto L0001; + L0024:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 4) < 4 || + (ctx->buffer.buf + ctx->cur)[0] != 't' || + (ctx->buffer.buf + ctx->cur)[1] != 'h' || + (ctx->buffer.buf + ctx->cur)[2] != 'e' || + (ctx->buffer.buf + ctx->cur)[3] != 'n' + ) goto L0026; + ctx->cur += 4; + { + const size_t p = ctx->cur; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0027; + ctx->cur = p; + goto L0026; + L0027:; + ctx->cur = p; + } + goto L0001; + L0026:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 4) < 4 || + (ctx->buffer.buf + ctx->cur)[0] != 'e' || + (ctx->buffer.buf + ctx->cur)[1] != 'l' || + (ctx->buffer.buf + ctx->cur)[2] != 's' || + (ctx->buffer.buf + ctx->cur)[3] != 'e' + ) goto L0028; + ctx->cur += 4; + { + const size_t p = ctx->cur; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0029; + ctx->cur = p; + goto L0028; + L0029:; + ctx->cur = p; + } + goto L0001; + L0028:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0001:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "keyword", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "keyword", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_dottedIdentifier(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "dottedIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_nonKeywordIdentifier, &chunk->thunks, NULL)) goto L0000; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '.' + ) goto L0001; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_nonKeywordIdentifier, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "dottedIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "dottedIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_decimal(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "decimal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_exponentialDecimal, &chunk->thunks, NULL)) goto L0002; + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_simpleDecimal, &chunk->thunks, NULL)) goto L0003; + goto L0001; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0001:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "decimal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "decimal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_exponentialDecimal(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "exponentialDecimal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_simpleDecimal, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != 'e' + ) goto L0000; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_simpleInteger, &chunk->thunks, NULL)) goto L0000; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "exponentialDecimal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "exponentialDecimal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_simpleDecimal(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "simpleDecimal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_simpleInteger, &chunk->thunks, NULL)) goto L0002; + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '.' + ) goto L0003; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_digits, &chunk->thunks, NULL)) goto L0003; + goto L0004; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0004:; + } + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '.' + ) goto L0005; + ctx->cur++; + { + const size_t p0 = ctx->cur; + const size_t n0 = chunk->thunks.len; + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_digits, &chunk->thunks, NULL)) goto L0006; + if (ctx->cur == p) break; + continue; + L0006:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + if (i < 1) { + ctx->cur = p0; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); + goto L0005; + } + } + goto L0001; + L0005:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0001:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "simpleDecimal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "simpleDecimal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_simpleInteger(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "simpleInteger", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + { + int u; + const size_t n = pcc_get_char_as_utf32(ctx, &u); + if (n == 0) goto L0001; + if (!( + u == 0x00002d || + u == 0x00002b + )) goto L0001; + ctx->cur += n; + } + goto L0002; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0002:; + } + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_digits, &chunk->thunks, NULL)) goto L0000; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "simpleInteger", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "simpleInteger", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_digits(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "digits", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p0 = ctx->cur; + const size_t n0 = chunk->thunks.len; + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + { + int u; + const size_t n = pcc_get_char_as_utf32(ctx, &u); + if (n == 0) goto L0001; + if (!( + (u >= 0x000030 && u <= 0x000039) + )) goto L0001; + ctx->cur += n; + } + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + if (i < 1) { + ctx->cur = p0; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); + goto L0000; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "digits", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "digits", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_hexNumber(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "hexNumber", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '0' || + (ctx->buffer.buf + ctx->cur)[1] != 'x' + ) goto L0000; + ctx->cur += 2; + { + const size_t p0 = ctx->cur; + const size_t n0 = chunk->thunks.len; + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + { + int u; + const size_t n = pcc_get_char_as_utf32(ctx, &u); + if (n == 0) goto L0001; + if (!( + (u >= 0x000030 && u <= 0x000039) || + (u >= 0x000041 && u <= 0x000046) || + (u >= 0x000061 && u <= 0x000066) + )) goto L0001; + ctx->cur += n; + } + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + if (i < 1) { + ctx->cur = p0; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); + goto L0000; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "hexNumber", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "hexNumber", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_oneLineString(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "oneLineString", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '\"' + ) goto L0000; + ctx->cur++; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_inStringChar, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '\"' + ) goto L0000; + ctx->cur++; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "oneLineString", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "oneLineString", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_characterLiteral(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "characterLiteral", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '\'' + ) goto L0000; + ctx->cur++; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_inStringChar, &chunk->thunks, NULL)) goto L0000; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '\'' + ) goto L0000; + ctx->cur++; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "characterLiteral", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "characterLiteral", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_inStringChar(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "inStringChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '\"' + ) goto L0003; + ctx->cur++; + goto L0002; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_NL, &chunk->thunks, NULL)) goto L0004; + goto L0002; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0001; + L0002:; + } + ctx->cur = p; + goto L0000; + L0001:; + ctx->cur = p; + } + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_inStringUnicodeChar, &chunk->thunks, NULL)) goto L0006; + goto L0005; + L0006:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_inStringEscapedChar, &chunk->thunks, NULL)) goto L0007; + goto L0005; + L0007:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_inStringPlainChar, &chunk->thunks, NULL)) goto L0008; + goto L0005; + L0008:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0005:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "inStringChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "inStringChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_inStringPlainChar(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "inStringPlainChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '\"' + ) goto L0003; + ctx->cur++; + goto L0002; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '\\' + ) goto L0004; + ctx->cur++; + goto L0002; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_NL, &chunk->thunks, NULL)) goto L0005; + goto L0002; + L0005:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0001; + L0002:; + } + ctx->cur = p; + goto L0000; + L0001:; + ctx->cur = p; + } + { + int u; + const size_t n = pcc_get_char_as_utf32(ctx, &u); + if (n == 0) goto L0000; + ctx->cur += n; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "inStringPlainChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "inStringPlainChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_inStringEscapedChar(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "inStringEscapedChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '\\' + ) goto L0000; + ctx->cur++; + { + const size_t p = ctx->cur; + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != 'u' + ) goto L0003; + ctx->cur++; + goto L0002; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_NL, &chunk->thunks, NULL)) goto L0004; + goto L0002; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0001; + L0002:; + } + ctx->cur = p; + goto L0000; + L0001:; + ctx->cur = p; + } + { + int u; + const size_t n = pcc_get_char_as_utf32(ctx, &u); + if (n == 0) goto L0000; + ctx->cur += n; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "inStringEscapedChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "inStringEscapedChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_inStringUnicodeChar(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "inStringUnicodeChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if ( + pcc_refill_buffer(ctx, 3) < 3 || + (ctx->buffer.buf + ctx->cur)[0] != '\\' || + (ctx->buffer.buf + ctx->cur)[1] != 'u' || + (ctx->buffer.buf + ctx->cur)[2] != '{' + ) goto L0000; + ctx->cur += 3; + { + const size_t p0 = ctx->cur; + const size_t n0 = chunk->thunks.len; + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + { + int u; + const size_t n = pcc_get_char_as_utf32(ctx, &u); + if (n == 0) goto L0001; + if (!( + (u >= 0x000030 && u <= 0x000039) || + (u >= 0x000041 && u <= 0x000046) || + (u >= 0x000061 && u <= 0x000066) + )) goto L0001; + ctx->cur += n; + } + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + if (i < 1) { + ctx->cur = p0; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); + goto L0000; + } + } + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '}' + ) goto L0000; + ctx->cur++; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "inStringUnicodeChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "inStringUnicodeChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_WS(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "WS", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p0 = ctx->cur; + const size_t n0 = chunk->thunks.len; + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + { + int u; + const size_t n = pcc_get_char_as_utf32(ctx, &u); + if (n == 0) goto L0001; + if (!( + u == 0x000020 || + u == 0x000009 + )) goto L0001; + ctx->cur += n; + } + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + if (i < 1) { + ctx->cur = p0; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); + goto L0000; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "WS", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "WS", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_NL(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "NL", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '\n' + ) goto L0002; + ctx->cur++; + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '\f' + ) goto L0003; + ctx->cur++; + goto L0001; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '\r' + ) goto L0004; + ctx->cur++; + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if ( + pcc_refill_buffer(ctx, 1) < 1 || + ctx->buffer.buf[ctx->cur] != '\n' + ) goto L0005; + ctx->cur++; + goto L0006; + L0005:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0006:; + } + goto L0001; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0001:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "NL", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "NL", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_Non_NL(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "Non_NL", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + int u; + const size_t n = pcc_get_char_as_utf32(ctx, &u); + if (n == 0) goto L0000; + if ( + u == 0x00000a || + u == 0x00000d || + u == 0x00000c + ) goto L0000; + ctx->cur += n; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "Non_NL", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "Non_NL", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_Non_WS_or_NL(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "Non_WS_or_NL", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + int u; + const size_t n = pcc_get_char_as_utf32(ctx, &u); + if (n == 0) goto L0000; + if ( + u == 0x000020 || + u == 0x000009 || + u == 0x00000a || + u == 0x00000d || + u == 0x00000c + ) goto L0000; + ctx->cur += n; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "Non_WS_or_NL", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "Non_WS_or_NL", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_EOF(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "EOF", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + { + int u; + const size_t n = pcc_get_char_as_utf32(ctx, &u); + if (n == 0) goto L0001; + ctx->cur += n; + } + ctx->cur = p; + goto L0000; + L0001:; + ctx->cur = p; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "EOF", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "EOF", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_delimitedComment(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "delimitedComment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '{' || + (ctx->buffer.buf + ctx->cur)[1] != '-' + ) goto L0000; + ctx->cur += 2; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_delimitedComment, &chunk->thunks, NULL)) goto L0003; + goto L0002; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + { + const size_t p = ctx->cur; + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '-' || + (ctx->buffer.buf + ctx->cur)[1] != '}' + ) goto L0005; + ctx->cur += 2; + ctx->cur = p; + goto L0004; + L0005:; + ctx->cur = p; + } + { + int u; + const size_t n = pcc_get_char_as_utf32(ctx, &u); + if (n == 0) goto L0004; + ctx->cur += n; + } + goto L0002; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0001; + L0002:; + } + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '-' || + (ctx->buffer.buf + ctx->cur)[1] != '}' + ) goto L0000; + ctx->cur += 2; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "delimitedComment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "delimitedComment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_lineComment(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "lineComment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + if ( + pcc_refill_buffer(ctx, 2) < 2 || + (ctx->buffer.buf + ctx->cur)[0] != '-' || + (ctx->buffer.buf + ctx->cur)[1] != '-' + ) goto L0000; + ctx->cur += 2; + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_Non_NL, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "lineComment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "lineComment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule__1_short(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "_1_short", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lineComment, &chunk->thunks, NULL)) goto L0003; + goto L0002; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_NL, &chunk->thunks, NULL)) goto L0004; + goto L0002; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0001; + L0002:; + } + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_WS, &chunk->thunks, NULL)) goto L0006; + goto L0005; + L0006:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_delimitedComment, &chunk->thunks, NULL)) goto L0007; + goto L0005; + L0007:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0005:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "_1_short", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "_1_short", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule__1_(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "_1_", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p0 = ctx->cur; + const size_t n0 = chunk->thunks.len; + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_short, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + if (i < 1) { + ctx->cur = p0; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); + goto L0000; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "_1_", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "_1_", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule__0_(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "_0_", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0002; + goto L0001; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + L0001:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "_0_", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_TLSS_short(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "TLSS_short", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_WS, &chunk->thunks, NULL)) goto L0003; + goto L0002; + L0003:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lineComment, &chunk->thunks, NULL)) goto L0004; + goto L0002; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_delimitedComment, &chunk->thunks, NULL)) goto L0005; + goto L0002; + L0005:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0001; + L0002:; + } + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + } + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_NL, &chunk->thunks, NULL)) goto L0007; + goto L0006; + L0007:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_EOF, &chunk->thunks, NULL)) goto L0008; + goto L0006; + L0008:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0000; + L0006:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "TLSS_short", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "TLSS_short", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_TLSS(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "TLSS", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p0 = ctx->cur; + const size_t n0 = chunk->thunks.len; + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_TLSS_short, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + if (i < 1) { + ctx->cur = p0; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); + goto L0000; + } + } + { + const size_t p = ctx->cur; + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_WS, &chunk->thunks, NULL)) goto L0004; + goto L0003; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lineComment, &chunk->thunks, NULL)) goto L0005; + goto L0003; + L0005:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_delimitedComment, &chunk->thunks, NULL)) goto L0006; + goto L0003; + L0006:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0002; + L0003:; + } + ctx->cur = p; + goto L0000; + L0002:; + ctx->cur = p; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "TLSS", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "TLSS", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule_EOS(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "EOS", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p = ctx->cur; + { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_TLSS, &chunk->thunks, NULL)) goto L0004; + goto L0003; + L0004:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_EOF, &chunk->thunks, NULL)) goto L0005; + goto L0003; + L0005:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + goto L0001; + L0003:; + } + ctx->cur = p; + goto L0002; + L0001:; + ctx->cur = p; + goto L0000; + L0002:; + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "EOS", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "EOS", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +static pcc_thunk_chunk_t *pcc_evaluate_rule__NL_IND_(pelm_context_t *ctx) { + pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); + chunk->pos = ctx->cur; + PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "_NL_IND_", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); + ctx->level++; + pcc_value_table__resize(ctx->auxil, &chunk->values, 0); + pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); + { + const size_t p0 = ctx->cur; + const size_t n0 = chunk->thunks.len; + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_TLSS_short, &chunk->thunks, NULL)) goto L0001; + if (ctx->cur == p) break; + continue; + L0001:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + if (i < 1) { + ctx->cur = p0; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); + goto L0000; + } + } + { + const size_t p0 = ctx->cur; + const size_t n0 = chunk->thunks.len; + int i; + for (i = 0;; i++) { + const size_t p = ctx->cur; + const size_t n = chunk->thunks.len; + if (!pcc_apply_rule(ctx, pcc_evaluate_rule_WS, &chunk->thunks, NULL)) goto L0002; + if (ctx->cur == p) break; + continue; + L0002:; + ctx->cur = p; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); + break; + } + if (i < 1) { + ctx->cur = p0; + pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); + goto L0000; + } + } + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "_NL_IND_", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + return chunk; +L0000:; + ctx->level--; + PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "_NL_IND_", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); + pcc_thunk_chunk__destroy(ctx->auxil, chunk); + return NULL; +} + +pelm_context_t *pelm_create(struct parserCtx *auxil) { + return pcc_context__create(auxil); +} + +int pelm_parse(pelm_context_t *ctx, int *ret) { + if (pcc_apply_rule(ctx, pcc_evaluate_rule_file, &ctx->thunks, ret)) + pcc_do_action(ctx, &ctx->thunks, ret); + else + PCC_ERROR(ctx->auxil); + pcc_commit_buffer(ctx); + pcc_thunk_array__revert(ctx->auxil, &ctx->thunks, 0); + return pcc_refill_buffer(ctx, 1) >= 1; +} + +void pelm_destroy(pelm_context_t *ctx) { + pcc_context__destroy(ctx); +} + +#include "elm_post.h" diff --git a/peg/elm.h b/peg/elm.h new file mode 100644 index 0000000000..a5cc3abbcc --- /dev/null +++ b/peg/elm.h @@ -0,0 +1,22 @@ +/* A packrat parser generated by PackCC 1.6.0 */ + +#ifndef PCC_INCLUDED___PEG_ELM_H +#define PCC_INCLUDED___PEG_ELM_H + +struct parserCtx; + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct pelm_context_tag pelm_context_t; + +pelm_context_t *pelm_create(struct parserCtx *auxil); +int pelm_parse(pelm_context_t *ctx, int *ret); +void pelm_destroy(pelm_context_t *ctx); + +#ifdef __cplusplus +} +#endif + +#endif /* !PCC_INCLUDED___PEG_ELM_H */ diff --git a/peg/elm.peg b/peg/elm.peg new file mode 100644 index 0000000000..4cc7aea70f --- /dev/null +++ b/peg/elm.peg @@ -0,0 +1,622 @@ +# Copyright (c) 2022 Nik Silver +# +# This source code is released for free distribution under the terms of the +# GNU General Public License version 2 or later. +# +# This Elm parser will tag items reliably at the top level. Functions +# defined in let/in blocks are also tagged, but with limitations. See below. +# +# Kinds +# - m module +# - n namespace (ie a module that's renamed) +# - t type +# - c constructor (within a type) +# - a alias +# - p port +# - f function +# +# Key/value pairs +# - roles:def This is defined here. +# - roles:imported This is imported here. +# - type: This constructor is in the scope of type , which +# may be dotted. Eg Main.myType. +# - function: This function is in the scope of function , which +# may be dotted. Eg Main.myFunc. +# - module: This is in the scope of module . +# - signature: This function, constructor or port has signature . +# - moduleName: This namespace has original module name . +# +# Functions defined in let/in blocks may be tagged, with these limitations: +# - the LHS (up to and including the '=') need to be on a single line; +# - the LHS can only have simple parameters; +# - their scope is only marked as being in the top-most function; +# - any type annotation is ignored. +# This should be good for 90% of inner functions. To make it totally robust +# is much more complicated due to (a) Elm's clever indentation-sensitivity +# and (b) limitations of the PEG parser used here. +# +# To do: +# Maybe do: +# - let/in blocks +# - Allow tuples on the LHS. Eg '(val1, val2) = valFunc'. +# - Inner functions' type annotations are used in the function's signature. +# - Inner functions can have more complex parameters. +# - Functions +# - Allow non-Latin upper and lower case. Use +# https://util.unicode.org/UnicodeJsps/properties.html +# combined with \p{Lu}, \p{Ll} and \p{L}. +# - If there's no --field=+r then an imported module (say) is still tagged, +# but there's no roles:imported, so it looks like it has been defined. +# Not sure if this is a bug. The Thrift parser has this same behaviour. +# +# Won't do: +# - Handle Elm's indentation properly. + + +%prefix "pelm" + +%auxil "struct parserCtx *" + +%earlysource { + #include "general.h" +} + +%header { + struct parserCtx; +} + +%source { +#include "elm_pre.h" +#include "routines.h" + +/* + * Include these lines to debug the parsing. + * From https://github.com/arithy/packcc#macros + * This will output parsing info to STDERR.tmp in the vent of a failed test. + */ + +/* +static const char *dbg_str[] = { "Evaluating rule", "Matched rule", "Abandoning rule" }; + +#define PCC_DEBUG(auxil, event, rule, level, pos, buffer, length) \ + fprintf(stderr, "%*s%s %s @%zu [%.*s]\n", \ + (int)((level) * 2), "", dbg_str[event], rule, pos, (int)(length), buffer) + */ +} + +# Top level elements ----------------------------------------------------- + +# We separate the file into the module section and the main section +# so that we only consider and tag one module declaration + +file <- + { + ELM_INIT_MODULE_SCOPE; + } + TLSS? + moduleDeclaration? + TLSS? + mainTopLevelStatements? + TLSS? + EOF + +mainTopLevelStatements <- + topLevelStatement (TLSS topLevelStatement)* + +topLevelStatement <- + importStatement + / typeAlias + / customType + / portDeclaration + / functionWithTypeAnnotation + / functionDefinition + / ignoreRestOfStatement + +# Main Elm grammar ------------------------------------------------------- + +# Module declaration +# +# We can be a bit relaxed about distinguishing functions, types and +# constructors listed in a module declaration, because we're not going +# to tag them. + +moduleDeclaration <- + ('port' _1_)? 'module' _1_ _1_ 'exposing' _0_ '(' exposedList ')' EOS { + elm_module_scope_index = makeElmTagSettingScope(auxil, $1, $1s, K_MODULE, ROLE_DEFINITION_INDEX); + } + +exposedList <- _0_ exposedItem _0_ (',' _0_ exposedList )* + +exposedItem <- + exposedFieldOrType + / exposedFunction + / exposedItemIgnored + +exposedFieldOrType <- + (_0_ '(' _0_ exposedTypeConstructorList _0_ ')')? + +exposedFunction <- + lowerStartIdentifier + +exposedItemIgnored <- '.'+ + +exposedTypeConstructorList <- + (upperStartIdentifier / exposedItemIgnored) _0_ (',' _0_ exposedTypeConstructorList)* + +# Type alias +# +# We don't care what the actual alias is + +typeAlias <- + 'type' _1_ 'alias' _1_ _0_ '=' _0_ ignoreRestOfStatement { + makeElmTag(auxil, $1, $1s, K_ALIAS, ROLE_DEFINITION_INDEX); + } + +# Custom type +# +# Includes type parameters, such as 'x' in 'type MyType x = Wrap x'. + +customType <- + 'type' _1_ (_0_ typeParameterList)? _0_ '=' _0_ { + makeElmTagSettingScope(auxil, $1, $1s, K_TYPE, ROLE_DEFINITION_INDEX); + } constructorList EOS { + POP_KIND(auxil, true); + } + +typeParameterList <- lowerStartIdentifier (_1_ lowerStartIdentifier)* + +# A type could be defined as a constructor list: +# type A = Cons1 String | Cons2 Float Float | ... +# The 'String' and the 'Float Float' etc are the constructor types. +# Each 'String', 'Float', etc is a single type spec. +# But a single type spec could also be a record, a tuple or a function spec. + +constructorList <- _0_ ? _0_ ('|' _0_ constructorList)? { + int r = makeElmTag(auxil, $1, $1s, K_CONSTRUCTOR, ROLE_DEFINITION_INDEX); + addElmSignature(r, $2); +} + +constructorTypes <- singleTypeSpec (_0_ constructorTypes)* + +singleTypeSpec <- + recordTypeSpec + / tupleTypeSpec + / functionTypeSpec + / parameterisedTypeSpec + +recordTypeSpec <- + '{' (_0_ recordRestrictionPrefix)? _0_ fieldSpec (_0_ ',' _0_ fieldSpec)* _0_ '}' + / '{' (_0_ recordRestrictionPrefix)? _0_ '}' + +recordRestrictionPrefix <- + lowerStartIdentifier _0_ '|' + +fieldSpec <- + lowerStartIdentifier _0_ ':' _0_ singleTypeSpec + +tupleTypeSpec <- + '(' _0_ singleTypeSpec (_0_ ',' _0_ singleTypeSpec)* _0_ ')' + / '(' _0_ ')' + +parameterisedTypeSpec <- + dottedIdentifier (_1_ (singleTypeSpec / lowerStartIdentifier))* + +functionTypeSpec <- + singleTypeSpec (_0_ '->' _0_ singleTypeSpec)+ + +# Port declaration + +portDeclaration <- + 'port' _1_ _0_ ':' _0_ EOS { + int r = makeElmTag(auxil, $1, $1s, K_PORT, ROLE_DEFINITION_INDEX); + addElmSignature(r, $2); + } + +# Import statement +# +# For the import statement we don't want the imported items to appear in the +# scope of the current module (ie this file), otherwise they'll be named +# wrongly. So we # want to save the module scope, make the imported tags, +# then restore the module scope. We do this in two separate C code blocks, +# because the module scope needs to be saved before any of the imported tags +# are made. +# +# Also, if we create a namespace then that *does* live in the scope of the +# current module, so we'll make that tag (if needed) before saving the +# module scope. + +importStatement <- + 'import' _1_ (_1_ 'as' _1_ )? { + // Make the namespace tag first, as it's in the file module's scope + if ($2s > 0) { + int r = makeElmTag(auxil, $2, $2s, K_NAMESPACE, ROLE_DEFINITION_INDEX); + attachParserFieldToCorkEntry (r, ElmFields[F_MODULENAME].ftype, $1); + } + + // Now make the tag for the imported module, as it lives outside + // the scope of the file module + ELM_SAVE_MODULE_SCOPE; + makeElmTagSettingScope(auxil, $1, $1s, K_MODULE, ELM_ROLE_IMPORTED); + } (_1_ 'exposing' _0_ '(' _0_ importedList _0_ ')')? EOS { + ELM_RESTORE_MODULE_SCOPE; + } + +importedList <- importedItem _0_ (',' _0_ importedList)* + +importedItem <- + importedFunction + / importedType + / importedItemIgnored + +importedFunction <- { + makeElmTag(auxil, $1, $1s, K_FUNCTION, ELM_ROLE_IMPORTED); + } + +# When importing a type and constructors we want the constructors +# to be in the scope of the type. So we have to set the scope as the +# type first, before parsing (and making the tags for) the constructors. +# That's why the code here uses two separate C code blocks. + +importedType <- + { + makeElmTagSettingScope(auxil, $1, $1s, K_TYPE, ELM_ROLE_IMPORTED); + } (_0_ '(' _0_ importedTypeConstructorList _0_ ')')? { + // We're done with the type and its constructors, so we can pop it + POP_SCOPE(auxil); + } + +importedItemIgnored <- '.'+ + +importedTypeConstructorList <- + (importedTypeConstructor / importedItemIgnored) _0_ (',' _0_ importedTypeConstructorList)* + +importedTypeConstructor <- + { + makeElmTag(auxil, $1, $1s, K_CONSTRUCTOR, ELM_ROLE_IMPORTED); + } + +# Function with a type annotation. +# +# The type is on one line, and the function must follow immediately as +# the next top level statement + +functionWithTypeAnnotation <- + _0_ ':' _0_ TLSS + <$1> _1_ { + int r = makeElmTagSettingScope(auxil, $3, $3s, K_FUNCTION, ROLE_DEFINITION_INDEX); + addElmSignature(r, $2); + } + functionParameterList? _0_ '=' _0_ expression EOS { + POP_SCOPE(auxil); + } + +typeAnnotation <- + singleTypeSpec (_0_ '->' _0_ singleTypeSpec)* + +# Function without a type annotation + +functionDefinition <- + _0_ { + makeElmTagSettingScope(auxil, $1, $1s, K_FUNCTION, ROLE_DEFINITION_INDEX); + } + functionParameterList? _0_ '=' _0_ expression EOS { + POP_SCOPE(auxil); + } + +# A function parameter list is what we define a function with. It's the +# x y z in 'fn x y z'. But of course they can be more complex, such as +# 'fn (Cons a b) ({ thing } as otherThing))' etc. + +functionParameterList <- functionParameter (_0_ functionParameter)* + +functionParameter <- + plainFunctionParameter + / tupleFunctionParameter + / recordFunctionParameter + / constructorFunctionParameter + +plainFunctionParameter <- + lowerStartIdentifier (_0_ asClause)? + +tupleFunctionParameter <- + '(' _0_ functionParameter (_0_ ',' _0_ functionParameter)* _0_ ')' (_0_ asClause)? + +recordFunctionParameter <- + '{' _0_ lowerStartIdentifier (_0_ ',' _0_ lowerStartIdentifier)* _0_ '}' (_0_ asClause)? + +constructorFunctionParameter <- + upperStartIdentifier (_0_ functionParameter)* (_0_ asClause)? + +asClause <- + 'as' _1_ lowerStartIdentifier + +# Expressions + +expression <- + (letInBlock _NL_IND_)? simpleExpression (_0_ binaryOperator _0_ expression)* + +simpleExpression <- + hexNumber + / decimal + / multilineString + / characterLiteral + / oneLineString + / tupleExpression + / listExpression + / recordExpression + / caseStatement + / ifThenElseStatement + / anonymousFunction + / functionCall + +tupleExpression <- + '(' _0_ expression (_0_ ',' _0_ expression)* _0_ ')' + / '(' _0_ ')' + +listExpression <- + '[' _0_ expression (_0_ ',' _0_ expression)* _0_ ']' + / '[' _0_ ']' + +recordExpression <- + '{' _0_ + (lowerStartIdentifier _0_ '|' _0_)? + recordExpressionAssignment (_0_ ',' _0_ recordExpressionAssignment)* _0_ + '}' + / '{' _0_ '}' + +recordExpressionAssignment <- + lowerStartIdentifier _0_ '=' _0_ expression + +anonymousFunction <- + '\\' _0_ functionParameterList _0_ '->' _0_ expression + +functionCall <- + ( dottedIdentifier + / '.' lowerStartIdentifier + / '(' binaryOperator ')' + ) (_1_ expression)* + +# Let/in block +# +# We'll treat let/in blocks very simply - we'll consider each line +# and expect the whole line either to be the start of a function +# definition (perhaps with some of its body) or its body. So something +# like 'f x y =' will have to be on one line. + +letInBlock <- + 'let' _NL_IND_ + letInLine (_NL_IND_ letInLine)* _NL_IND_ + 'in' + +letInLine <- + letInFunctionDefinition + / letInBlock + / letInFunctionBody + +letInFunctionDefinition <- + (WS+ nonKeywordIdentifier)* WS* '=' Non_NL* { + makeElmTag(auxil, $1, $1s, K_FUNCTION, ROLE_DEFINITION_INDEX); + } + +letInFunctionBody <- + !('let' / 'in') Non_NL+ + +# Case statements +# +# We're going to be pretty loose with case statements, otherwise we'd +# have to follow Elm's indentation rules. So we'll just say +# the body of a case statement is a series of patterns like this: +# -> . The might well swallow +# up a bit of the next case pattern (because to do otherwise requires +# following Elm's indentation rules), so that's why we just specify +# . + +caseStatement <- + 'case' _1_ expression _0_ 'of' _1_ + caseClauseList + +caseClauseList <- + caseClause (_1_ caseClause)* + +caseClause <- + roughCasePatternChar* '->' _0_ expression + +roughCasePatternChar <- + !('->' / TLSS / lineComment / delimitedComment / NL) . + +# If/then/else statements + +ifThenElseStatement <- + 'if' _1_ expression _1_ + 'then' _1_ expression _1_ + 'else' _1_ expression + +# Binary operators + +binaryOperator <- + '>>' / '<<' / '|>' / '<|' + / '//' / '++' / '::' + / '==' / '/=' + / '&&' / '||' + / '<=' / '>=' + / '<' / '>' + / '+' / '-' / '*' / '/' / '^' + +# Sometimes we just need to ignore the rest of the (top level) statement + +ignoreRestOfStatement <- + (multilineString / Non_WS_or_NL+) (_1_ ignoreRestOfStatement)* + +multilineString <- + '"""' (!'"""' .)* '"""' + +# Low level tokens ------------------------------------------------------- + +# Identifiers + +naiveIdentifier <- [A-Za-z_] alphanumeric* + +upperStartIdentifier <- [A-Z] alphanumeric* + +lowerStartIdentifier <- !keyword [a-z_] alphanumeric* + +alphanumeric <- [A-Za-z0-9_] + +nonKeywordIdentifier <- + !keyword naiveIdentifier + +keyword <- + 'type' !alphanumeric + / 'module' !alphanumeric + / 'port' !alphanumeric + / 'alias' !alphanumeric + / 'as' !alphanumeric + / 'exposing' !alphanumeric + / 'import' !alphanumeric + / 'let' !alphanumeric + / 'in' !alphanumeric + / 'case' !alphanumeric + / 'of' !alphanumeric + / 'if' !alphanumeric + / 'then' !alphanumeric + / 'else' !alphanumeric + +dottedIdentifier <- nonKeywordIdentifier ('.' nonKeywordIdentifier)* + +# Numbers + +decimal <- + exponentialDecimal + / simpleDecimal + +exponentialDecimal <- + simpleDecimal 'e' simpleInteger + +simpleDecimal <- + simpleInteger ('.' digits)? + / '.' digits+ + +simpleInteger <- [-+]? digits + +digits <- [0-9]+ + +hexNumber <- '0x' [0-9A-Fa-f]+ + +# One line strings and characters + +oneLineString <- '"' inStringChar* '"' + +characterLiteral <- "'" inStringChar "'" + +inStringChar <- + !('"' / NL) + ( inStringUnicodeChar / inStringEscapedChar / inStringPlainChar ) + +inStringPlainChar <- + !('"' / '\\' / NL) . + +inStringEscapedChar <- + '\\' !('u' / NL) . + +inStringUnicodeChar <- + '\\u{' [0-9A-Fa-f]+ '}' + +# Ignorable things ------------------------------------------------------- + +# Simple things... + +WS <- [ \t]+ +NL <- '\n' / '\f' / '\r' '\n'? +Non_NL <- [^\n\r\f] +Non_WS_or_NL <- [^ \t\n\r\f] +EOF <- !. + +# A delimited comment is effectively "nothing", even if it spans several +# lines. But it does separate two tokens. +# +# A line comment can only come at the end of a line. Notice here it doesn't +# include the actual newline. + +delimitedComment <- '{-' (delimitedComment / !'-}' .)* '-}' + +lineComment <- '--' Non_NL* + +# Elm whitespacing is a bit special... +# - Two statements are at the same level (eg at the top level, or statements +# in the same let...in block) only if they begin with the same indentation. +# - One line has more indentation than the previous line then it is a +# continuation of that previous line. +# - But sometimes several statements can appear on the same line if tokens +# make it obvious. Eg this is okay: +# Eg: 'myFunc = let f x y = x + y in f 3 4' +# +# We'll only worry about top level statements for this part. But we still +# need to know +# - when a top level statement begins; and +# - when two sequential tokens are part of the same top level statement. +# They may be separated by a combination of whitespace, comments, and +# newlines, but if there is a newline then that will always be followed +# by an indent. +# +# When considering how one token relates to the next in top level statements +# we should only need three kinds of "join"s: +# - Where we need whitespace, such as 'import MyModule', but that space +# may occur over multiple lines. If it's over multiple lines, the +# second token needs to be somewhat in from the first column of text. +# We'll call this _1_ - ie at least one space. +# - Where we don't need whitespace, such as 'f = 3', but that space +# may occur over multiple lines. If it's over multiple lines then again +# the second token needs to be somewhat in from the first column of text. +# We'll call this _0_ - ie possibly zero space. +# - When we've got an end of statement, and the next token is some +# meaningful code (not a comment) and starts in the first column of text. +# Then that next token is the start of the next top level statement. +# We'll call this TLSS, for top level statement separator. +# +# We can define _1_ as +# - The longest possible sequence of whitespace, delimited comments, +# newlines, and line comments, as long as it ends with a whitespace +# or a delimited comment, because then it won't be in the first column. +# +# We can define _0_ as +# - _1_ or the empty string. +# +# We can define TLSS as +# - The longest possible sequence of whitespace, delimited comments, +# newlines, and line comments, as long as it ends with a newline or EOF +# (and there's no more ignorable characters after that). +# +# PEG parsing tip: If we want to define a sequence like 'the longest +# sequence of As, Bs and Cs, as long as it ends with C' we define a short +# sequence like 'the longest sequence of As and Bs, then a C' and then +# define 'the longest sequence of those'. + +_1_short <- + (lineComment / NL)* (WS / delimitedComment) + +_1_ <- _1_short+ + + +_0_ <- _1_ / '' + +TLSS_short <- + (WS / lineComment / delimitedComment)* (NL / EOF) + +TLSS <- + TLSS_short+ + !(WS / lineComment / delimitedComment) + +# An end of statement marks the end of a top level statement, but +# doesn't consume anything + +EOS <- &( TLSS / EOF ) + +# When considering lines in a let/in block we'll want to look for +# a newline and an indent. There may be some delimited comments etc +# in between. + +_NL_IND_ <- + TLSS_short+ WS+ + +%% +#include "elm_post.h" diff --git a/peg/elm_post.h b/peg/elm_post.h new file mode 100644 index 0000000000..b2f079e7ad --- /dev/null +++ b/peg/elm_post.h @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2022 Nik Silver + * based on the Kotlin code by Jan DolinĂ¡r + * + * This source code is released for free distribution under the terms of the + * GNU General Public License version 2 or (at your option) any later version. + * + * This module contains functions to generate tags for Elm. + */ + +/* + * INCLUDE FILES + */ +#include "parse.h" +#include "trace.h" + +/* + * FUNCTION DEFINITIONS + */ + +/* kind - The kind of this tag. + * role - The role this tag plays. But def(ined) is expressed by setting + * this to ROLE_DEFINITION_INDEX. + * pushScope - If true, also update the scope to be this tag. + */ +static int makeElmTag (struct parserCtx *auxil, const char *name, long offset, int kind, int role) +{ + tagEntryInfo e; + + if (role == ROLE_DEFINITION_INDEX) + { + initTagEntry (&e, name, kind); + } + else + { + initRefTagEntry (&e, name, kind, role); + } + + e.lineNumber = getInputLineNumberForFileOffset (offset); + e.filePosition = getInputFilePositionForLine (e.lineNumber); + e.extensionFields.scopeIndex = BASE_SCOPE (auxil); + int scope_index = makeTagEntry (&e); + return scope_index; +} + +/* Like makeElmTag, but have this tag be the latest scope. + */ +static int makeElmTagSettingScope (struct parserCtx *auxil, const char *name, long offset, int kind, int role) +{ + // Here is a useless line just to use a function and so + // get rid of a compiler warning. + if (1 < 0) + { + PEEK_KIND (auxil); + } + // The real function starts here... + + int scope_index = makeElmTag (auxil, name, offset, kind, role); + SET_SCOPE (auxil, scope_index); + return scope_index; +} + +static void addElmSignature(int scope_index, const char *sig) +{ + tagEntryInfo *e = getEntryInCorkQueue (scope_index); + + if (e) + { + vString *vsig = collapseWhitespace (sig); + const char *sig2 = vStringValue (vsig); + + e->extensionFields.signature = eStrdup (sig2); + + vStringDelete (vsig); + } +} + +/* For a signature such as "a1 b2 c3" we want to transform it + * to "a1 b2 c3" for the signature field. + */ +static vString *collapseWhitespace (const char *sig) +{ + vString *vstr = vStringNew (); + + const char *c = sig; + char c2; + int found_ws = 0; + + for ( ; *c != '\0'; c++) + { + // The character, in case we need to change it + c2 = *c; + + if (c2 == ' ' || c2 == '\t' || c2 == '\r' || c2 == '\n' || c2 == '\f') + { + // It's whitespace. Make it plain space + c2 = ' '; + if (found_ws) + { + // We found whitespace just before, so ignore this + continue; + } + + found_ws = 1; + } + else + { + found_ws = 0; + } + vStringPut (vstr, c2); + } + + return vstr; +} + +static void ctxInit (struct parserCtx *auxil) +{ + BASE_INIT (auxil, K_MODULE); +} + +static void ctxFini (struct parserCtx *auxil) +{ + BASE_FINI (auxil); +} + +static void findElmTags (void) +{ + struct parserCtx auxil; + + ctxInit (&auxil); + pelm_context_t *pctx = pelm_create (&auxil); + + while (pelm_parse (pctx, NULL) && (! BASE_ERROR (&auxil))) + ; + + pelm_destroy (pctx); + ctxFini (&auxil); +} + +extern parserDefinition *ElmParser (void) +{ + static const char *const extensions [] = { "elm", NULL }; + parserDefinition *def = parserNew ("Elm"); + def->kindTable = ElmKinds; + def->kindCount = ARRAY_SIZE (ElmKinds); + def->extensions = extensions; + def->parser = findElmTags; + def->fieldTable = ElmFields; + def->fieldCount = ARRAY_SIZE (ElmFields); + def->useCork = true; + def->enabled = true; + //def->requestAutomaticFQTag = true; + def->defaultScopeSeparator = "."; + return def; +} diff --git a/peg/elm_pre.h b/peg/elm_pre.h new file mode 100644 index 0000000000..6951a6b016 --- /dev/null +++ b/peg/elm_pre.h @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2022 Nik Silver + * + * This source code is released for free distribution under the terms of the + * GNU General Public License version 2 or (at your option) any later version. + * + * This module contains macros, data decls and prototypes to generate tags for Elm. + */ + +/* + * INCLUDE FILES + */ + +#include "kind.h" +#include "peg_common.h" + +/* + * This allows us to save and restore the module scope. + * We want to do this because it's unhelpful to say that an imported item + * is the scope of the importing module. + */ + +// Remember the scope of the module tag. But at first there is none (CORK_NIL). +static int elm_module_scope_index; + +#define ELM_INIT_MODULE_SCOPE \ + elm_module_scope_index = CORK_NIL +#define ELM_SAVE_MODULE_SCOPE \ + if (elm_module_scope_index != CORK_NIL) { \ + POP_SCOPE (auxil); \ + } +#define ELM_RESTORE_MODULE_SCOPE \ + if (elm_module_scope_index != CORK_NIL) { \ + SET_SCOPE (auxil, elm_module_scope_index); \ + } else { \ + POP_SCOPE (auxil); \ + } + +/* + * DATA DECLARATIONS + */ +typedef enum { + K_MODULE, + K_NAMESPACE, + K_TYPE, + K_CONSTRUCTOR, + K_ALIAS, + K_PORT, + K_FUNCTION, + COUNT_KINDS, +} ElmKind; + +/* We only define roles which aren't def(ined) + */ +typedef enum { + ELM_ROLE_IMPORTED +} elmRoles; + +static roleDefinition ElmRoles [] = { + { true, "imported", "item imported" }, +}; + +typedef enum { + F_MODULENAME, + COUNT_FIELDS, +} ElmField; + +static fieldDefinition ElmFields [COUNT_FIELDS] = { + { .name = "moduleName", + .description = "actual name of renamed module", + .enabled = true }, +}; + +/* Use referenceOnly = true when a tag must always appear + * as role that's not def(ined). + */ +static kindDefinition ElmKinds [COUNT_KINDS] = { + { true, 'm', "module", "modules", + .referenceOnly = false, ATTACH_ROLES (ElmRoles) }, + { true, 'n', "namespace", "modules renamed", }, + { true, 't', "type", "types", + .referenceOnly = false, ATTACH_ROLES (ElmRoles) }, + { true, 'c', "constructor", "constructors", + .referenceOnly = false, ATTACH_ROLES (ElmRoles) }, + { true, 'a', "alias", "aliases", }, + { true, 'p', "port", "ports", }, + { true, 'f', "function", "functions", + .referenceOnly = false, ATTACH_ROLES (ElmRoles) }, +}; + +struct parserCtx { + struct parserBaseCtx base; +}; + +/* +* FUNCTION PROTOTYPES +*/ +#define USE_KIND_STACK KIND_GHOST_INDEX +static int makeElmTag (struct parserCtx *auxil, const char *name, long offset, int kind, int role); +static int makeElmTagSettingScope (struct parserCtx *auxil, const char *name, long offset, int kind, int role); +static void addElmSignature(int scope_index, const char *str); +static vString *collapseWhitespace (const char *sig); diff --git a/source.mak b/source.mak index 18b7459290..5387e89e73 100644 --- a/source.mak +++ b/source.mak @@ -204,7 +204,6 @@ OPTLIB2C_INPUT = \ optlib/cmake.ctags \ optlib/ctags-optlib.ctags \ optlib/elixir.ctags \ - optlib/elm.ctags \ optlib/gdbinit.ctags \ optlib/inko.ctags \ optlib/iPythonCell.ctags \ @@ -236,6 +235,7 @@ PEG_INPUT = \ peg/varlink.peg \ peg/kotlin.peg \ peg/thrift.peg \ + peg/elm.peg \ \ $(NULL) PEG_SRCS = $(PEG_INPUT:.peg=.c) diff --git a/win32/ctags_vs2013.vcxproj b/win32/ctags_vs2013.vcxproj index 5bfb6e84b8..05e718f8d9 100644 --- a/win32/ctags_vs2013.vcxproj +++ b/win32/ctags_vs2013.vcxproj @@ -233,7 +233,6 @@ - @@ -463,4 +462,4 @@ - \ No newline at end of file + diff --git a/win32/ctags_vs2013.vcxproj.filters b/win32/ctags_vs2013.vcxproj.filters index 33ffcb3f2e..de83fba6cd 100644 --- a/win32/ctags_vs2013.vcxproj.filters +++ b/win32/ctags_vs2013.vcxproj.filters @@ -222,9 +222,6 @@ Source Files\optlib - - Source Files\optlib - Source Files\optlib @@ -893,4 +890,4 @@ Resource Files - \ No newline at end of file + From 7b03368d7636d22d788db9c0622fa2460c9de544 Mon Sep 17 00:00:00 2001 From: Nik Silver Date: Wed, 23 Mar 2022 20:18:13 +0000 Subject: [PATCH 02/11] Tmain: Update tests for new Elm parser --- Tmain/list-fields-with-prefix.d/stdout-expected.txt | 1 + Tmain/list-fields.d/stdout-expected.txt | 1 + Tmain/list-roles.d/stdout-expected.txt | 10 ++++++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Tmain/list-fields-with-prefix.d/stdout-expected.txt b/Tmain/list-fields-with-prefix.d/stdout-expected.txt index dcfcdc9ffe..898a490932 100644 --- a/Tmain/list-fields-with-prefix.d/stdout-expected.txt +++ b/Tmain/list-fields-with-prefix.d/stdout-expected.txt @@ -19,6 +19,7 @@ x UCTAGSxpath no NONE s-- no -- xpath for - UCTAGSmacrodef no CPreProcessor s-- no -- macro definition - UCTAGSmacrodef no CUDA s-- no -- macro definition - UCTAGSproperties no CUDA s-- no -- properties (static, inline, mutable,...) +- UCTAGSmoduleName yes Elm s-- no -- actual name of renamed module - UCTAGSannotations yes GDScript s-- no -- annotations on functions and variables - UCTAGShowImported no Go s-- no -- how the package is imported ("inline" for `.' or "init" for `_') - UCTAGSpackage yes Go s-- no -- the real package specified by the package name diff --git a/Tmain/list-fields.d/stdout-expected.txt b/Tmain/list-fields.d/stdout-expected.txt index 7d48f48e8f..d05ad961de 100644 --- a/Tmain/list-fields.d/stdout-expected.txt +++ b/Tmain/list-fields.d/stdout-expected.txt @@ -37,6 +37,7 @@ z kind no NONE s-- no r- [tags output] prepend "kind:" to k/ (or K/) field outpu - macrodef no CPreProcessor s-- no -- macro definition - macrodef no CUDA s-- no -- macro definition - properties no CUDA s-- no -- properties (static, inline, mutable,...) +- moduleName yes Elm s-- no -- actual name of renamed module - annotations yes GDScript s-- no -- annotations on functions and variables - howImported no Go s-- no -- how the package is imported ("inline" for `.' or "init" for `_') - package yes Go s-- no -- the real package specified by the package name diff --git a/Tmain/list-roles.d/stdout-expected.txt b/Tmain/list-roles.d/stdout-expected.txt index 2768d11872..3d29e154b9 100644 --- a/Tmain/list-roles.d/stdout-expected.txt +++ b/Tmain/list-roles.d/stdout-expected.txt @@ -40,7 +40,10 @@ DTD e/element attOwner on attributes owner DTD p/parameterEntity condition on conditions DTD p/parameterEntity elementName on element names DTD p/parameterEntity partOfAttDef on part of attribute definition -Elm m/module imported on imported module +Elm c/constructor imported on item imported +Elm f/function imported on item imported +Elm m/module imported on item imported +Elm t/type imported on item imported Flex I/import import on imports GDScript c/class extended on used as a base class for extending GemSpec g/gem develDep on specifying development dependency @@ -145,7 +148,10 @@ DTD e/element attOwner on attributes owner DTD p/parameterEntity condition on conditions DTD p/parameterEntity elementName on element names DTD p/parameterEntity partOfAttDef on part of attribute definition -Elm m/module imported on imported module +Elm c/constructor imported on item imported +Elm f/function imported on item imported +Elm m/module imported on item imported +Elm t/type imported on item imported Flex I/import import on imports GDScript c/class extended on used as a base class for extending GemSpec g/gem develDep on specifying development dependency From 2d85e580789f46dd3cb5bbbeee00ffd4a69ac28e Mon Sep 17 00:00:00 2001 From: Nik Silver Date: Wed, 23 Mar 2022 20:20:32 +0000 Subject: [PATCH 03/11] refactor: Remove Elm source generated by build system --- peg/elm.c | 6760 ----------------------------------------------------- peg/elm.h | 22 - 2 files changed, 6782 deletions(-) delete mode 100644 peg/elm.c delete mode 100644 peg/elm.h diff --git a/peg/elm.c b/peg/elm.c deleted file mode 100644 index 867c178839..0000000000 --- a/peg/elm.c +++ /dev/null @@ -1,6760 +0,0 @@ -/* A packrat parser generated by PackCC 1.6.0 */ - -#include "general.h" -#ifdef _MSC_VER -#undef _CRT_SECURE_NO_WARNINGS -#define _CRT_SECURE_NO_WARNINGS -#endif /* _MSC_VER */ -#include -#include -#include - -#ifndef _MSC_VER -#if defined __GNUC__ && defined _WIN32 /* MinGW */ -#ifndef PCC_USE_SYSTEM_STRNLEN -#define strnlen(str, maxlen) pcc_strnlen(str, maxlen) -static size_t pcc_strnlen(const char *str, size_t maxlen) { - size_t i; - for (i = 0; i < maxlen && str[i]; i++); - return i; -} -#endif /* !PCC_USE_SYSTEM_STRNLEN */ -#endif /* defined __GNUC__ && defined _WIN32 */ -#endif /* !_MSC_VER */ - -#include "./peg/elm.h" - -#include "elm_pre.h" -#include "routines.h" - -/* - * Include these lines to debug the parsing. - * From https://github.com/arithy/packcc#macros - * This will output parsing info to STDERR.tmp in the vent of a failed test. - */ - -/* -static const char *dbg_str[] = { "Evaluating rule", "Matched rule", "Abandoning rule" }; - -#define PCC_DEBUG(auxil, event, rule, level, pos, buffer, length) \ - fprintf(stderr, "%*s%s %s @%zu [%.*s]\n", \ - (int)((level) * 2), "", dbg_str[event], rule, pos, (int)(length), buffer) - */ -#if !defined __has_attribute || defined _MSC_VER -#define __attribute__(x) -#endif - -#ifdef _MSC_VER -#define MARK_USED_FUNC __pragma(warning(suppress:4505)) -#else -#define MARK_USED_FUNC __attribute__((__unused__)) -#endif - -#ifndef PCC_BUFFERSIZE -#define PCC_BUFFERSIZE 256 -#endif /* !PCC_BUFFERSIZE */ - -#ifndef PCC_ARRAYSIZE -#define PCC_ARRAYSIZE 2 -#endif /* !PCC_ARRAYSIZE */ - -#define PCC_DBG_EVALUATE 0 -#define PCC_DBG_MATCH 1 -#define PCC_DBG_NOMATCH 2 - -#define PCC_VOID_VALUE (~(size_t)0) - -typedef enum pcc_bool_tag { - PCC_FALSE = 0, - PCC_TRUE -} pcc_bool_t; - -typedef struct pcc_char_array_tag { - char *buf; - size_t max; - size_t len; -} pcc_char_array_t; - -typedef struct pcc_range_tag { - size_t start; - size_t end; -} pcc_range_t; - -typedef int pcc_value_t; - -typedef struct parserCtx *pcc_auxil_t; - -typedef struct pcc_value_table_tag { - pcc_value_t *buf; - size_t max; - size_t len; -} pcc_value_table_t; - -typedef struct pcc_value_refer_table_tag { - pcc_value_t **buf; - size_t max; - size_t len; -} pcc_value_refer_table_t; - -typedef struct pcc_capture_tag { - pcc_range_t range; - char *string; /* mutable */ -} pcc_capture_t; - -typedef struct pcc_capture_table_tag { - pcc_capture_t *buf; - size_t max; - size_t len; -} pcc_capture_table_t; - -typedef struct pcc_capture_const_table_tag { - const pcc_capture_t **buf; - size_t max; - size_t len; -} pcc_capture_const_table_t; - -typedef struct pcc_thunk_tag pcc_thunk_t; -typedef struct pcc_thunk_array_tag pcc_thunk_array_t; - -typedef void (*pcc_action_t)(pelm_context_t *, pcc_thunk_t *, pcc_value_t *); - -typedef enum pcc_thunk_type_tag { - PCC_THUNK_LEAF, - PCC_THUNK_NODE -} pcc_thunk_type_t; - -typedef struct pcc_thunk_leaf_tag { - pcc_value_refer_table_t values; - pcc_capture_const_table_t capts; - pcc_capture_t capt0; - pcc_action_t action; -} pcc_thunk_leaf_t; - -typedef struct pcc_thunk_node_tag { - const pcc_thunk_array_t *thunks; /* just a reference */ - pcc_value_t *value; /* just a reference */ -} pcc_thunk_node_t; - -typedef union pcc_thunk_data_tag { - pcc_thunk_leaf_t leaf; - pcc_thunk_node_t node; -} pcc_thunk_data_t; - -struct pcc_thunk_tag { - pcc_thunk_type_t type; - pcc_thunk_data_t data; -}; - -struct pcc_thunk_array_tag { - pcc_thunk_t **buf; - size_t max; - size_t len; -}; - -typedef struct pcc_thunk_chunk_tag { - pcc_value_table_t values; - pcc_capture_table_t capts; - pcc_thunk_array_t thunks; - size_t pos; /* the starting position in the character buffer */ -} pcc_thunk_chunk_t; - -typedef struct pcc_lr_entry_tag pcc_lr_entry_t; - -typedef enum pcc_lr_answer_type_tag { - PCC_LR_ANSWER_LR, - PCC_LR_ANSWER_CHUNK -} pcc_lr_answer_type_t; - -typedef union pcc_lr_answer_data_tag { - pcc_lr_entry_t *lr; - pcc_thunk_chunk_t *chunk; -} pcc_lr_answer_data_t; - -typedef struct pcc_lr_answer_tag pcc_lr_answer_t; - -struct pcc_lr_answer_tag { - pcc_lr_answer_type_t type; - pcc_lr_answer_data_t data; - size_t pos; /* the absolute position in the input */ - pcc_lr_answer_t *hold; -}; - -typedef pcc_thunk_chunk_t *(*pcc_rule_t)(pelm_context_t *); - -typedef struct pcc_rule_set_tag { - pcc_rule_t *buf; - size_t max; - size_t len; -} pcc_rule_set_t; - -typedef struct pcc_lr_head_tag pcc_lr_head_t; - -struct pcc_lr_head_tag { - pcc_rule_t rule; - pcc_rule_set_t invol; - pcc_rule_set_t eval; - pcc_lr_head_t *hold; -}; - -typedef struct pcc_lr_memo_tag { - pcc_rule_t rule; - pcc_lr_answer_t *answer; -} pcc_lr_memo_t; - -typedef struct pcc_lr_memo_map_tag { - pcc_lr_memo_t *buf; - size_t max; - size_t len; -} pcc_lr_memo_map_t; - -typedef struct pcc_lr_table_entry_tag { - pcc_lr_head_t *head; /* just a reference */ - pcc_lr_memo_map_t memos; - pcc_lr_answer_t *hold_a; - pcc_lr_head_t *hold_h; -} pcc_lr_table_entry_t; - -typedef struct pcc_lr_table_tag { - pcc_lr_table_entry_t **buf; - size_t max; - size_t len; - size_t ofs; -} pcc_lr_table_t; - -struct pcc_lr_entry_tag { - pcc_rule_t rule; - pcc_thunk_chunk_t *seed; /* just a reference */ - pcc_lr_head_t *head; /* just a reference */ -}; - -typedef struct pcc_lr_stack_tag { - pcc_lr_entry_t **buf; - size_t max; - size_t len; -} pcc_lr_stack_t; - -struct pelm_context_tag { - size_t pos; /* the position in the input of the first character currently buffered */ - size_t cur; /* the current parsing position in the character buffer */ - size_t level; - pcc_char_array_t buffer; - pcc_lr_table_t lrtable; - pcc_lr_stack_t lrstack; - pcc_thunk_array_t thunks; - pcc_auxil_t auxil; -}; - -#ifndef PCC_ERROR -#define PCC_ERROR(auxil) pcc_error() -MARK_USED_FUNC -static void pcc_error(void) { - fprintf(stderr, "Syntax error\n"); - exit(1); -} -#endif /* !PCC_ERROR */ - -#ifndef PCC_GETCHAR -#define PCC_GETCHAR(auxil) getchar() -#endif /* !PCC_GETCHAR */ - -#ifndef PCC_MALLOC -#define PCC_MALLOC(auxil, size) pcc_malloc_e(size) -static void *pcc_malloc_e(size_t size) { - void *const p = malloc(size); - if (p == NULL) { - fprintf(stderr, "Out of memory\n"); - exit(1); - } - return p; -} -#endif /* !PCC_MALLOC */ - -#ifndef PCC_REALLOC -#define PCC_REALLOC(auxil, ptr, size) pcc_realloc_e(ptr, size) -static void *pcc_realloc_e(void *ptr, size_t size) { - void *const p = realloc(ptr, size); - if (p == NULL) { - fprintf(stderr, "Out of memory\n"); - exit(1); - } - return p; -} -#endif /* !PCC_REALLOC */ - -#ifndef PCC_FREE -#define PCC_FREE(auxil, ptr) free(ptr) -#endif /* !PCC_FREE */ - -#ifndef PCC_DEBUG -#define PCC_DEBUG(auxil, event, rule, level, pos, buffer, length) ((void)0) -#endif /* !PCC_DEBUG */ - -static char *pcc_strndup_e(pcc_auxil_t auxil, const char *str, size_t len) { - const size_t m = strnlen(str, len); - char *const s = (char *)PCC_MALLOC(auxil, m + 1); - memcpy(s, str, m); - s[m] = '\0'; - return s; -} - -static void pcc_char_array__init(pcc_auxil_t auxil, pcc_char_array_t *array) { - array->len = 0; - array->max = 0; - array->buf = NULL; -} - -static void pcc_char_array__add(pcc_auxil_t auxil, pcc_char_array_t *array, char ch) { - if (array->max <= array->len) { - const size_t n = array->len + 1; - size_t m = array->max; - if (m == 0) m = PCC_BUFFERSIZE; - while (m < n && m != 0) m <<= 1; - if (m == 0) m = n; - array->buf = (char *)PCC_REALLOC(auxil, array->buf, m); - array->max = m; - } - array->buf[array->len++] = ch; -} - -static void pcc_char_array__term(pcc_auxil_t auxil, pcc_char_array_t *array) { - PCC_FREE(auxil, array->buf); -} - -static void pcc_value_table__init(pcc_auxil_t auxil, pcc_value_table_t *table) { - table->len = 0; - table->max = 0; - table->buf = NULL; -} - -MARK_USED_FUNC -static void pcc_value_table__resize(pcc_auxil_t auxil, pcc_value_table_t *table, size_t len) { - if (table->max < len) { - size_t m = table->max; - if (m == 0) m = PCC_ARRAYSIZE; - while (m < len && m != 0) m <<= 1; - if (m == 0) m = len; - table->buf = (pcc_value_t *)PCC_REALLOC(auxil, table->buf, sizeof(pcc_value_t) * m); - table->max = m; - } - table->len = len; -} - -static void pcc_value_table__term(pcc_auxil_t auxil, pcc_value_table_t *table) { - PCC_FREE(auxil, table->buf); -} - -static void pcc_value_refer_table__init(pcc_auxil_t auxil, pcc_value_refer_table_t *table) { - table->len = 0; - table->max = 0; - table->buf = NULL; -} - -static void pcc_value_refer_table__resize(pcc_auxil_t auxil, pcc_value_refer_table_t *table, size_t len) { - size_t i; - if (table->max < len) { - size_t m = table->max; - if (m == 0) m = PCC_ARRAYSIZE; - while (m < len && m != 0) m <<= 1; - if (m == 0) m = len; - table->buf = (pcc_value_t **)PCC_REALLOC(auxil, table->buf, sizeof(pcc_value_t *) * m); - table->max = m; - } - for (i = table->len; i < len; i++) table->buf[i] = NULL; - table->len = len; -} - -static void pcc_value_refer_table__term(pcc_auxil_t auxil, pcc_value_refer_table_t *table) { - PCC_FREE(auxil, table->buf); -} - -static void pcc_capture_table__init(pcc_auxil_t auxil, pcc_capture_table_t *table) { - table->len = 0; - table->max = 0; - table->buf = NULL; -} - -MARK_USED_FUNC -static void pcc_capture_table__resize(pcc_auxil_t auxil, pcc_capture_table_t *table, size_t len) { - size_t i; - for (i = len; i < table->len; i++) PCC_FREE(auxil, table->buf[i].string); - if (table->max < len) { - size_t m = table->max; - if (m == 0) m = PCC_ARRAYSIZE; - while (m < len && m != 0) m <<= 1; - if (m == 0) m = len; - table->buf = (pcc_capture_t *)PCC_REALLOC(auxil, table->buf, sizeof(pcc_capture_t) * m); - table->max = m; - } - for (i = table->len; i < len; i++) { - table->buf[i].range.start = 0; - table->buf[i].range.end = 0; - table->buf[i].string = NULL; - } - table->len = len; -} - -static void pcc_capture_table__term(pcc_auxil_t auxil, pcc_capture_table_t *table) { - while (table->len > 0) { - table->len--; - PCC_FREE(auxil, table->buf[table->len].string); - } - PCC_FREE(auxil, table->buf); -} - -static void pcc_capture_const_table__init(pcc_auxil_t auxil, pcc_capture_const_table_t *table) { - table->len = 0; - table->max = 0; - table->buf = NULL; -} - -static void pcc_capture_const_table__resize(pcc_auxil_t auxil, pcc_capture_const_table_t *table, size_t len) { - size_t i; - if (table->max < len) { - size_t m = table->max; - if (m == 0) m = PCC_ARRAYSIZE; - while (m < len && m != 0) m <<= 1; - if (m == 0) m = len; - table->buf = (const pcc_capture_t **)PCC_REALLOC(auxil, (pcc_capture_t **)table->buf, sizeof(const pcc_capture_t *) * m); - table->max = m; - } - for (i = table->len; i < len; i++) table->buf[i] = NULL; - table->len = len; -} - -static void pcc_capture_const_table__term(pcc_auxil_t auxil, pcc_capture_const_table_t *table) { - PCC_FREE(auxil, (void *)table->buf); -} - -MARK_USED_FUNC -static pcc_thunk_t *pcc_thunk__create_leaf(pcc_auxil_t auxil, pcc_action_t action, size_t valuec, size_t captc) { - pcc_thunk_t *const thunk = (pcc_thunk_t *)PCC_MALLOC(auxil, sizeof(pcc_thunk_t)); - thunk->type = PCC_THUNK_LEAF; - pcc_value_refer_table__init(auxil, &thunk->data.leaf.values); - pcc_value_refer_table__resize(auxil, &thunk->data.leaf.values, valuec); - pcc_capture_const_table__init(auxil, &thunk->data.leaf.capts); - pcc_capture_const_table__resize(auxil, &thunk->data.leaf.capts, captc); - thunk->data.leaf.capt0.range.start = 0; - thunk->data.leaf.capt0.range.end = 0; - thunk->data.leaf.capt0.string = NULL; - thunk->data.leaf.action = action; - return thunk; -} - -static pcc_thunk_t *pcc_thunk__create_node(pcc_auxil_t auxil, const pcc_thunk_array_t *thunks, pcc_value_t *value) { - pcc_thunk_t *const thunk = (pcc_thunk_t *)PCC_MALLOC(auxil, sizeof(pcc_thunk_t)); - thunk->type = PCC_THUNK_NODE; - thunk->data.node.thunks = thunks; - thunk->data.node.value = value; - return thunk; -} - -static void pcc_thunk__destroy(pcc_auxil_t auxil, pcc_thunk_t *thunk) { - if (thunk == NULL) return; - switch (thunk->type) { - case PCC_THUNK_LEAF: - PCC_FREE(auxil, thunk->data.leaf.capt0.string); - pcc_capture_const_table__term(auxil, &thunk->data.leaf.capts); - pcc_value_refer_table__term(auxil, &thunk->data.leaf.values); - break; - case PCC_THUNK_NODE: - break; - default: /* unknown */ - break; - } - PCC_FREE(auxil, thunk); -} - -static void pcc_thunk_array__init(pcc_auxil_t auxil, pcc_thunk_array_t *array) { - array->len = 0; - array->max = 0; - array->buf = NULL; -} - -static void pcc_thunk_array__add(pcc_auxil_t auxil, pcc_thunk_array_t *array, pcc_thunk_t *thunk) { - if (array->max <= array->len) { - const size_t n = array->len + 1; - size_t m = array->max; - if (m == 0) m = PCC_ARRAYSIZE; - while (m < n && m != 0) m <<= 1; - if (m == 0) m = n; - array->buf = (pcc_thunk_t **)PCC_REALLOC(auxil, array->buf, sizeof(pcc_thunk_t *) * m); - array->max = m; - } - array->buf[array->len++] = thunk; -} - -static void pcc_thunk_array__revert(pcc_auxil_t auxil, pcc_thunk_array_t *array, size_t len) { - while (array->len > len) { - array->len--; - pcc_thunk__destroy(auxil, array->buf[array->len]); - } -} - -static void pcc_thunk_array__term(pcc_auxil_t auxil, pcc_thunk_array_t *array) { - while (array->len > 0) { - array->len--; - pcc_thunk__destroy(auxil, array->buf[array->len]); - } - PCC_FREE(auxil, array->buf); -} - -MARK_USED_FUNC -static pcc_thunk_chunk_t *pcc_thunk_chunk__create(pcc_auxil_t auxil) { - pcc_thunk_chunk_t *const chunk = (pcc_thunk_chunk_t *)PCC_MALLOC(auxil, sizeof(pcc_thunk_chunk_t)); - pcc_value_table__init(auxil, &chunk->values); - pcc_capture_table__init(auxil, &chunk->capts); - pcc_thunk_array__init(auxil, &chunk->thunks); - chunk->pos = 0; - return chunk; -} - -static void pcc_thunk_chunk__destroy(pcc_auxil_t auxil, pcc_thunk_chunk_t *chunk) { - if (chunk == NULL) return; - pcc_thunk_array__term(auxil, &chunk->thunks); - pcc_capture_table__term(auxil, &chunk->capts); - pcc_value_table__term(auxil, &chunk->values); - PCC_FREE(auxil, chunk); -} - -static void pcc_rule_set__init(pcc_auxil_t auxil, pcc_rule_set_t *set) { - set->len = 0; - set->max = 0; - set->buf = NULL; -} - -static size_t pcc_rule_set__index(pcc_auxil_t auxil, const pcc_rule_set_t *set, pcc_rule_t rule) { - size_t i; - for (i = 0; i < set->len; i++) { - if (set->buf[i] == rule) return i; - } - return PCC_VOID_VALUE; -} - -static pcc_bool_t pcc_rule_set__add(pcc_auxil_t auxil, pcc_rule_set_t *set, pcc_rule_t rule) { - const size_t i = pcc_rule_set__index(auxil, set, rule); - if (i != PCC_VOID_VALUE) return PCC_FALSE; - if (set->max <= set->len) { - const size_t n = set->len + 1; - size_t m = set->max; - if (m == 0) m = PCC_ARRAYSIZE; - while (m < n && m != 0) m <<= 1; - if (m == 0) m = n; - set->buf = (pcc_rule_t *)PCC_REALLOC(auxil, set->buf, sizeof(pcc_rule_t) * m); - set->max = m; - } - set->buf[set->len++] = rule; - return PCC_TRUE; -} - -static pcc_bool_t pcc_rule_set__remove(pcc_auxil_t auxil, pcc_rule_set_t *set, pcc_rule_t rule) { - const size_t i = pcc_rule_set__index(auxil, set, rule); - if (i == PCC_VOID_VALUE) return PCC_FALSE; - memmove(set->buf + i, set->buf + (i + 1), sizeof(pcc_rule_t) * (set->len - (i + 1))); - return PCC_TRUE; -} - -static void pcc_rule_set__clear(pcc_auxil_t auxil, pcc_rule_set_t *set) { - set->len = 0; -} - -static void pcc_rule_set__copy(pcc_auxil_t auxil, pcc_rule_set_t *set, const pcc_rule_set_t *src) { - size_t i; - pcc_rule_set__clear(auxil, set); - for (i = 0; i < src->len; i++) { - pcc_rule_set__add(auxil, set, src->buf[i]); - } -} - -static void pcc_rule_set__term(pcc_auxil_t auxil, pcc_rule_set_t *set) { - PCC_FREE(auxil, set->buf); -} - -static pcc_lr_head_t *pcc_lr_head__create(pcc_auxil_t auxil, pcc_rule_t rule) { - pcc_lr_head_t *const head = (pcc_lr_head_t *)PCC_MALLOC(auxil, sizeof(pcc_lr_head_t)); - head->rule = rule; - pcc_rule_set__init(auxil, &head->invol); - pcc_rule_set__init(auxil, &head->eval); - head->hold = NULL; - return head; -} - -static void pcc_lr_head__destroy(pcc_auxil_t auxil, pcc_lr_head_t *head) { - if (head == NULL) return; - pcc_lr_head__destroy(auxil, head->hold); - pcc_rule_set__term(auxil, &head->eval); - pcc_rule_set__term(auxil, &head->invol); - PCC_FREE(auxil, head); -} - -static void pcc_lr_entry__destroy(pcc_auxil_t auxil, pcc_lr_entry_t *lr); - -static pcc_lr_answer_t *pcc_lr_answer__create(pcc_auxil_t auxil, pcc_lr_answer_type_t type, size_t pos) { - pcc_lr_answer_t *answer = (pcc_lr_answer_t *)PCC_MALLOC(auxil, sizeof(pcc_lr_answer_t)); - answer->type = type; - answer->pos = pos; - answer->hold = NULL; - switch (answer->type) { - case PCC_LR_ANSWER_LR: - answer->data.lr = NULL; - break; - case PCC_LR_ANSWER_CHUNK: - answer->data.chunk = NULL; - break; - default: /* unknown */ - PCC_FREE(auxil, answer); - answer = NULL; - } - return answer; -} - -static void pcc_lr_answer__set_chunk(pcc_auxil_t auxil, pcc_lr_answer_t *answer, pcc_thunk_chunk_t *chunk) { - pcc_lr_answer_t *const a = pcc_lr_answer__create(auxil, answer->type, answer->pos); - switch (answer->type) { - case PCC_LR_ANSWER_LR: - a->data.lr = answer->data.lr; - break; - case PCC_LR_ANSWER_CHUNK: - a->data.chunk = answer->data.chunk; - break; - default: /* unknown */ - break; - } - a->hold = answer->hold; - answer->hold = a; - answer->type = PCC_LR_ANSWER_CHUNK; - answer->data.chunk = chunk; -} - -static void pcc_lr_answer__destroy(pcc_auxil_t auxil, pcc_lr_answer_t *answer) { - while (answer != NULL) { - pcc_lr_answer_t *const a = answer->hold; - switch (answer->type) { - case PCC_LR_ANSWER_LR: - pcc_lr_entry__destroy(auxil, answer->data.lr); - break; - case PCC_LR_ANSWER_CHUNK: - pcc_thunk_chunk__destroy(auxil, answer->data.chunk); - break; - default: /* unknown */ - break; - } - PCC_FREE(auxil, answer); - answer = a; - } -} - -static void pcc_lr_memo_map__init(pcc_auxil_t auxil, pcc_lr_memo_map_t *map) { - map->len = 0; - map->max = 0; - map->buf = NULL; -} - -static size_t pcc_lr_memo_map__index(pcc_auxil_t auxil, pcc_lr_memo_map_t *map, pcc_rule_t rule) { - size_t i; - for (i = 0; i < map->len; i++) { - if (map->buf[i].rule == rule) return i; - } - return PCC_VOID_VALUE; -} - -static void pcc_lr_memo_map__put(pcc_auxil_t auxil, pcc_lr_memo_map_t *map, pcc_rule_t rule, pcc_lr_answer_t *answer) { - const size_t i = pcc_lr_memo_map__index(auxil, map, rule); - if (i != PCC_VOID_VALUE) { - pcc_lr_answer__destroy(auxil, map->buf[i].answer); - map->buf[i].answer = answer; - } - else { - if (map->max <= map->len) { - const size_t n = map->len + 1; - size_t m = map->max; - if (m == 0) m = PCC_ARRAYSIZE; - while (m < n && m != 0) m <<= 1; - if (m == 0) m = n; - map->buf = (pcc_lr_memo_t *)PCC_REALLOC(auxil, map->buf, sizeof(pcc_lr_memo_t) * m); - map->max = m; - } - map->buf[map->len].rule = rule; - map->buf[map->len].answer = answer; - map->len++; - } -} - -static pcc_lr_answer_t *pcc_lr_memo_map__get(pcc_auxil_t auxil, pcc_lr_memo_map_t *map, pcc_rule_t rule) { - const size_t i = pcc_lr_memo_map__index(auxil, map, rule); - return (i != PCC_VOID_VALUE) ? map->buf[i].answer : NULL; -} - -static void pcc_lr_memo_map__term(pcc_auxil_t auxil, pcc_lr_memo_map_t *map) { - while (map->len > 0) { - map->len--; - pcc_lr_answer__destroy(auxil, map->buf[map->len].answer); - } - PCC_FREE(auxil, map->buf); -} - -static pcc_lr_table_entry_t *pcc_lr_table_entry__create(pcc_auxil_t auxil) { - pcc_lr_table_entry_t *const entry = (pcc_lr_table_entry_t *)PCC_MALLOC(auxil, sizeof(pcc_lr_table_entry_t)); - entry->head = NULL; - pcc_lr_memo_map__init(auxil, &entry->memos); - entry->hold_a = NULL; - entry->hold_h = NULL; - return entry; -} - -static void pcc_lr_table_entry__destroy(pcc_auxil_t auxil, pcc_lr_table_entry_t *entry) { - if (entry == NULL) return; - pcc_lr_head__destroy(auxil, entry->hold_h); - pcc_lr_answer__destroy(auxil, entry->hold_a); - pcc_lr_memo_map__term(auxil, &entry->memos); - PCC_FREE(auxil, entry); -} - -static void pcc_lr_table__init(pcc_auxil_t auxil, pcc_lr_table_t *table) { - table->ofs = 0; - table->len = 0; - table->max = 0; - table->buf = NULL; -} - -static void pcc_lr_table__resize(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t len) { - size_t i; - for (i = len; i < table->len; i++) pcc_lr_table_entry__destroy(auxil, table->buf[i]); - if (table->max < len) { - size_t m = table->max; - if (m == 0) m = PCC_ARRAYSIZE; - while (m < len && m != 0) m <<= 1; - if (m == 0) m = len; - table->buf = (pcc_lr_table_entry_t **)PCC_REALLOC(auxil, table->buf, sizeof(pcc_lr_table_entry_t *) * m); - table->max = m; - } - for (i = table->len; i < len; i++) table->buf[i] = NULL; - table->len = len; -} - -static void pcc_lr_table__set_head(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t index, pcc_lr_head_t *head) { - index += table->ofs; - if (index >= table->len) pcc_lr_table__resize(auxil, table, index + 1); - if (table->buf[index] == NULL) table->buf[index] = pcc_lr_table_entry__create(auxil); - table->buf[index]->head = head; -} - -static void pcc_lr_table__hold_head(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t index, pcc_lr_head_t *head) { - index += table->ofs; - if (index >= table->len) pcc_lr_table__resize(auxil, table, index + 1); - if (table->buf[index] == NULL) table->buf[index] = pcc_lr_table_entry__create(auxil); - head->hold = table->buf[index]->hold_h; - table->buf[index]->hold_h = head; -} - -static void pcc_lr_table__set_answer(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t index, pcc_rule_t rule, pcc_lr_answer_t *answer) { - index += table->ofs; - if (index >= table->len) pcc_lr_table__resize(auxil, table, index + 1); - if (table->buf[index] == NULL) table->buf[index] = pcc_lr_table_entry__create(auxil); - pcc_lr_memo_map__put(auxil, &table->buf[index]->memos, rule, answer); -} - -static void pcc_lr_table__hold_answer(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t index, pcc_lr_answer_t *answer) { - index += table->ofs; - if (index >= table->len) pcc_lr_table__resize(auxil, table, index + 1); - if (table->buf[index] == NULL) table->buf[index] = pcc_lr_table_entry__create(auxil); - answer->hold = table->buf[index]->hold_a; - table->buf[index]->hold_a = answer; -} - -static pcc_lr_head_t *pcc_lr_table__get_head(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t index) { - index += table->ofs; - if (index >= table->len || table->buf[index] == NULL) return NULL; - return table->buf[index]->head; -} - -static pcc_lr_answer_t *pcc_lr_table__get_answer(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t index, pcc_rule_t rule) { - index += table->ofs; - if (index >= table->len || table->buf[index] == NULL) return NULL; - return pcc_lr_memo_map__get(auxil, &table->buf[index]->memos, rule); -} - -static void pcc_lr_table__shift(pcc_auxil_t auxil, pcc_lr_table_t *table, size_t count) { - size_t i; - if (count > table->len - table->ofs) count = table->len - table->ofs; - for (i = 0; i < count; i++) pcc_lr_table_entry__destroy(auxil, table->buf[table->ofs++]); - if (table->ofs > (table->max >> 1)) { - memmove(table->buf, table->buf + table->ofs, sizeof(pcc_lr_table_entry_t *) * (table->len - table->ofs)); - table->len -= table->ofs; - table->ofs = 0; - } -} - -static void pcc_lr_table__term(pcc_auxil_t auxil, pcc_lr_table_t *table) { - while (table->len > table->ofs) { - table->len--; - pcc_lr_table_entry__destroy(auxil, table->buf[table->len]); - } - PCC_FREE(auxil, table->buf); -} - -static pcc_lr_entry_t *pcc_lr_entry__create(pcc_auxil_t auxil, pcc_rule_t rule) { - pcc_lr_entry_t *const lr = (pcc_lr_entry_t *)PCC_MALLOC(auxil, sizeof(pcc_lr_entry_t)); - lr->rule = rule; - lr->seed = NULL; - lr->head = NULL; - return lr; -} - -static void pcc_lr_entry__destroy(pcc_auxil_t auxil, pcc_lr_entry_t *lr) { - PCC_FREE(auxil, lr); -} - -static void pcc_lr_stack__init(pcc_auxil_t auxil, pcc_lr_stack_t *stack) { - stack->len = 0; - stack->max = 0; - stack->buf = NULL; -} - -static void pcc_lr_stack__push(pcc_auxil_t auxil, pcc_lr_stack_t *stack, pcc_lr_entry_t *lr) { - if (stack->max <= stack->len) { - const size_t n = stack->len + 1; - size_t m = stack->max; - if (m == 0) m = PCC_ARRAYSIZE; - while (m < n && m != 0) m <<= 1; - if (m == 0) m = n; - stack->buf = (pcc_lr_entry_t **)PCC_REALLOC(auxil, stack->buf, sizeof(pcc_lr_entry_t *) * m); - stack->max = m; - } - stack->buf[stack->len++] = lr; -} - -static pcc_lr_entry_t *pcc_lr_stack__pop(pcc_auxil_t auxil, pcc_lr_stack_t *stack) { - return stack->buf[--stack->len]; -} - -static void pcc_lr_stack__term(pcc_auxil_t auxil, pcc_lr_stack_t *stack) { - PCC_FREE(auxil, stack->buf); -} - -static pelm_context_t *pcc_context__create(pcc_auxil_t auxil) { - pelm_context_t *const ctx = (pelm_context_t *)PCC_MALLOC(auxil, sizeof(pelm_context_t)); - ctx->pos = 0; - ctx->cur = 0; - ctx->level = 0; - pcc_char_array__init(auxil, &ctx->buffer); - pcc_lr_table__init(auxil, &ctx->lrtable); - pcc_lr_stack__init(auxil, &ctx->lrstack); - pcc_thunk_array__init(auxil, &ctx->thunks); - ctx->auxil = auxil; - return ctx; -} - -static void pcc_context__destroy(pelm_context_t *ctx) { - if (ctx == NULL) return; - pcc_thunk_array__term(ctx->auxil, &ctx->thunks); - pcc_lr_stack__term(ctx->auxil, &ctx->lrstack); - pcc_lr_table__term(ctx->auxil, &ctx->lrtable); - pcc_char_array__term(ctx->auxil, &ctx->buffer); - PCC_FREE(ctx->auxil, ctx); -} - -static size_t pcc_refill_buffer(pelm_context_t *ctx, size_t num) { - if (ctx->buffer.len >= ctx->cur + num) return ctx->buffer.len - ctx->cur; - while (ctx->buffer.len < ctx->cur + num) { - const int c = PCC_GETCHAR(ctx->auxil); - if (c < 0) break; - pcc_char_array__add(ctx->auxil, &ctx->buffer, (char)c); - } - return ctx->buffer.len - ctx->cur; -} - -MARK_USED_FUNC -static void pcc_commit_buffer(pelm_context_t *ctx) { - memmove(ctx->buffer.buf, ctx->buffer.buf + ctx->cur, ctx->buffer.len - ctx->cur); - ctx->buffer.len -= ctx->cur; - ctx->pos += ctx->cur; - pcc_lr_table__shift(ctx->auxil, &ctx->lrtable, ctx->cur); - ctx->cur = 0; -} - -MARK_USED_FUNC -static const char *pcc_get_capture_string(pelm_context_t *ctx, const pcc_capture_t *capt) { - if (capt->string == NULL) - ((pcc_capture_t *)capt)->string = - pcc_strndup_e(ctx->auxil, ctx->buffer.buf + capt->range.start, capt->range.end - capt->range.start); - return capt->string; -} - -static size_t pcc_get_char_as_utf32(pelm_context_t *ctx, int *out) { /* with checking UTF-8 validity */ - int c, u; - size_t n; - if (pcc_refill_buffer(ctx, 1) < 1) return 0; - c = (int)(unsigned char)ctx->buffer.buf[ctx->cur]; - n = (c < 0x80) ? 1 : - ((c & 0xe0) == 0xc0) ? 2 : - ((c & 0xf0) == 0xe0) ? 3 : - ((c & 0xf8) == 0xf0) ? 4 : 0; - if (n < 1) return 0; - if (pcc_refill_buffer(ctx, n) < n) return 0; - switch (n) { - case 1: - u = c; - break; - case 2: - u = c & 0x1f; - c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 1]; - if ((c & 0xc0) != 0x80) return 0; - u <<= 6; u |= c & 0x3f; - if (u < 0x80) return 0; - break; - case 3: - u = c & 0x0f; - c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 1]; - if ((c & 0xc0) != 0x80) return 0; - u <<= 6; u |= c & 0x3f; - c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 2]; - if ((c & 0xc0) != 0x80) return 0; - u <<= 6; u |= c & 0x3f; - if (u < 0x800) return 0; - break; - case 4: - u = c & 0x07; - c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 1]; - if ((c & 0xc0) != 0x80) return 0; - u <<= 6; u |= c & 0x3f; - c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 2]; - if ((c & 0xc0) != 0x80) return 0; - u <<= 6; u |= c & 0x3f; - c = (int)(unsigned char)ctx->buffer.buf[ctx->cur + 3]; - if ((c & 0xc0) != 0x80) return 0; - u <<= 6; u |= c & 0x3f; - if (u < 0x10000 || u > 0x10ffff) return 0; - break; - default: - return 0; - } - if (out) *out = u; - return n; -} - -MARK_USED_FUNC -static pcc_bool_t pcc_apply_rule(pelm_context_t *ctx, pcc_rule_t rule, pcc_thunk_array_t *thunks, pcc_value_t *value) { - static pcc_value_t null; - pcc_thunk_chunk_t *c = NULL; - const size_t p = ctx->pos + ctx->cur; - pcc_bool_t b = PCC_TRUE; - pcc_lr_answer_t *a = pcc_lr_table__get_answer(ctx->auxil, &ctx->lrtable, p, rule); - pcc_lr_head_t *h = pcc_lr_table__get_head(ctx->auxil, &ctx->lrtable, p); - if (h != NULL) { - if (a == NULL && rule != h->rule && pcc_rule_set__index(ctx->auxil, &h->invol, rule) == PCC_VOID_VALUE) { - b = PCC_FALSE; - c = NULL; - } - else if (pcc_rule_set__remove(ctx->auxil, &h->eval, rule)) { - b = PCC_FALSE; - c = rule(ctx); - a = pcc_lr_answer__create(ctx->auxil, PCC_LR_ANSWER_CHUNK, ctx->pos + ctx->cur); - a->data.chunk = c; - pcc_lr_table__hold_answer(ctx->auxil, &ctx->lrtable, p, a); - } - } - if (b) { - if (a != NULL) { - ctx->cur = a->pos - ctx->pos; - switch (a->type) { - case PCC_LR_ANSWER_LR: - if (a->data.lr->head == NULL) { - a->data.lr->head = pcc_lr_head__create(ctx->auxil, rule); - pcc_lr_table__hold_head(ctx->auxil, &ctx->lrtable, p, a->data.lr->head); - } - { - size_t i = ctx->lrstack.len; - while (i > 0) { - i--; - if (ctx->lrstack.buf[i]->head == a->data.lr->head) break; - ctx->lrstack.buf[i]->head = a->data.lr->head; - pcc_rule_set__add(ctx->auxil, &a->data.lr->head->invol, ctx->lrstack.buf[i]->rule); - } - } - c = a->data.lr->seed; - break; - case PCC_LR_ANSWER_CHUNK: - c = a->data.chunk; - break; - default: /* unknown */ - break; - } - } - else { - pcc_lr_entry_t *const e = pcc_lr_entry__create(ctx->auxil, rule); - pcc_lr_stack__push(ctx->auxil, &ctx->lrstack, e); - a = pcc_lr_answer__create(ctx->auxil, PCC_LR_ANSWER_LR, p); - a->data.lr = e; - pcc_lr_table__set_answer(ctx->auxil, &ctx->lrtable, p, rule, a); - c = rule(ctx); - pcc_lr_stack__pop(ctx->auxil, &ctx->lrstack); - a->pos = ctx->pos + ctx->cur; - if (e->head == NULL) { - pcc_lr_answer__set_chunk(ctx->auxil, a, c); - } - else { - e->seed = c; - h = a->data.lr->head; - if (h->rule != rule) { - c = a->data.lr->seed; - a = pcc_lr_answer__create(ctx->auxil, PCC_LR_ANSWER_CHUNK, ctx->pos + ctx->cur); - a->data.chunk = c; - pcc_lr_table__hold_answer(ctx->auxil, &ctx->lrtable, p, a); - } - else { - pcc_lr_answer__set_chunk(ctx->auxil, a, a->data.lr->seed); - if (a->data.chunk == NULL) { - c = NULL; - } - else { - pcc_lr_table__set_head(ctx->auxil, &ctx->lrtable, p, h); - for (;;) { - ctx->cur = p - ctx->pos; - pcc_rule_set__copy(ctx->auxil, &h->eval, &h->invol); - c = rule(ctx); - if (c == NULL || ctx->pos + ctx->cur <= a->pos) break; - pcc_lr_answer__set_chunk(ctx->auxil, a, c); - a->pos = ctx->pos + ctx->cur; - } - pcc_thunk_chunk__destroy(ctx->auxil, c); - pcc_lr_table__set_head(ctx->auxil, &ctx->lrtable, p, NULL); - ctx->cur = a->pos - ctx->pos; - c = a->data.chunk; - } - } - } - } - } - if (c == NULL) return PCC_FALSE; - if (value == NULL) value = &null; - memset(value, 0, sizeof(pcc_value_t)); /* in case */ - pcc_thunk_array__add(ctx->auxil, thunks, pcc_thunk__create_node(ctx->auxil, &c->thunks, value)); - return PCC_TRUE; -} - -MARK_USED_FUNC -static void pcc_do_action(pelm_context_t *ctx, const pcc_thunk_array_t *thunks, pcc_value_t *value) { - size_t i; - for (i = 0; i < thunks->len; i++) { - pcc_thunk_t *const thunk = thunks->buf[i]; - switch (thunk->type) { - case PCC_THUNK_LEAF: - thunk->data.leaf.action(ctx, thunk, value); - break; - case PCC_THUNK_NODE: - pcc_do_action(ctx, thunk->data.node.thunks, thunk->data.node.value); - break; - default: /* unknown */ - break; - } - } -} - -static void pcc_action_file_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { -#define auxil (__pcc_ctx->auxil) -#define __ (*__pcc_out) -#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) -#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) -#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) - ELM_INIT_MODULE_SCOPE; -#undef _0e -#undef _0s -#undef _0 -#undef __ -#undef auxil -} - -static void pcc_action_moduleDeclaration_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { -#define auxil (__pcc_ctx->auxil) -#define __ (*__pcc_out) -#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) -#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) -#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) -#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) -#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) -#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) - elm_module_scope_index = makeElmTagSettingScope(auxil, _1, _1s, K_MODULE, ROLE_DEFINITION_INDEX); -#undef _1e -#undef _1s -#undef _1 -#undef _0e -#undef _0s -#undef _0 -#undef __ -#undef auxil -} - -static void pcc_action_typeAlias_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { -#define auxil (__pcc_ctx->auxil) -#define __ (*__pcc_out) -#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) -#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) -#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) -#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) -#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) -#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) - makeElmTag(auxil, _1, _1s, K_ALIAS, ROLE_DEFINITION_INDEX); -#undef _1e -#undef _1s -#undef _1 -#undef _0e -#undef _0s -#undef _0 -#undef __ -#undef auxil -} - -static void pcc_action_customType_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { -#define auxil (__pcc_ctx->auxil) -#define __ (*__pcc_out) -#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) -#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) -#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) -#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) -#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) -#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) - makeElmTagSettingScope(auxil, _1, _1s, K_TYPE, ROLE_DEFINITION_INDEX); -#undef _1e -#undef _1s -#undef _1 -#undef _0e -#undef _0s -#undef _0 -#undef __ -#undef auxil -} - -static void pcc_action_customType_1(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { -#define auxil (__pcc_ctx->auxil) -#define __ (*__pcc_out) -#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) -#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) -#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) -#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) -#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) -#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) - POP_KIND(auxil, true); -#undef _1e -#undef _1s -#undef _1 -#undef _0e -#undef _0s -#undef _0 -#undef __ -#undef auxil -} - -static void pcc_action_constructorList_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { -#define auxil (__pcc_ctx->auxil) -#define __ (*__pcc_out) -#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) -#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) -#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) -#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) -#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) -#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) -#define _2 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[1]) -#define _2s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.start)) -#define _2e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.end)) - int r = makeElmTag(auxil, _1, _1s, K_CONSTRUCTOR, ROLE_DEFINITION_INDEX); - addElmSignature(r, _2); -#undef _2e -#undef _2s -#undef _2 -#undef _1e -#undef _1s -#undef _1 -#undef _0e -#undef _0s -#undef _0 -#undef __ -#undef auxil -} - -static void pcc_action_portDeclaration_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { -#define auxil (__pcc_ctx->auxil) -#define __ (*__pcc_out) -#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) -#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) -#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) -#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) -#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) -#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) -#define _2 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[1]) -#define _2s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.start)) -#define _2e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.end)) - int r = makeElmTag(auxil, _1, _1s, K_PORT, ROLE_DEFINITION_INDEX); - addElmSignature(r, _2); -#undef _2e -#undef _2s -#undef _2 -#undef _1e -#undef _1s -#undef _1 -#undef _0e -#undef _0s -#undef _0 -#undef __ -#undef auxil -} - -static void pcc_action_importStatement_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { -#define auxil (__pcc_ctx->auxil) -#define __ (*__pcc_out) -#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) -#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) -#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) -#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) -#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) -#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) -#define _2 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[1]) -#define _2s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.start)) -#define _2e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.end)) - // Make the namespace tag first, as it's in the file module's scope - if (_2s > 0) { - int r = makeElmTag(auxil, _2, _2s, K_NAMESPACE, ROLE_DEFINITION_INDEX); - attachParserFieldToCorkEntry (r, ElmFields[F_MODULENAME].ftype, _1); - } - - // Now make the tag for the imported module, as it lives outside - // the scope of the file module - ELM_SAVE_MODULE_SCOPE; - makeElmTagSettingScope(auxil, _1, _1s, K_MODULE, ELM_ROLE_IMPORTED); -#undef _2e -#undef _2s -#undef _2 -#undef _1e -#undef _1s -#undef _1 -#undef _0e -#undef _0s -#undef _0 -#undef __ -#undef auxil -} - -static void pcc_action_importStatement_1(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { -#define auxil (__pcc_ctx->auxil) -#define __ (*__pcc_out) -#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) -#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) -#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) -#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) -#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) -#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) -#define _2 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[1]) -#define _2s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.start)) -#define _2e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.end)) - ELM_RESTORE_MODULE_SCOPE; -#undef _2e -#undef _2s -#undef _2 -#undef _1e -#undef _1s -#undef _1 -#undef _0e -#undef _0s -#undef _0 -#undef __ -#undef auxil -} - -static void pcc_action_importedFunction_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { -#define auxil (__pcc_ctx->auxil) -#define __ (*__pcc_out) -#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) -#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) -#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) -#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) -#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) -#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) - makeElmTag(auxil, _1, _1s, K_FUNCTION, ELM_ROLE_IMPORTED); -#undef _1e -#undef _1s -#undef _1 -#undef _0e -#undef _0s -#undef _0 -#undef __ -#undef auxil -} - -static void pcc_action_importedType_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { -#define auxil (__pcc_ctx->auxil) -#define __ (*__pcc_out) -#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) -#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) -#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) -#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) -#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) -#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) - makeElmTagSettingScope(auxil, _1, _1s, K_TYPE, ELM_ROLE_IMPORTED); -#undef _1e -#undef _1s -#undef _1 -#undef _0e -#undef _0s -#undef _0 -#undef __ -#undef auxil -} - -static void pcc_action_importedType_1(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { -#define auxil (__pcc_ctx->auxil) -#define __ (*__pcc_out) -#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) -#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) -#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) -#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) -#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) -#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) - // We're done with the type and its constructors, so we can pop it - POP_SCOPE(auxil); -#undef _1e -#undef _1s -#undef _1 -#undef _0e -#undef _0s -#undef _0 -#undef __ -#undef auxil -} - -static void pcc_action_importedTypeConstructor_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { -#define auxil (__pcc_ctx->auxil) -#define __ (*__pcc_out) -#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) -#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) -#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) -#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) -#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) -#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) - makeElmTag(auxil, _1, _1s, K_CONSTRUCTOR, ELM_ROLE_IMPORTED); -#undef _1e -#undef _1s -#undef _1 -#undef _0e -#undef _0s -#undef _0 -#undef __ -#undef auxil -} - -static void pcc_action_functionWithTypeAnnotation_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { -#define auxil (__pcc_ctx->auxil) -#define __ (*__pcc_out) -#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) -#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) -#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) -#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) -#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) -#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) -#define _2 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[1]) -#define _2s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.start)) -#define _2e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.end)) -#define _3 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[2]) -#define _3s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[2]->range.start)) -#define _3e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[2]->range.end)) - int r = makeElmTagSettingScope(auxil, _3, _3s, K_FUNCTION, ROLE_DEFINITION_INDEX); - addElmSignature(r, _2); -#undef _3e -#undef _3s -#undef _3 -#undef _2e -#undef _2s -#undef _2 -#undef _1e -#undef _1s -#undef _1 -#undef _0e -#undef _0s -#undef _0 -#undef __ -#undef auxil -} - -static void pcc_action_functionWithTypeAnnotation_1(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { -#define auxil (__pcc_ctx->auxil) -#define __ (*__pcc_out) -#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) -#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) -#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) -#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) -#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) -#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) -#define _2 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[1]) -#define _2s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.start)) -#define _2e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[1]->range.end)) -#define _3 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[2]) -#define _3s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[2]->range.start)) -#define _3e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[2]->range.end)) - POP_SCOPE(auxil); -#undef _3e -#undef _3s -#undef _3 -#undef _2e -#undef _2s -#undef _2 -#undef _1e -#undef _1s -#undef _1 -#undef _0e -#undef _0s -#undef _0 -#undef __ -#undef auxil -} - -static void pcc_action_functionDefinition_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { -#define auxil (__pcc_ctx->auxil) -#define __ (*__pcc_out) -#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) -#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) -#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) -#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) -#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) -#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) - makeElmTagSettingScope(auxil, _1, _1s, K_FUNCTION, ROLE_DEFINITION_INDEX); -#undef _1e -#undef _1s -#undef _1 -#undef _0e -#undef _0s -#undef _0 -#undef __ -#undef auxil -} - -static void pcc_action_functionDefinition_1(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { -#define auxil (__pcc_ctx->auxil) -#define __ (*__pcc_out) -#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) -#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) -#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) -#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) -#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) -#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) - POP_SCOPE(auxil); -#undef _1e -#undef _1s -#undef _1 -#undef _0e -#undef _0s -#undef _0 -#undef __ -#undef auxil -} - -static void pcc_action_letInFunctionDefinition_0(pelm_context_t *__pcc_ctx, pcc_thunk_t *__pcc_in, pcc_value_t *__pcc_out) { -#define auxil (__pcc_ctx->auxil) -#define __ (*__pcc_out) -#define _0 pcc_get_capture_string(__pcc_ctx, &__pcc_in->data.leaf.capt0) -#define _0s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.start)) -#define _0e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capt0.range.end)) -#define _1 pcc_get_capture_string(__pcc_ctx, __pcc_in->data.leaf.capts.buf[0]) -#define _1s ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.start)) -#define _1e ((const size_t)(__pcc_ctx->pos + __pcc_in->data.leaf.capts.buf[0]->range.end)) - makeElmTag(auxil, _1, _1s, K_FUNCTION, ROLE_DEFINITION_INDEX); -#undef _1e -#undef _1s -#undef _1 -#undef _0e -#undef _0s -#undef _0 -#undef __ -#undef auxil -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_file(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_mainTopLevelStatements(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_topLevelStatement(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_moduleDeclaration(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedList(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedItem(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedFieldOrType(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedFunction(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedItemIgnored(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedTypeConstructorList(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_typeAlias(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_customType(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_typeParameterList(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_constructorList(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_constructorTypes(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_singleTypeSpec(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_recordTypeSpec(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_recordRestrictionPrefix(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_fieldSpec(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_tupleTypeSpec(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_parameterisedTypeSpec(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_functionTypeSpec(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_portDeclaration(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_importStatement(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_importedList(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_importedItem(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_importedFunction(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_importedType(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_importedItemIgnored(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_importedTypeConstructorList(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_importedTypeConstructor(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_functionWithTypeAnnotation(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_typeAnnotation(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_functionDefinition(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_functionParameterList(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_functionParameter(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_plainFunctionParameter(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_tupleFunctionParameter(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_recordFunctionParameter(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_constructorFunctionParameter(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_asClause(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_expression(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_simpleExpression(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_tupleExpression(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_listExpression(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_recordExpression(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_recordExpressionAssignment(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_anonymousFunction(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_functionCall(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_letInBlock(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_letInLine(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_letInFunctionDefinition(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_letInFunctionBody(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_caseStatement(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_caseClauseList(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_caseClause(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_roughCasePatternChar(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_ifThenElseStatement(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_binaryOperator(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_ignoreRestOfStatement(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_multilineString(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_naiveIdentifier(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_upperStartIdentifier(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_lowerStartIdentifier(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_alphanumeric(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_nonKeywordIdentifier(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_keyword(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_dottedIdentifier(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_decimal(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_exponentialDecimal(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_simpleDecimal(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_simpleInteger(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_digits(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_hexNumber(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_oneLineString(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_characterLiteral(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_inStringChar(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_inStringPlainChar(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_inStringEscapedChar(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_inStringUnicodeChar(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_WS(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_NL(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_Non_NL(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_Non_WS_or_NL(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_EOF(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_delimitedComment(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_lineComment(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule__1_short(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule__1_(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule__0_(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_TLSS_short(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_TLSS(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule_EOS(pelm_context_t *ctx); -static pcc_thunk_chunk_t *pcc_evaluate_rule__NL_IND_(pelm_context_t *ctx); - -static pcc_thunk_chunk_t *pcc_evaluate_rule_file(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "file", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_file_0, 0, 0); - thunk->data.leaf.capt0.range.start = chunk->pos; - thunk->data.leaf.capt0.range.end = ctx->cur; - pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); - } - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_TLSS, &chunk->thunks, NULL)) goto L0001; - goto L0002; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0002:; - } - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_moduleDeclaration, &chunk->thunks, NULL)) goto L0003; - goto L0004; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0004:; - } - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_TLSS, &chunk->thunks, NULL)) goto L0005; - goto L0006; - L0005:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0006:; - } - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_mainTopLevelStatements, &chunk->thunks, NULL)) goto L0007; - goto L0008; - L0007:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0008:; - } - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_TLSS, &chunk->thunks, NULL)) goto L0009; - goto L0010; - L0009:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0010:; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_EOF, &chunk->thunks, NULL)) goto L0000; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "file", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "file", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_mainTopLevelStatements(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "mainTopLevelStatements", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_topLevelStatement, &chunk->thunks, NULL)) goto L0000; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_TLSS, &chunk->thunks, NULL)) goto L0001; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_topLevelStatement, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "mainTopLevelStatements", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "mainTopLevelStatements", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_topLevelStatement(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "topLevelStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importStatement, &chunk->thunks, NULL)) goto L0002; - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_typeAlias, &chunk->thunks, NULL)) goto L0003; - goto L0001; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_customType, &chunk->thunks, NULL)) goto L0004; - goto L0001; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_portDeclaration, &chunk->thunks, NULL)) goto L0005; - goto L0001; - L0005:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionWithTypeAnnotation, &chunk->thunks, NULL)) goto L0006; - goto L0001; - L0006:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionDefinition, &chunk->thunks, NULL)) goto L0007; - goto L0001; - L0007:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_ignoreRestOfStatement, &chunk->thunks, NULL)) goto L0008; - goto L0001; - L0008:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0001:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "topLevelStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "topLevelStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_moduleDeclaration(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "moduleDeclaration", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 4) < 4 || - (ctx->buffer.buf + ctx->cur)[0] != 'p' || - (ctx->buffer.buf + ctx->cur)[1] != 'o' || - (ctx->buffer.buf + ctx->cur)[2] != 'r' || - (ctx->buffer.buf + ctx->cur)[3] != 't' - ) goto L0001; - ctx->cur += 4; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0001; - goto L0002; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0002:; - } - if ( - pcc_refill_buffer(ctx, 6) < 6 || - (ctx->buffer.buf + ctx->cur)[0] != 'm' || - (ctx->buffer.buf + ctx->cur)[1] != 'o' || - (ctx->buffer.buf + ctx->cur)[2] != 'd' || - (ctx->buffer.buf + ctx->cur)[3] != 'u' || - (ctx->buffer.buf + ctx->cur)[4] != 'l' || - (ctx->buffer.buf + ctx->cur)[5] != 'e' - ) goto L0000; - ctx->cur += 6; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; - { - const size_t p = ctx->cur; - size_t q; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_dottedIdentifier, &chunk->thunks, NULL)) goto L0000; - q = ctx->cur; - chunk->capts.buf[0].range.start = p; - chunk->capts.buf[0].range.end = q; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 8) < 8 || - (ctx->buffer.buf + ctx->cur)[0] != 'e' || - (ctx->buffer.buf + ctx->cur)[1] != 'x' || - (ctx->buffer.buf + ctx->cur)[2] != 'p' || - (ctx->buffer.buf + ctx->cur)[3] != 'o' || - (ctx->buffer.buf + ctx->cur)[4] != 's' || - (ctx->buffer.buf + ctx->cur)[5] != 'i' || - (ctx->buffer.buf + ctx->cur)[6] != 'n' || - (ctx->buffer.buf + ctx->cur)[7] != 'g' - ) goto L0000; - ctx->cur += 8; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '(' - ) goto L0000; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_exposedList, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ')' - ) goto L0000; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_EOS, &chunk->thunks, NULL)) goto L0000; - { - pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_moduleDeclaration_0, 0, 1); - thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); - thunk->data.leaf.capt0.range.start = chunk->pos; - thunk->data.leaf.capt0.range.end = ctx->cur; - pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "moduleDeclaration", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "moduleDeclaration", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedList(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "exposedList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_exposedItem, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ',' - ) goto L0001; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_exposedList, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "exposedList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "exposedList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedItem(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "exposedItem", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_exposedFieldOrType, &chunk->thunks, NULL)) goto L0002; - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_exposedFunction, &chunk->thunks, NULL)) goto L0003; - goto L0001; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_exposedItemIgnored, &chunk->thunks, NULL)) goto L0004; - goto L0001; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0001:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "exposedItem", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "exposedItem", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedFieldOrType(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "exposedFieldOrType", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1); - { - const size_t p = ctx->cur; - size_t q; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_upperStartIdentifier, &chunk->thunks, NULL)) goto L0000; - q = ctx->cur; - chunk->capts.buf[0].range.start = p; - chunk->capts.buf[0].range.end = q; - } - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '(' - ) goto L0001; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_exposedTypeConstructorList, &chunk->thunks, NULL)) goto L0001; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ')' - ) goto L0001; - ctx->cur++; - goto L0002; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0002:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "exposedFieldOrType", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "exposedFieldOrType", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedFunction(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "exposedFunction", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "exposedFunction", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "exposedFunction", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedItemIgnored(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "exposedItemIgnored", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p0 = ctx->cur; - const size_t n0 = chunk->thunks.len; - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '.' - ) goto L0001; - ctx->cur++; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - if (i < 1) { - ctx->cur = p0; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); - goto L0000; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "exposedItemIgnored", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "exposedItemIgnored", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_exposedTypeConstructorList(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "exposedTypeConstructorList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_upperStartIdentifier, &chunk->thunks, NULL)) goto L0002; - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_exposedItemIgnored, &chunk->thunks, NULL)) goto L0003; - goto L0001; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0001:; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ',' - ) goto L0004; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0004; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_exposedTypeConstructorList, &chunk->thunks, NULL)) goto L0004; - if (ctx->cur == p) break; - continue; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "exposedTypeConstructorList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "exposedTypeConstructorList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_typeAlias(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "typeAlias", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1); - if ( - pcc_refill_buffer(ctx, 4) < 4 || - (ctx->buffer.buf + ctx->cur)[0] != 't' || - (ctx->buffer.buf + ctx->cur)[1] != 'y' || - (ctx->buffer.buf + ctx->cur)[2] != 'p' || - (ctx->buffer.buf + ctx->cur)[3] != 'e' - ) goto L0000; - ctx->cur += 4; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 5) < 5 || - (ctx->buffer.buf + ctx->cur)[0] != 'a' || - (ctx->buffer.buf + ctx->cur)[1] != 'l' || - (ctx->buffer.buf + ctx->cur)[2] != 'i' || - (ctx->buffer.buf + ctx->cur)[3] != 'a' || - (ctx->buffer.buf + ctx->cur)[4] != 's' - ) goto L0000; - ctx->cur += 5; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; - { - const size_t p = ctx->cur; - size_t q; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_upperStartIdentifier, &chunk->thunks, NULL)) goto L0000; - q = ctx->cur; - chunk->capts.buf[0].range.start = p; - chunk->capts.buf[0].range.end = q; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '=' - ) goto L0000; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_ignoreRestOfStatement, &chunk->thunks, NULL)) goto L0000; - { - pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_typeAlias_0, 0, 1); - thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); - thunk->data.leaf.capt0.range.start = chunk->pos; - thunk->data.leaf.capt0.range.end = ctx->cur; - pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "typeAlias", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "typeAlias", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_customType(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "customType", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1); - if ( - pcc_refill_buffer(ctx, 4) < 4 || - (ctx->buffer.buf + ctx->cur)[0] != 't' || - (ctx->buffer.buf + ctx->cur)[1] != 'y' || - (ctx->buffer.buf + ctx->cur)[2] != 'p' || - (ctx->buffer.buf + ctx->cur)[3] != 'e' - ) goto L0000; - ctx->cur += 4; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; - { - const size_t p = ctx->cur; - size_t q; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_upperStartIdentifier, &chunk->thunks, NULL)) goto L0000; - q = ctx->cur; - chunk->capts.buf[0].range.start = p; - chunk->capts.buf[0].range.end = q; - } - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_typeParameterList, &chunk->thunks, NULL)) goto L0001; - goto L0002; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0002:; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '=' - ) goto L0000; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - { - pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_customType_0, 0, 1); - thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); - thunk->data.leaf.capt0.range.start = chunk->pos; - thunk->data.leaf.capt0.range.end = ctx->cur; - pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_constructorList, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_EOS, &chunk->thunks, NULL)) goto L0000; - { - pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_customType_1, 0, 1); - thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); - thunk->data.leaf.capt0.range.start = chunk->pos; - thunk->data.leaf.capt0.range.end = ctx->cur; - pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "customType", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "customType", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_typeParameterList(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "typeParameterList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0001; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "typeParameterList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "typeParameterList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_constructorList(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "constructorList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 2); - { - const size_t p = ctx->cur; - size_t q; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_upperStartIdentifier, &chunk->thunks, NULL)) goto L0000; - q = ctx->cur; - chunk->capts.buf[0].range.start = p; - chunk->capts.buf[0].range.end = q; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - { - const size_t p = ctx->cur; - size_t q; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_constructorTypes, &chunk->thunks, NULL)) goto L0001; - q = ctx->cur; - chunk->capts.buf[1].range.start = p; - chunk->capts.buf[1].range.end = q; - } - goto L0002; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0002:; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '|' - ) goto L0003; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_constructorList, &chunk->thunks, NULL)) goto L0003; - goto L0004; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0004:; - } - { - pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_constructorList_0, 0, 2); - thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); - thunk->data.leaf.capts.buf[1] = &(chunk->capts.buf[1]); - thunk->data.leaf.capt0.range.start = chunk->pos; - thunk->data.leaf.capt0.range.end = ctx->cur; - pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "constructorList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "constructorList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_constructorTypes(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "constructorTypes", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_singleTypeSpec, &chunk->thunks, NULL)) goto L0000; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_constructorTypes, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "constructorTypes", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "constructorTypes", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_singleTypeSpec(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "singleTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_recordTypeSpec, &chunk->thunks, NULL)) goto L0002; - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_tupleTypeSpec, &chunk->thunks, NULL)) goto L0003; - goto L0001; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionTypeSpec, &chunk->thunks, NULL)) goto L0004; - goto L0001; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_parameterisedTypeSpec, &chunk->thunks, NULL)) goto L0005; - goto L0001; - L0005:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0001:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "singleTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "singleTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_recordTypeSpec(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "recordTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '{' - ) goto L0002; - ctx->cur++; - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_recordRestrictionPrefix, &chunk->thunks, NULL)) goto L0003; - goto L0004; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0004:; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_fieldSpec, &chunk->thunks, NULL)) goto L0002; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0005; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ',' - ) goto L0005; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0005; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_fieldSpec, &chunk->thunks, NULL)) goto L0005; - if (ctx->cur == p) break; - continue; - L0005:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '}' - ) goto L0002; - ctx->cur++; - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '{' - ) goto L0006; - ctx->cur++; - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0007; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_recordRestrictionPrefix, &chunk->thunks, NULL)) goto L0007; - goto L0008; - L0007:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0008:; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0006; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '}' - ) goto L0006; - ctx->cur++; - goto L0001; - L0006:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0001:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "recordTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "recordTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_recordRestrictionPrefix(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "recordRestrictionPrefix", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '|' - ) goto L0000; - ctx->cur++; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "recordRestrictionPrefix", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "recordRestrictionPrefix", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_fieldSpec(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "fieldSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ':' - ) goto L0000; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_singleTypeSpec, &chunk->thunks, NULL)) goto L0000; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "fieldSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "fieldSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_tupleTypeSpec(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "tupleTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '(' - ) goto L0002; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_singleTypeSpec, &chunk->thunks, NULL)) goto L0002; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ',' - ) goto L0003; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_singleTypeSpec, &chunk->thunks, NULL)) goto L0003; - if (ctx->cur == p) break; - continue; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ')' - ) goto L0002; - ctx->cur++; - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '(' - ) goto L0004; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0004; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ')' - ) goto L0004; - ctx->cur++; - goto L0001; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0001:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "tupleTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "tupleTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_parameterisedTypeSpec(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "parameterisedTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_dottedIdentifier, &chunk->thunks, NULL)) goto L0000; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0001; - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_singleTypeSpec, &chunk->thunks, NULL)) goto L0003; - goto L0002; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0004; - goto L0002; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0001; - L0002:; - } - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "parameterisedTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "parameterisedTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_functionTypeSpec(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "functionTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_singleTypeSpec, &chunk->thunks, NULL)) goto L0000; - { - const size_t p0 = ctx->cur; - const size_t n0 = chunk->thunks.len; - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '-' || - (ctx->buffer.buf + ctx->cur)[1] != '>' - ) goto L0001; - ctx->cur += 2; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_singleTypeSpec, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - if (i < 1) { - ctx->cur = p0; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); - goto L0000; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "functionTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "functionTypeSpec", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_portDeclaration(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "portDeclaration", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 2); - if ( - pcc_refill_buffer(ctx, 4) < 4 || - (ctx->buffer.buf + ctx->cur)[0] != 'p' || - (ctx->buffer.buf + ctx->cur)[1] != 'o' || - (ctx->buffer.buf + ctx->cur)[2] != 'r' || - (ctx->buffer.buf + ctx->cur)[3] != 't' - ) goto L0000; - ctx->cur += 4; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; - { - const size_t p = ctx->cur; - size_t q; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; - q = ctx->cur; - chunk->capts.buf[0].range.start = p; - chunk->capts.buf[0].range.end = q; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ':' - ) goto L0000; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - { - const size_t p = ctx->cur; - size_t q; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_typeAnnotation, &chunk->thunks, NULL)) goto L0000; - q = ctx->cur; - chunk->capts.buf[1].range.start = p; - chunk->capts.buf[1].range.end = q; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_EOS, &chunk->thunks, NULL)) goto L0000; - { - pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_portDeclaration_0, 0, 2); - thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); - thunk->data.leaf.capts.buf[1] = &(chunk->capts.buf[1]); - thunk->data.leaf.capt0.range.start = chunk->pos; - thunk->data.leaf.capt0.range.end = ctx->cur; - pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "portDeclaration", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "portDeclaration", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_importStatement(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "importStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 2); - if ( - pcc_refill_buffer(ctx, 6) < 6 || - (ctx->buffer.buf + ctx->cur)[0] != 'i' || - (ctx->buffer.buf + ctx->cur)[1] != 'm' || - (ctx->buffer.buf + ctx->cur)[2] != 'p' || - (ctx->buffer.buf + ctx->cur)[3] != 'o' || - (ctx->buffer.buf + ctx->cur)[4] != 'r' || - (ctx->buffer.buf + ctx->cur)[5] != 't' - ) goto L0000; - ctx->cur += 6; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; - { - const size_t p = ctx->cur; - size_t q; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_dottedIdentifier, &chunk->thunks, NULL)) goto L0000; - q = ctx->cur; - chunk->capts.buf[0].range.start = p; - chunk->capts.buf[0].range.end = q; - } - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0001; - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != 'a' || - (ctx->buffer.buf + ctx->cur)[1] != 's' - ) goto L0001; - ctx->cur += 2; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0001; - { - const size_t p = ctx->cur; - size_t q; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_upperStartIdentifier, &chunk->thunks, NULL)) goto L0001; - q = ctx->cur; - chunk->capts.buf[1].range.start = p; - chunk->capts.buf[1].range.end = q; - } - goto L0002; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0002:; - } - { - pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_importStatement_0, 0, 2); - thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); - thunk->data.leaf.capts.buf[1] = &(chunk->capts.buf[1]); - thunk->data.leaf.capt0.range.start = chunk->pos; - thunk->data.leaf.capt0.range.end = ctx->cur; - pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); - } - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0003; - if ( - pcc_refill_buffer(ctx, 8) < 8 || - (ctx->buffer.buf + ctx->cur)[0] != 'e' || - (ctx->buffer.buf + ctx->cur)[1] != 'x' || - (ctx->buffer.buf + ctx->cur)[2] != 'p' || - (ctx->buffer.buf + ctx->cur)[3] != 'o' || - (ctx->buffer.buf + ctx->cur)[4] != 's' || - (ctx->buffer.buf + ctx->cur)[5] != 'i' || - (ctx->buffer.buf + ctx->cur)[6] != 'n' || - (ctx->buffer.buf + ctx->cur)[7] != 'g' - ) goto L0003; - ctx->cur += 8; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '(' - ) goto L0003; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importedList, &chunk->thunks, NULL)) goto L0003; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ')' - ) goto L0003; - ctx->cur++; - goto L0004; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0004:; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_EOS, &chunk->thunks, NULL)) goto L0000; - { - pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_importStatement_1, 0, 2); - thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); - thunk->data.leaf.capts.buf[1] = &(chunk->capts.buf[1]); - thunk->data.leaf.capt0.range.start = chunk->pos; - thunk->data.leaf.capt0.range.end = ctx->cur; - pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "importStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "importStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_importedList(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "importedList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importedItem, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ',' - ) goto L0001; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importedList, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "importedList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "importedList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_importedItem(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "importedItem", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importedFunction, &chunk->thunks, NULL)) goto L0002; - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importedType, &chunk->thunks, NULL)) goto L0003; - goto L0001; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importedItemIgnored, &chunk->thunks, NULL)) goto L0004; - goto L0001; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0001:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "importedItem", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "importedItem", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_importedFunction(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "importedFunction", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1); - { - const size_t p = ctx->cur; - size_t q; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; - q = ctx->cur; - chunk->capts.buf[0].range.start = p; - chunk->capts.buf[0].range.end = q; - } - { - pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_importedFunction_0, 0, 1); - thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); - thunk->data.leaf.capt0.range.start = chunk->pos; - thunk->data.leaf.capt0.range.end = ctx->cur; - pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "importedFunction", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "importedFunction", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_importedType(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "importedType", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1); - { - const size_t p = ctx->cur; - size_t q; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_upperStartIdentifier, &chunk->thunks, NULL)) goto L0000; - q = ctx->cur; - chunk->capts.buf[0].range.start = p; - chunk->capts.buf[0].range.end = q; - } - { - pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_importedType_0, 0, 1); - thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); - thunk->data.leaf.capt0.range.start = chunk->pos; - thunk->data.leaf.capt0.range.end = ctx->cur; - pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); - } - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '(' - ) goto L0001; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importedTypeConstructorList, &chunk->thunks, NULL)) goto L0001; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ')' - ) goto L0001; - ctx->cur++; - goto L0002; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0002:; - } - { - pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_importedType_1, 0, 1); - thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); - thunk->data.leaf.capt0.range.start = chunk->pos; - thunk->data.leaf.capt0.range.end = ctx->cur; - pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "importedType", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "importedType", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_importedItemIgnored(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "importedItemIgnored", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p0 = ctx->cur; - const size_t n0 = chunk->thunks.len; - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '.' - ) goto L0001; - ctx->cur++; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - if (i < 1) { - ctx->cur = p0; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); - goto L0000; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "importedItemIgnored", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "importedItemIgnored", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_importedTypeConstructorList(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "importedTypeConstructorList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importedTypeConstructor, &chunk->thunks, NULL)) goto L0002; - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importedItemIgnored, &chunk->thunks, NULL)) goto L0003; - goto L0001; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0001:; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ',' - ) goto L0004; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0004; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_importedTypeConstructorList, &chunk->thunks, NULL)) goto L0004; - if (ctx->cur == p) break; - continue; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "importedTypeConstructorList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "importedTypeConstructorList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_importedTypeConstructor(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "importedTypeConstructor", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1); - { - const size_t p = ctx->cur; - size_t q; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_upperStartIdentifier, &chunk->thunks, NULL)) goto L0000; - q = ctx->cur; - chunk->capts.buf[0].range.start = p; - chunk->capts.buf[0].range.end = q; - } - { - pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_importedTypeConstructor_0, 0, 1); - thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); - thunk->data.leaf.capt0.range.start = chunk->pos; - thunk->data.leaf.capt0.range.end = ctx->cur; - pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "importedTypeConstructor", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "importedTypeConstructor", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_functionWithTypeAnnotation(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "functionWithTypeAnnotation", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 3); - { - const size_t p = ctx->cur; - size_t q; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; - q = ctx->cur; - chunk->capts.buf[0].range.start = p; - chunk->capts.buf[0].range.end = q; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ':' - ) goto L0000; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - { - const size_t p = ctx->cur; - size_t q; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_typeAnnotation, &chunk->thunks, NULL)) goto L0000; - q = ctx->cur; - chunk->capts.buf[1].range.start = p; - chunk->capts.buf[1].range.end = q; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_TLSS, &chunk->thunks, NULL)) goto L0000; - { - const size_t p = ctx->cur; - size_t q; - { - const size_t n = chunk->capts.buf[0].range.end - chunk->capts.buf[0].range.start; - if (pcc_refill_buffer(ctx, n) < n) goto L0000; - if (n > 0) { - const char *const p = ctx->buffer.buf + ctx->cur; - const char *const q = ctx->buffer.buf + chunk->capts.buf[0].range.start; - size_t i; - for (i = 0; i < n; i++) { - if (p[i] != q[i]) goto L0000; - } - ctx->cur += n; - } - } - q = ctx->cur; - chunk->capts.buf[2].range.start = p; - chunk->capts.buf[2].range.end = q; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; - { - pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_functionWithTypeAnnotation_0, 0, 3); - thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); - thunk->data.leaf.capts.buf[1] = &(chunk->capts.buf[1]); - thunk->data.leaf.capts.buf[2] = &(chunk->capts.buf[2]); - thunk->data.leaf.capt0.range.start = chunk->pos; - thunk->data.leaf.capt0.range.end = ctx->cur; - pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); - } - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionParameterList, &chunk->thunks, NULL)) goto L0001; - goto L0002; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0002:; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '=' - ) goto L0000; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_EOS, &chunk->thunks, NULL)) goto L0000; - { - pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_functionWithTypeAnnotation_1, 0, 3); - thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); - thunk->data.leaf.capts.buf[1] = &(chunk->capts.buf[1]); - thunk->data.leaf.capts.buf[2] = &(chunk->capts.buf[2]); - thunk->data.leaf.capt0.range.start = chunk->pos; - thunk->data.leaf.capt0.range.end = ctx->cur; - pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "functionWithTypeAnnotation", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "functionWithTypeAnnotation", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_typeAnnotation(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "typeAnnotation", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_singleTypeSpec, &chunk->thunks, NULL)) goto L0000; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '-' || - (ctx->buffer.buf + ctx->cur)[1] != '>' - ) goto L0001; - ctx->cur += 2; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_singleTypeSpec, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "typeAnnotation", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "typeAnnotation", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_functionDefinition(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "functionDefinition", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1); - { - const size_t p = ctx->cur; - size_t q; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_nonKeywordIdentifier, &chunk->thunks, NULL)) goto L0000; - q = ctx->cur; - chunk->capts.buf[0].range.start = p; - chunk->capts.buf[0].range.end = q; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - { - pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_functionDefinition_0, 0, 1); - thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); - thunk->data.leaf.capt0.range.start = chunk->pos; - thunk->data.leaf.capt0.range.end = ctx->cur; - pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); - } - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionParameterList, &chunk->thunks, NULL)) goto L0001; - goto L0002; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0002:; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '=' - ) goto L0000; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_EOS, &chunk->thunks, NULL)) goto L0000; - { - pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_functionDefinition_1, 0, 1); - thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); - thunk->data.leaf.capt0.range.start = chunk->pos; - thunk->data.leaf.capt0.range.end = ctx->cur; - pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "functionDefinition", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "functionDefinition", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_functionParameterList(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "functionParameterList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionParameter, &chunk->thunks, NULL)) goto L0000; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionParameter, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "functionParameterList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "functionParameterList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_functionParameter(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "functionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_plainFunctionParameter, &chunk->thunks, NULL)) goto L0002; - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_tupleFunctionParameter, &chunk->thunks, NULL)) goto L0003; - goto L0001; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_recordFunctionParameter, &chunk->thunks, NULL)) goto L0004; - goto L0001; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_constructorFunctionParameter, &chunk->thunks, NULL)) goto L0005; - goto L0001; - L0005:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0001:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "functionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "functionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_plainFunctionParameter(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "plainFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_asClause, &chunk->thunks, NULL)) goto L0001; - goto L0002; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0002:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "plainFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "plainFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_tupleFunctionParameter(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "tupleFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '(' - ) goto L0000; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionParameter, &chunk->thunks, NULL)) goto L0000; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ',' - ) goto L0001; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionParameter, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ')' - ) goto L0000; - ctx->cur++; - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_asClause, &chunk->thunks, NULL)) goto L0002; - goto L0003; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0003:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "tupleFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "tupleFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_recordFunctionParameter(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "recordFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '{' - ) goto L0000; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ',' - ) goto L0001; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '}' - ) goto L0000; - ctx->cur++; - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_asClause, &chunk->thunks, NULL)) goto L0002; - goto L0003; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0003:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "recordFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "recordFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_constructorFunctionParameter(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "constructorFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_upperStartIdentifier, &chunk->thunks, NULL)) goto L0000; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0001; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionParameter, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_asClause, &chunk->thunks, NULL)) goto L0002; - goto L0003; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0003:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "constructorFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "constructorFunctionParameter", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_asClause(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "asClause", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != 'a' || - (ctx->buffer.buf + ctx->cur)[1] != 's' - ) goto L0000; - ctx->cur += 2; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "asClause", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "asClause", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_expression(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "expression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_letInBlock, &chunk->thunks, NULL)) goto L0001; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__NL_IND_, &chunk->thunks, NULL)) goto L0001; - goto L0002; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0002:; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_simpleExpression, &chunk->thunks, NULL)) goto L0000; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_binaryOperator, &chunk->thunks, NULL)) goto L0003; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0003; - if (ctx->cur == p) break; - continue; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "expression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "expression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_simpleExpression(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "simpleExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_hexNumber, &chunk->thunks, NULL)) goto L0002; - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_decimal, &chunk->thunks, NULL)) goto L0003; - goto L0001; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_multilineString, &chunk->thunks, NULL)) goto L0004; - goto L0001; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_characterLiteral, &chunk->thunks, NULL)) goto L0005; - goto L0001; - L0005:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_oneLineString, &chunk->thunks, NULL)) goto L0006; - goto L0001; - L0006:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_tupleExpression, &chunk->thunks, NULL)) goto L0007; - goto L0001; - L0007:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_listExpression, &chunk->thunks, NULL)) goto L0008; - goto L0001; - L0008:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_recordExpression, &chunk->thunks, NULL)) goto L0009; - goto L0001; - L0009:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_caseStatement, &chunk->thunks, NULL)) goto L0010; - goto L0001; - L0010:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_ifThenElseStatement, &chunk->thunks, NULL)) goto L0011; - goto L0001; - L0011:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_anonymousFunction, &chunk->thunks, NULL)) goto L0012; - goto L0001; - L0012:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionCall, &chunk->thunks, NULL)) goto L0013; - goto L0001; - L0013:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0001:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "simpleExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "simpleExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_tupleExpression(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "tupleExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '(' - ) goto L0002; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0002; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ',' - ) goto L0003; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0003; - if (ctx->cur == p) break; - continue; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ')' - ) goto L0002; - ctx->cur++; - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '(' - ) goto L0004; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0004; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ')' - ) goto L0004; - ctx->cur++; - goto L0001; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0001:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "tupleExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "tupleExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_listExpression(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "listExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '[' - ) goto L0002; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0002; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ',' - ) goto L0003; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0003; - if (ctx->cur == p) break; - continue; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ']' - ) goto L0002; - ctx->cur++; - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '[' - ) goto L0004; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0004; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ']' - ) goto L0004; - ctx->cur++; - goto L0001; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0001:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "listExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "listExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_recordExpression(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "recordExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '{' - ) goto L0002; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0003; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '|' - ) goto L0003; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0003; - goto L0004; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0004:; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_recordExpressionAssignment, &chunk->thunks, NULL)) goto L0002; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0005; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ',' - ) goto L0005; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0005; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_recordExpressionAssignment, &chunk->thunks, NULL)) goto L0005; - if (ctx->cur == p) break; - continue; - L0005:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0002; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '}' - ) goto L0002; - ctx->cur++; - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '{' - ) goto L0006; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0006; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '}' - ) goto L0006; - ctx->cur++; - goto L0001; - L0006:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0001:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "recordExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "recordExpression", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_recordExpressionAssignment(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "recordExpressionAssignment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '=' - ) goto L0000; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "recordExpressionAssignment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "recordExpressionAssignment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_anonymousFunction(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "anonymousFunction", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '\\' - ) goto L0000; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_functionParameterList, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '-' || - (ctx->buffer.buf + ctx->cur)[1] != '>' - ) goto L0000; - ctx->cur += 2; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "anonymousFunction", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "anonymousFunction", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_functionCall(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "functionCall", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_dottedIdentifier, &chunk->thunks, NULL)) goto L0002; - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '.' - ) goto L0003; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lowerStartIdentifier, &chunk->thunks, NULL)) goto L0003; - goto L0001; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '(' - ) goto L0004; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_binaryOperator, &chunk->thunks, NULL)) goto L0004; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != ')' - ) goto L0004; - ctx->cur++; - goto L0001; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0001:; - } - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0005; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0005; - if (ctx->cur == p) break; - continue; - L0005:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "functionCall", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "functionCall", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_letInBlock(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "letInBlock", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if ( - pcc_refill_buffer(ctx, 3) < 3 || - (ctx->buffer.buf + ctx->cur)[0] != 'l' || - (ctx->buffer.buf + ctx->cur)[1] != 'e' || - (ctx->buffer.buf + ctx->cur)[2] != 't' - ) goto L0000; - ctx->cur += 3; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__NL_IND_, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_letInLine, &chunk->thunks, NULL)) goto L0000; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__NL_IND_, &chunk->thunks, NULL)) goto L0001; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_letInLine, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__NL_IND_, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != 'i' || - (ctx->buffer.buf + ctx->cur)[1] != 'n' - ) goto L0000; - ctx->cur += 2; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "letInBlock", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "letInBlock", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_letInLine(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "letInLine", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_letInFunctionDefinition, &chunk->thunks, NULL)) goto L0002; - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_letInBlock, &chunk->thunks, NULL)) goto L0003; - goto L0001; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_letInFunctionBody, &chunk->thunks, NULL)) goto L0004; - goto L0001; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0001:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "letInLine", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "letInLine", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_letInFunctionDefinition(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "letInFunctionDefinition", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 1); - { - const size_t p = ctx->cur; - size_t q; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_nonKeywordIdentifier, &chunk->thunks, NULL)) goto L0000; - q = ctx->cur; - chunk->capts.buf[0].range.start = p; - chunk->capts.buf[0].range.end = q; - } - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - { - const size_t p0 = ctx->cur; - const size_t n0 = chunk->thunks.len; - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_WS, &chunk->thunks, NULL)) goto L0002; - if (ctx->cur == p) break; - continue; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - if (i < 1) { - ctx->cur = p0; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); - goto L0001; - } - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_nonKeywordIdentifier, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_WS, &chunk->thunks, NULL)) goto L0003; - if (ctx->cur == p) break; - continue; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '=' - ) goto L0000; - ctx->cur++; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_Non_NL, &chunk->thunks, NULL)) goto L0004; - if (ctx->cur == p) break; - continue; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - { - pcc_thunk_t *const thunk = pcc_thunk__create_leaf(ctx->auxil, pcc_action_letInFunctionDefinition_0, 0, 1); - thunk->data.leaf.capts.buf[0] = &(chunk->capts.buf[0]); - thunk->data.leaf.capt0.range.start = chunk->pos; - thunk->data.leaf.capt0.range.end = ctx->cur; - pcc_thunk_array__add(ctx->auxil, &chunk->thunks, thunk); - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "letInFunctionDefinition", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "letInFunctionDefinition", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_letInFunctionBody(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "letInFunctionBody", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 3) < 3 || - (ctx->buffer.buf + ctx->cur)[0] != 'l' || - (ctx->buffer.buf + ctx->cur)[1] != 'e' || - (ctx->buffer.buf + ctx->cur)[2] != 't' - ) goto L0003; - ctx->cur += 3; - goto L0002; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != 'i' || - (ctx->buffer.buf + ctx->cur)[1] != 'n' - ) goto L0004; - ctx->cur += 2; - goto L0002; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0001; - L0002:; - } - ctx->cur = p; - goto L0000; - L0001:; - ctx->cur = p; - } - { - const size_t p0 = ctx->cur; - const size_t n0 = chunk->thunks.len; - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_Non_NL, &chunk->thunks, NULL)) goto L0005; - if (ctx->cur == p) break; - continue; - L0005:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - if (i < 1) { - ctx->cur = p0; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); - goto L0000; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "letInFunctionBody", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "letInFunctionBody", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_caseStatement(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "caseStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if ( - pcc_refill_buffer(ctx, 4) < 4 || - (ctx->buffer.buf + ctx->cur)[0] != 'c' || - (ctx->buffer.buf + ctx->cur)[1] != 'a' || - (ctx->buffer.buf + ctx->cur)[2] != 's' || - (ctx->buffer.buf + ctx->cur)[3] != 'e' - ) goto L0000; - ctx->cur += 4; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != 'o' || - (ctx->buffer.buf + ctx->cur)[1] != 'f' - ) goto L0000; - ctx->cur += 2; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_caseClauseList, &chunk->thunks, NULL)) goto L0000; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "caseStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "caseStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_caseClauseList(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "caseClauseList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_caseClause, &chunk->thunks, NULL)) goto L0000; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0001; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_caseClause, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "caseClauseList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "caseClauseList", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_caseClause(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "caseClause", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_roughCasePatternChar, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '-' || - (ctx->buffer.buf + ctx->cur)[1] != '>' - ) goto L0000; - ctx->cur += 2; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__0_, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "caseClause", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "caseClause", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_roughCasePatternChar(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "roughCasePatternChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '-' || - (ctx->buffer.buf + ctx->cur)[1] != '>' - ) goto L0003; - ctx->cur += 2; - goto L0002; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_TLSS, &chunk->thunks, NULL)) goto L0004; - goto L0002; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lineComment, &chunk->thunks, NULL)) goto L0005; - goto L0002; - L0005:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_delimitedComment, &chunk->thunks, NULL)) goto L0006; - goto L0002; - L0006:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_NL, &chunk->thunks, NULL)) goto L0007; - goto L0002; - L0007:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0001; - L0002:; - } - ctx->cur = p; - goto L0000; - L0001:; - ctx->cur = p; - } - { - int u; - const size_t n = pcc_get_char_as_utf32(ctx, &u); - if (n == 0) goto L0000; - ctx->cur += n; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "roughCasePatternChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "roughCasePatternChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_ifThenElseStatement(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "ifThenElseStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != 'i' || - (ctx->buffer.buf + ctx->cur)[1] != 'f' - ) goto L0000; - ctx->cur += 2; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 4) < 4 || - (ctx->buffer.buf + ctx->cur)[0] != 't' || - (ctx->buffer.buf + ctx->cur)[1] != 'h' || - (ctx->buffer.buf + ctx->cur)[2] != 'e' || - (ctx->buffer.buf + ctx->cur)[3] != 'n' - ) goto L0000; - ctx->cur += 4; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 4) < 4 || - (ctx->buffer.buf + ctx->cur)[0] != 'e' || - (ctx->buffer.buf + ctx->cur)[1] != 'l' || - (ctx->buffer.buf + ctx->cur)[2] != 's' || - (ctx->buffer.buf + ctx->cur)[3] != 'e' - ) goto L0000; - ctx->cur += 4; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0000; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_expression, &chunk->thunks, NULL)) goto L0000; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "ifThenElseStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "ifThenElseStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_binaryOperator(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "binaryOperator", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '>' || - (ctx->buffer.buf + ctx->cur)[1] != '>' - ) goto L0002; - ctx->cur += 2; - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '<' || - (ctx->buffer.buf + ctx->cur)[1] != '<' - ) goto L0003; - ctx->cur += 2; - goto L0001; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '|' || - (ctx->buffer.buf + ctx->cur)[1] != '>' - ) goto L0004; - ctx->cur += 2; - goto L0001; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '<' || - (ctx->buffer.buf + ctx->cur)[1] != '|' - ) goto L0005; - ctx->cur += 2; - goto L0001; - L0005:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '/' || - (ctx->buffer.buf + ctx->cur)[1] != '/' - ) goto L0006; - ctx->cur += 2; - goto L0001; - L0006:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '+' || - (ctx->buffer.buf + ctx->cur)[1] != '+' - ) goto L0007; - ctx->cur += 2; - goto L0001; - L0007:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != ':' || - (ctx->buffer.buf + ctx->cur)[1] != ':' - ) goto L0008; - ctx->cur += 2; - goto L0001; - L0008:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '=' || - (ctx->buffer.buf + ctx->cur)[1] != '=' - ) goto L0009; - ctx->cur += 2; - goto L0001; - L0009:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '/' || - (ctx->buffer.buf + ctx->cur)[1] != '=' - ) goto L0010; - ctx->cur += 2; - goto L0001; - L0010:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '&' || - (ctx->buffer.buf + ctx->cur)[1] != '&' - ) goto L0011; - ctx->cur += 2; - goto L0001; - L0011:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '|' || - (ctx->buffer.buf + ctx->cur)[1] != '|' - ) goto L0012; - ctx->cur += 2; - goto L0001; - L0012:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '<' || - (ctx->buffer.buf + ctx->cur)[1] != '=' - ) goto L0013; - ctx->cur += 2; - goto L0001; - L0013:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '>' || - (ctx->buffer.buf + ctx->cur)[1] != '=' - ) goto L0014; - ctx->cur += 2; - goto L0001; - L0014:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '<' - ) goto L0015; - ctx->cur++; - goto L0001; - L0015:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '>' - ) goto L0016; - ctx->cur++; - goto L0001; - L0016:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '+' - ) goto L0017; - ctx->cur++; - goto L0001; - L0017:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '-' - ) goto L0018; - ctx->cur++; - goto L0001; - L0018:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '*' - ) goto L0019; - ctx->cur++; - goto L0001; - L0019:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '/' - ) goto L0020; - ctx->cur++; - goto L0001; - L0020:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '^' - ) goto L0021; - ctx->cur++; - goto L0001; - L0021:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0001:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "binaryOperator", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "binaryOperator", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_ignoreRestOfStatement(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "ignoreRestOfStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_multilineString, &chunk->thunks, NULL)) goto L0002; - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - { - const size_t p0 = ctx->cur; - const size_t n0 = chunk->thunks.len; - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_Non_WS_or_NL, &chunk->thunks, NULL)) goto L0004; - if (ctx->cur == p) break; - continue; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - if (i < 1) { - ctx->cur = p0; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); - goto L0003; - } - } - goto L0001; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0001:; - } - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0005; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_ignoreRestOfStatement, &chunk->thunks, NULL)) goto L0005; - if (ctx->cur == p) break; - continue; - L0005:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "ignoreRestOfStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "ignoreRestOfStatement", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_multilineString(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "multilineString", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if ( - pcc_refill_buffer(ctx, 3) < 3 || - (ctx->buffer.buf + ctx->cur)[0] != '\"' || - (ctx->buffer.buf + ctx->cur)[1] != '\"' || - (ctx->buffer.buf + ctx->cur)[2] != '\"' - ) goto L0000; - ctx->cur += 3; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - { - const size_t p = ctx->cur; - if ( - pcc_refill_buffer(ctx, 3) < 3 || - (ctx->buffer.buf + ctx->cur)[0] != '\"' || - (ctx->buffer.buf + ctx->cur)[1] != '\"' || - (ctx->buffer.buf + ctx->cur)[2] != '\"' - ) goto L0002; - ctx->cur += 3; - ctx->cur = p; - goto L0001; - L0002:; - ctx->cur = p; - } - { - int u; - const size_t n = pcc_get_char_as_utf32(ctx, &u); - if (n == 0) goto L0001; - ctx->cur += n; - } - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - if ( - pcc_refill_buffer(ctx, 3) < 3 || - (ctx->buffer.buf + ctx->cur)[0] != '\"' || - (ctx->buffer.buf + ctx->cur)[1] != '\"' || - (ctx->buffer.buf + ctx->cur)[2] != '\"' - ) goto L0000; - ctx->cur += 3; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "multilineString", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "multilineString", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_naiveIdentifier(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "naiveIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - int u; - const size_t n = pcc_get_char_as_utf32(ctx, &u); - if (n == 0) goto L0000; - if (!( - (u >= 0x000041 && u <= 0x00005a) || - (u >= 0x000061 && u <= 0x00007a) || - u == 0x00005f - )) goto L0000; - ctx->cur += n; - } - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "naiveIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "naiveIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_upperStartIdentifier(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "upperStartIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - int u; - const size_t n = pcc_get_char_as_utf32(ctx, &u); - if (n == 0) goto L0000; - if (!( - (u >= 0x000041 && u <= 0x00005a) - )) goto L0000; - ctx->cur += n; - } - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "upperStartIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "upperStartIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_lowerStartIdentifier(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "lowerStartIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_keyword, &chunk->thunks, NULL)) goto L0001; - ctx->cur = p; - goto L0000; - L0001:; - ctx->cur = p; - } - { - int u; - const size_t n = pcc_get_char_as_utf32(ctx, &u); - if (n == 0) goto L0000; - if (!( - (u >= 0x000061 && u <= 0x00007a) || - u == 0x00005f - )) goto L0000; - ctx->cur += n; - } - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0002; - if (ctx->cur == p) break; - continue; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "lowerStartIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "lowerStartIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_alphanumeric(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "alphanumeric", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - int u; - const size_t n = pcc_get_char_as_utf32(ctx, &u); - if (n == 0) goto L0000; - if (!( - (u >= 0x000041 && u <= 0x00005a) || - (u >= 0x000061 && u <= 0x00007a) || - (u >= 0x000030 && u <= 0x000039) || - u == 0x00005f - )) goto L0000; - ctx->cur += n; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "alphanumeric", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "alphanumeric", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_nonKeywordIdentifier(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "nonKeywordIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_keyword, &chunk->thunks, NULL)) goto L0001; - ctx->cur = p; - goto L0000; - L0001:; - ctx->cur = p; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_naiveIdentifier, &chunk->thunks, NULL)) goto L0000; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "nonKeywordIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "nonKeywordIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_keyword(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "keyword", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 4) < 4 || - (ctx->buffer.buf + ctx->cur)[0] != 't' || - (ctx->buffer.buf + ctx->cur)[1] != 'y' || - (ctx->buffer.buf + ctx->cur)[2] != 'p' || - (ctx->buffer.buf + ctx->cur)[3] != 'e' - ) goto L0002; - ctx->cur += 4; - { - const size_t p = ctx->cur; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0003; - ctx->cur = p; - goto L0002; - L0003:; - ctx->cur = p; - } - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 6) < 6 || - (ctx->buffer.buf + ctx->cur)[0] != 'm' || - (ctx->buffer.buf + ctx->cur)[1] != 'o' || - (ctx->buffer.buf + ctx->cur)[2] != 'd' || - (ctx->buffer.buf + ctx->cur)[3] != 'u' || - (ctx->buffer.buf + ctx->cur)[4] != 'l' || - (ctx->buffer.buf + ctx->cur)[5] != 'e' - ) goto L0004; - ctx->cur += 6; - { - const size_t p = ctx->cur; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0005; - ctx->cur = p; - goto L0004; - L0005:; - ctx->cur = p; - } - goto L0001; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 4) < 4 || - (ctx->buffer.buf + ctx->cur)[0] != 'p' || - (ctx->buffer.buf + ctx->cur)[1] != 'o' || - (ctx->buffer.buf + ctx->cur)[2] != 'r' || - (ctx->buffer.buf + ctx->cur)[3] != 't' - ) goto L0006; - ctx->cur += 4; - { - const size_t p = ctx->cur; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0007; - ctx->cur = p; - goto L0006; - L0007:; - ctx->cur = p; - } - goto L0001; - L0006:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 5) < 5 || - (ctx->buffer.buf + ctx->cur)[0] != 'a' || - (ctx->buffer.buf + ctx->cur)[1] != 'l' || - (ctx->buffer.buf + ctx->cur)[2] != 'i' || - (ctx->buffer.buf + ctx->cur)[3] != 'a' || - (ctx->buffer.buf + ctx->cur)[4] != 's' - ) goto L0008; - ctx->cur += 5; - { - const size_t p = ctx->cur; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0009; - ctx->cur = p; - goto L0008; - L0009:; - ctx->cur = p; - } - goto L0001; - L0008:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != 'a' || - (ctx->buffer.buf + ctx->cur)[1] != 's' - ) goto L0010; - ctx->cur += 2; - { - const size_t p = ctx->cur; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0011; - ctx->cur = p; - goto L0010; - L0011:; - ctx->cur = p; - } - goto L0001; - L0010:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 8) < 8 || - (ctx->buffer.buf + ctx->cur)[0] != 'e' || - (ctx->buffer.buf + ctx->cur)[1] != 'x' || - (ctx->buffer.buf + ctx->cur)[2] != 'p' || - (ctx->buffer.buf + ctx->cur)[3] != 'o' || - (ctx->buffer.buf + ctx->cur)[4] != 's' || - (ctx->buffer.buf + ctx->cur)[5] != 'i' || - (ctx->buffer.buf + ctx->cur)[6] != 'n' || - (ctx->buffer.buf + ctx->cur)[7] != 'g' - ) goto L0012; - ctx->cur += 8; - { - const size_t p = ctx->cur; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0013; - ctx->cur = p; - goto L0012; - L0013:; - ctx->cur = p; - } - goto L0001; - L0012:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 6) < 6 || - (ctx->buffer.buf + ctx->cur)[0] != 'i' || - (ctx->buffer.buf + ctx->cur)[1] != 'm' || - (ctx->buffer.buf + ctx->cur)[2] != 'p' || - (ctx->buffer.buf + ctx->cur)[3] != 'o' || - (ctx->buffer.buf + ctx->cur)[4] != 'r' || - (ctx->buffer.buf + ctx->cur)[5] != 't' - ) goto L0014; - ctx->cur += 6; - { - const size_t p = ctx->cur; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0015; - ctx->cur = p; - goto L0014; - L0015:; - ctx->cur = p; - } - goto L0001; - L0014:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 3) < 3 || - (ctx->buffer.buf + ctx->cur)[0] != 'l' || - (ctx->buffer.buf + ctx->cur)[1] != 'e' || - (ctx->buffer.buf + ctx->cur)[2] != 't' - ) goto L0016; - ctx->cur += 3; - { - const size_t p = ctx->cur; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0017; - ctx->cur = p; - goto L0016; - L0017:; - ctx->cur = p; - } - goto L0001; - L0016:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != 'i' || - (ctx->buffer.buf + ctx->cur)[1] != 'n' - ) goto L0018; - ctx->cur += 2; - { - const size_t p = ctx->cur; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0019; - ctx->cur = p; - goto L0018; - L0019:; - ctx->cur = p; - } - goto L0001; - L0018:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 4) < 4 || - (ctx->buffer.buf + ctx->cur)[0] != 'c' || - (ctx->buffer.buf + ctx->cur)[1] != 'a' || - (ctx->buffer.buf + ctx->cur)[2] != 's' || - (ctx->buffer.buf + ctx->cur)[3] != 'e' - ) goto L0020; - ctx->cur += 4; - { - const size_t p = ctx->cur; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0021; - ctx->cur = p; - goto L0020; - L0021:; - ctx->cur = p; - } - goto L0001; - L0020:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != 'o' || - (ctx->buffer.buf + ctx->cur)[1] != 'f' - ) goto L0022; - ctx->cur += 2; - { - const size_t p = ctx->cur; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0023; - ctx->cur = p; - goto L0022; - L0023:; - ctx->cur = p; - } - goto L0001; - L0022:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != 'i' || - (ctx->buffer.buf + ctx->cur)[1] != 'f' - ) goto L0024; - ctx->cur += 2; - { - const size_t p = ctx->cur; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0025; - ctx->cur = p; - goto L0024; - L0025:; - ctx->cur = p; - } - goto L0001; - L0024:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 4) < 4 || - (ctx->buffer.buf + ctx->cur)[0] != 't' || - (ctx->buffer.buf + ctx->cur)[1] != 'h' || - (ctx->buffer.buf + ctx->cur)[2] != 'e' || - (ctx->buffer.buf + ctx->cur)[3] != 'n' - ) goto L0026; - ctx->cur += 4; - { - const size_t p = ctx->cur; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0027; - ctx->cur = p; - goto L0026; - L0027:; - ctx->cur = p; - } - goto L0001; - L0026:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 4) < 4 || - (ctx->buffer.buf + ctx->cur)[0] != 'e' || - (ctx->buffer.buf + ctx->cur)[1] != 'l' || - (ctx->buffer.buf + ctx->cur)[2] != 's' || - (ctx->buffer.buf + ctx->cur)[3] != 'e' - ) goto L0028; - ctx->cur += 4; - { - const size_t p = ctx->cur; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_alphanumeric, &chunk->thunks, NULL)) goto L0029; - ctx->cur = p; - goto L0028; - L0029:; - ctx->cur = p; - } - goto L0001; - L0028:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0001:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "keyword", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "keyword", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_dottedIdentifier(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "dottedIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_nonKeywordIdentifier, &chunk->thunks, NULL)) goto L0000; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '.' - ) goto L0001; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_nonKeywordIdentifier, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "dottedIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "dottedIdentifier", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_decimal(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "decimal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_exponentialDecimal, &chunk->thunks, NULL)) goto L0002; - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_simpleDecimal, &chunk->thunks, NULL)) goto L0003; - goto L0001; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0001:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "decimal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "decimal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_exponentialDecimal(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "exponentialDecimal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_simpleDecimal, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != 'e' - ) goto L0000; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_simpleInteger, &chunk->thunks, NULL)) goto L0000; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "exponentialDecimal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "exponentialDecimal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_simpleDecimal(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "simpleDecimal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_simpleInteger, &chunk->thunks, NULL)) goto L0002; - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '.' - ) goto L0003; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_digits, &chunk->thunks, NULL)) goto L0003; - goto L0004; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0004:; - } - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '.' - ) goto L0005; - ctx->cur++; - { - const size_t p0 = ctx->cur; - const size_t n0 = chunk->thunks.len; - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_digits, &chunk->thunks, NULL)) goto L0006; - if (ctx->cur == p) break; - continue; - L0006:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - if (i < 1) { - ctx->cur = p0; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); - goto L0005; - } - } - goto L0001; - L0005:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0001:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "simpleDecimal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "simpleDecimal", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_simpleInteger(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "simpleInteger", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - { - int u; - const size_t n = pcc_get_char_as_utf32(ctx, &u); - if (n == 0) goto L0001; - if (!( - u == 0x00002d || - u == 0x00002b - )) goto L0001; - ctx->cur += n; - } - goto L0002; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0002:; - } - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_digits, &chunk->thunks, NULL)) goto L0000; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "simpleInteger", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "simpleInteger", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_digits(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "digits", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p0 = ctx->cur; - const size_t n0 = chunk->thunks.len; - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - { - int u; - const size_t n = pcc_get_char_as_utf32(ctx, &u); - if (n == 0) goto L0001; - if (!( - (u >= 0x000030 && u <= 0x000039) - )) goto L0001; - ctx->cur += n; - } - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - if (i < 1) { - ctx->cur = p0; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); - goto L0000; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "digits", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "digits", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_hexNumber(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "hexNumber", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '0' || - (ctx->buffer.buf + ctx->cur)[1] != 'x' - ) goto L0000; - ctx->cur += 2; - { - const size_t p0 = ctx->cur; - const size_t n0 = chunk->thunks.len; - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - { - int u; - const size_t n = pcc_get_char_as_utf32(ctx, &u); - if (n == 0) goto L0001; - if (!( - (u >= 0x000030 && u <= 0x000039) || - (u >= 0x000041 && u <= 0x000046) || - (u >= 0x000061 && u <= 0x000066) - )) goto L0001; - ctx->cur += n; - } - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - if (i < 1) { - ctx->cur = p0; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); - goto L0000; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "hexNumber", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "hexNumber", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_oneLineString(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "oneLineString", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '\"' - ) goto L0000; - ctx->cur++; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_inStringChar, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '\"' - ) goto L0000; - ctx->cur++; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "oneLineString", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "oneLineString", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_characterLiteral(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "characterLiteral", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '\'' - ) goto L0000; - ctx->cur++; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_inStringChar, &chunk->thunks, NULL)) goto L0000; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '\'' - ) goto L0000; - ctx->cur++; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "characterLiteral", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "characterLiteral", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_inStringChar(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "inStringChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '\"' - ) goto L0003; - ctx->cur++; - goto L0002; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_NL, &chunk->thunks, NULL)) goto L0004; - goto L0002; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0001; - L0002:; - } - ctx->cur = p; - goto L0000; - L0001:; - ctx->cur = p; - } - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_inStringUnicodeChar, &chunk->thunks, NULL)) goto L0006; - goto L0005; - L0006:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_inStringEscapedChar, &chunk->thunks, NULL)) goto L0007; - goto L0005; - L0007:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_inStringPlainChar, &chunk->thunks, NULL)) goto L0008; - goto L0005; - L0008:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0005:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "inStringChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "inStringChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_inStringPlainChar(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "inStringPlainChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '\"' - ) goto L0003; - ctx->cur++; - goto L0002; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '\\' - ) goto L0004; - ctx->cur++; - goto L0002; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_NL, &chunk->thunks, NULL)) goto L0005; - goto L0002; - L0005:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0001; - L0002:; - } - ctx->cur = p; - goto L0000; - L0001:; - ctx->cur = p; - } - { - int u; - const size_t n = pcc_get_char_as_utf32(ctx, &u); - if (n == 0) goto L0000; - ctx->cur += n; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "inStringPlainChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "inStringPlainChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_inStringEscapedChar(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "inStringEscapedChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '\\' - ) goto L0000; - ctx->cur++; - { - const size_t p = ctx->cur; - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != 'u' - ) goto L0003; - ctx->cur++; - goto L0002; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_NL, &chunk->thunks, NULL)) goto L0004; - goto L0002; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0001; - L0002:; - } - ctx->cur = p; - goto L0000; - L0001:; - ctx->cur = p; - } - { - int u; - const size_t n = pcc_get_char_as_utf32(ctx, &u); - if (n == 0) goto L0000; - ctx->cur += n; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "inStringEscapedChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "inStringEscapedChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_inStringUnicodeChar(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "inStringUnicodeChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if ( - pcc_refill_buffer(ctx, 3) < 3 || - (ctx->buffer.buf + ctx->cur)[0] != '\\' || - (ctx->buffer.buf + ctx->cur)[1] != 'u' || - (ctx->buffer.buf + ctx->cur)[2] != '{' - ) goto L0000; - ctx->cur += 3; - { - const size_t p0 = ctx->cur; - const size_t n0 = chunk->thunks.len; - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - { - int u; - const size_t n = pcc_get_char_as_utf32(ctx, &u); - if (n == 0) goto L0001; - if (!( - (u >= 0x000030 && u <= 0x000039) || - (u >= 0x000041 && u <= 0x000046) || - (u >= 0x000061 && u <= 0x000066) - )) goto L0001; - ctx->cur += n; - } - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - if (i < 1) { - ctx->cur = p0; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); - goto L0000; - } - } - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '}' - ) goto L0000; - ctx->cur++; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "inStringUnicodeChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "inStringUnicodeChar", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_WS(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "WS", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p0 = ctx->cur; - const size_t n0 = chunk->thunks.len; - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - { - int u; - const size_t n = pcc_get_char_as_utf32(ctx, &u); - if (n == 0) goto L0001; - if (!( - u == 0x000020 || - u == 0x000009 - )) goto L0001; - ctx->cur += n; - } - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - if (i < 1) { - ctx->cur = p0; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); - goto L0000; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "WS", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "WS", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_NL(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "NL", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '\n' - ) goto L0002; - ctx->cur++; - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '\f' - ) goto L0003; - ctx->cur++; - goto L0001; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '\r' - ) goto L0004; - ctx->cur++; - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if ( - pcc_refill_buffer(ctx, 1) < 1 || - ctx->buffer.buf[ctx->cur] != '\n' - ) goto L0005; - ctx->cur++; - goto L0006; - L0005:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0006:; - } - goto L0001; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0001:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "NL", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "NL", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_Non_NL(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "Non_NL", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - int u; - const size_t n = pcc_get_char_as_utf32(ctx, &u); - if (n == 0) goto L0000; - if ( - u == 0x00000a || - u == 0x00000d || - u == 0x00000c - ) goto L0000; - ctx->cur += n; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "Non_NL", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "Non_NL", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_Non_WS_or_NL(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "Non_WS_or_NL", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - int u; - const size_t n = pcc_get_char_as_utf32(ctx, &u); - if (n == 0) goto L0000; - if ( - u == 0x000020 || - u == 0x000009 || - u == 0x00000a || - u == 0x00000d || - u == 0x00000c - ) goto L0000; - ctx->cur += n; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "Non_WS_or_NL", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "Non_WS_or_NL", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_EOF(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "EOF", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - { - int u; - const size_t n = pcc_get_char_as_utf32(ctx, &u); - if (n == 0) goto L0001; - ctx->cur += n; - } - ctx->cur = p; - goto L0000; - L0001:; - ctx->cur = p; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "EOF", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "EOF", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_delimitedComment(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "delimitedComment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '{' || - (ctx->buffer.buf + ctx->cur)[1] != '-' - ) goto L0000; - ctx->cur += 2; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_delimitedComment, &chunk->thunks, NULL)) goto L0003; - goto L0002; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - { - const size_t p = ctx->cur; - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '-' || - (ctx->buffer.buf + ctx->cur)[1] != '}' - ) goto L0005; - ctx->cur += 2; - ctx->cur = p; - goto L0004; - L0005:; - ctx->cur = p; - } - { - int u; - const size_t n = pcc_get_char_as_utf32(ctx, &u); - if (n == 0) goto L0004; - ctx->cur += n; - } - goto L0002; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0001; - L0002:; - } - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '-' || - (ctx->buffer.buf + ctx->cur)[1] != '}' - ) goto L0000; - ctx->cur += 2; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "delimitedComment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "delimitedComment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_lineComment(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "lineComment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - if ( - pcc_refill_buffer(ctx, 2) < 2 || - (ctx->buffer.buf + ctx->cur)[0] != '-' || - (ctx->buffer.buf + ctx->cur)[1] != '-' - ) goto L0000; - ctx->cur += 2; - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_Non_NL, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "lineComment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "lineComment", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule__1_short(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "_1_short", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lineComment, &chunk->thunks, NULL)) goto L0003; - goto L0002; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_NL, &chunk->thunks, NULL)) goto L0004; - goto L0002; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0001; - L0002:; - } - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_WS, &chunk->thunks, NULL)) goto L0006; - goto L0005; - L0006:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_delimitedComment, &chunk->thunks, NULL)) goto L0007; - goto L0005; - L0007:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0005:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "_1_short", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "_1_short", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule__1_(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "_1_", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p0 = ctx->cur; - const size_t n0 = chunk->thunks.len; - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_short, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - if (i < 1) { - ctx->cur = p0; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); - goto L0000; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "_1_", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "_1_", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule__0_(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "_0_", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule__1_, &chunk->thunks, NULL)) goto L0002; - goto L0001; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - L0001:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "_0_", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_TLSS_short(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "TLSS_short", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_WS, &chunk->thunks, NULL)) goto L0003; - goto L0002; - L0003:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lineComment, &chunk->thunks, NULL)) goto L0004; - goto L0002; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_delimitedComment, &chunk->thunks, NULL)) goto L0005; - goto L0002; - L0005:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0001; - L0002:; - } - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - } - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_NL, &chunk->thunks, NULL)) goto L0007; - goto L0006; - L0007:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_EOF, &chunk->thunks, NULL)) goto L0008; - goto L0006; - L0008:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0000; - L0006:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "TLSS_short", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "TLSS_short", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_TLSS(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "TLSS", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p0 = ctx->cur; - const size_t n0 = chunk->thunks.len; - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_TLSS_short, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - if (i < 1) { - ctx->cur = p0; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); - goto L0000; - } - } - { - const size_t p = ctx->cur; - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_WS, &chunk->thunks, NULL)) goto L0004; - goto L0003; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_lineComment, &chunk->thunks, NULL)) goto L0005; - goto L0003; - L0005:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_delimitedComment, &chunk->thunks, NULL)) goto L0006; - goto L0003; - L0006:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0002; - L0003:; - } - ctx->cur = p; - goto L0000; - L0002:; - ctx->cur = p; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "TLSS", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "TLSS", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule_EOS(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "EOS", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p = ctx->cur; - { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_TLSS, &chunk->thunks, NULL)) goto L0004; - goto L0003; - L0004:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_EOF, &chunk->thunks, NULL)) goto L0005; - goto L0003; - L0005:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - goto L0001; - L0003:; - } - ctx->cur = p; - goto L0002; - L0001:; - ctx->cur = p; - goto L0000; - L0002:; - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "EOS", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "EOS", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -static pcc_thunk_chunk_t *pcc_evaluate_rule__NL_IND_(pelm_context_t *ctx) { - pcc_thunk_chunk_t *const chunk = pcc_thunk_chunk__create(ctx->auxil); - chunk->pos = ctx->cur; - PCC_DEBUG(ctx->auxil, PCC_DBG_EVALUATE, "_NL_IND_", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->buffer.len - chunk->pos)); - ctx->level++; - pcc_value_table__resize(ctx->auxil, &chunk->values, 0); - pcc_capture_table__resize(ctx->auxil, &chunk->capts, 0); - { - const size_t p0 = ctx->cur; - const size_t n0 = chunk->thunks.len; - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_TLSS_short, &chunk->thunks, NULL)) goto L0001; - if (ctx->cur == p) break; - continue; - L0001:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - if (i < 1) { - ctx->cur = p0; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); - goto L0000; - } - } - { - const size_t p0 = ctx->cur; - const size_t n0 = chunk->thunks.len; - int i; - for (i = 0;; i++) { - const size_t p = ctx->cur; - const size_t n = chunk->thunks.len; - if (!pcc_apply_rule(ctx, pcc_evaluate_rule_WS, &chunk->thunks, NULL)) goto L0002; - if (ctx->cur == p) break; - continue; - L0002:; - ctx->cur = p; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n); - break; - } - if (i < 1) { - ctx->cur = p0; - pcc_thunk_array__revert(ctx->auxil, &chunk->thunks, n0); - goto L0000; - } - } - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_MATCH, "_NL_IND_", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - return chunk; -L0000:; - ctx->level--; - PCC_DEBUG(ctx->auxil, PCC_DBG_NOMATCH, "_NL_IND_", ctx->level, chunk->pos, (ctx->buffer.buf + chunk->pos), (ctx->cur - chunk->pos)); - pcc_thunk_chunk__destroy(ctx->auxil, chunk); - return NULL; -} - -pelm_context_t *pelm_create(struct parserCtx *auxil) { - return pcc_context__create(auxil); -} - -int pelm_parse(pelm_context_t *ctx, int *ret) { - if (pcc_apply_rule(ctx, pcc_evaluate_rule_file, &ctx->thunks, ret)) - pcc_do_action(ctx, &ctx->thunks, ret); - else - PCC_ERROR(ctx->auxil); - pcc_commit_buffer(ctx); - pcc_thunk_array__revert(ctx->auxil, &ctx->thunks, 0); - return pcc_refill_buffer(ctx, 1) >= 1; -} - -void pelm_destroy(pelm_context_t *ctx) { - pcc_context__destroy(ctx); -} - -#include "elm_post.h" diff --git a/peg/elm.h b/peg/elm.h deleted file mode 100644 index a5cc3abbcc..0000000000 --- a/peg/elm.h +++ /dev/null @@ -1,22 +0,0 @@ -/* A packrat parser generated by PackCC 1.6.0 */ - -#ifndef PCC_INCLUDED___PEG_ELM_H -#define PCC_INCLUDED___PEG_ELM_H - -struct parserCtx; - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct pelm_context_tag pelm_context_t; - -pelm_context_t *pelm_create(struct parserCtx *auxil); -int pelm_parse(pelm_context_t *ctx, int *ret); -void pelm_destroy(pelm_context_t *ctx); - -#ifdef __cplusplus -} -#endif - -#endif /* !PCC_INCLUDED___PEG_ELM_H */ From 9a79fc14a87286c1ad516dd27d51bee97d3f0225 Mon Sep 17 00:00:00 2001 From: Nik Silver Date: Thu, 24 Mar 2022 19:29:15 +0000 Subject: [PATCH 04/11] Elm: Fix parser error causing assertion failure. Error reported is ``` ctags: main/numarray.c:178: intArrayRemoveLast: Assertion `current->count > 0' failed. ``` caused by unbalanced SET_SCOPE/POP_KIND. Thanks to Masaktake Yamato for [finding the cause](https://github.com/universal-ctags/ctags/pull/3312#pullrequestreview-919484608). --- peg/elm.peg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/peg/elm.peg b/peg/elm.peg index 4cc7aea70f..f87e9a4dc7 100644 --- a/peg/elm.peg +++ b/peg/elm.peg @@ -160,7 +160,7 @@ customType <- 'type' _1_ (_0_ typeParameterList)? _0_ '=' _0_ { makeElmTagSettingScope(auxil, $1, $1s, K_TYPE, ROLE_DEFINITION_INDEX); } constructorList EOS { - POP_KIND(auxil, true); + POP_SCOPE(auxil); } typeParameterList <- lowerStartIdentifier (_1_ lowerStartIdentifier)* From 52c7fe3e7fdc57ae9c35e7cdc7df6a4682884714 Mon Sep 17 00:00:00 2001 From: Nik Silver Date: Thu, 24 Mar 2022 19:47:10 +0000 Subject: [PATCH 05/11] Elm,cosmetic: Add links in comments language reference. --- peg/elm.peg | 5 ++++- peg/elm_post.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/peg/elm.peg b/peg/elm.peg index f87e9a4dc7..e082023d2e 100644 --- a/peg/elm.peg +++ b/peg/elm.peg @@ -3,7 +3,10 @@ # This source code is released for free distribution under the terms of the # GNU General Public License version 2 or later. # -# This Elm parser will tag items reliably at the top level. Functions +# This parser generates tags for Elm. See https://elm-lang.org/docs/syntax +# for language reference. +# +# The parser will tag items reliably at the top level. Functions # defined in let/in blocks are also tagged, but with limitations. See below. # # Kinds diff --git a/peg/elm_post.h b/peg/elm_post.h index b2f079e7ad..6cdc9c6fd1 100644 --- a/peg/elm_post.h +++ b/peg/elm_post.h @@ -6,6 +6,7 @@ * GNU General Public License version 2 or (at your option) any later version. * * This module contains functions to generate tags for Elm. + * See https://elm-lang.org/docs/syntax for language reference. */ /* From 7384e744e654f2ce7892c544a5d3e4b0ff04b7d8 Mon Sep 17 00:00:00 2001 From: Nik Silver Date: Thu, 24 Mar 2022 20:30:24 +0000 Subject: [PATCH 06/11] Style: Update generated win32 VS2013 files Following an earlier comment, committed files generated by `make -BC win32`. Earlier comment is: https://github.com/universal-ctags/ctags/pull/3312#issuecomment-1076792579 --- win32/ctags_vs2013.vcxproj | 2 +- win32/ctags_vs2013.vcxproj.filters | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/win32/ctags_vs2013.vcxproj b/win32/ctags_vs2013.vcxproj index 05e718f8d9..aac34cb094 100644 --- a/win32/ctags_vs2013.vcxproj +++ b/win32/ctags_vs2013.vcxproj @@ -462,4 +462,4 @@ - + \ No newline at end of file diff --git a/win32/ctags_vs2013.vcxproj.filters b/win32/ctags_vs2013.vcxproj.filters index de83fba6cd..5351df2e57 100644 --- a/win32/ctags_vs2013.vcxproj.filters +++ b/win32/ctags_vs2013.vcxproj.filters @@ -890,4 +890,4 @@ Resource Files - + \ No newline at end of file From dcac6768e9c4b9d752ad8b501a7a4f32cfa3e0b1 Mon Sep 17 00:00:00 2001 From: Nik Silver Date: Sat, 26 Mar 2022 11:32:28 +0000 Subject: [PATCH 07/11] Elm,refactor: Use helper function for brevity. --- peg/elm_post.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/peg/elm_post.h b/peg/elm_post.h index 6cdc9c6fd1..512ec9c42f 100644 --- a/peg/elm_post.h +++ b/peg/elm_post.h @@ -68,11 +68,7 @@ static void addElmSignature(int scope_index, const char *sig) if (e) { vString *vsig = collapseWhitespace (sig); - const char *sig2 = vStringValue (vsig); - - e->extensionFields.signature = eStrdup (sig2); - - vStringDelete (vsig); + e->extensionFields.signature = vStringDeleteUnwrap (vsig); } } From ed0d63d3ab975700e9f9d33092fafd1e52214588 Mon Sep 17 00:00:00 2001 From: Nik Silver Date: Sat, 26 Mar 2022 13:35:27 +0000 Subject: [PATCH 08/11] Elm: signature field becomes typeref:description field. --- Units/parser-elm.r/elm-bad-lines.d/args.ctags | 2 +- Units/parser-elm.r/elm-bad-lines.d/expected.tags | 2 +- .../elm-case-statements.d/args.ctags | 2 +- .../parser-elm.r/elm-complex-types.d/args.ctags | 2 +- .../elm-constructor-signatures.d/args.ctags | 2 +- .../elm-constructor-signatures.d/expected.tags | 6 +++--- Units/parser-elm.r/elm-expressions.d/args.ctags | 2 +- Units/parser-elm.r/elm-functions.d/args.ctags | 2 +- Units/parser-elm.r/elm-functions.d/input.elm | 2 +- Units/parser-elm.r/elm-if-then-else.d/args.ctags | 2 +- Units/parser-elm.r/elm-imports.d/args.ctags | 2 +- Units/parser-elm.r/elm-let-in.d/args.ctags | 2 +- .../elm-multiline-strings.d/args.ctags | 2 +- .../elm-optlist-compatibility.d/args.ctags | 2 +- .../elm-parameter-patterns.d/args.ctags | 2 +- Units/parser-elm.r/elm-ports.d/args.ctags | 2 +- Units/parser-elm.r/elm-ports.d/expected.tags | 4 ++-- .../parser-elm.r/elm-signatures.d/expected.tags | 9 --------- .../elm-single-expressions.d/args.ctags | 2 +- .../args.ctags | 2 +- .../elm-type-annotations.d/expected.tags | 9 +++++++++ .../input.elm | 14 +++++++------- Units/parser-elm.r/elm-types.d/args.ctags | 2 +- docs/man/ctags-lang-elm.7.rst | 16 ++++++++-------- man/ctags-lang-elm.7.rst.in | 16 ++++++++-------- peg/elm.peg | 12 +++++++----- peg/elm_post.h | 6 ++++-- peg/elm_pre.h | 2 +- 28 files changed, 67 insertions(+), 63 deletions(-) delete mode 100644 Units/parser-elm.r/elm-signatures.d/expected.tags rename Units/parser-elm.r/{elm-signatures.d => elm-type-annotations.d}/args.ctags (62%) create mode 100644 Units/parser-elm.r/elm-type-annotations.d/expected.tags rename Units/parser-elm.r/{elm-signatures.d => elm-type-annotations.d}/input.elm (62%) diff --git a/Units/parser-elm.r/elm-bad-lines.d/args.ctags b/Units/parser-elm.r/elm-bad-lines.d/args.ctags index 405ad9b9ff..41f6dbed62 100644 --- a/Units/parser-elm.r/elm-bad-lines.d/args.ctags +++ b/Units/parser-elm.r/elm-bad-lines.d/args.ctags @@ -1,3 +1,3 @@ --sort=no --extras=+r ---fields=+rS +--fields=+r diff --git a/Units/parser-elm.r/elm-bad-lines.d/expected.tags b/Units/parser-elm.r/elm-bad-lines.d/expected.tags index 6e06f8bb57..8756fdd497 100644 --- a/Units/parser-elm.r/elm-bad-lines.d/expected.tags +++ b/Units/parser-elm.r/elm-bad-lines.d/expected.tags @@ -1,6 +1,6 @@ Input input.elm /^import Input exposing (..)$/;" m roles:imported input1a input-1.elm /^input1a = 1$/;" f roles:def -input1b input-1.elm /^input1b = 2$/;" f signature:Int roles:def +input1b input-1.elm /^input1b = 2$/;" f typeref:description:Int roles:def input2b input-2.elm /^input2b = 1$/;" f roles:def input2c input-2.elm /^input2c = 3$/;" f roles:def module2d input-2.elm /^module2d = 4$/;" f roles:def diff --git a/Units/parser-elm.r/elm-case-statements.d/args.ctags b/Units/parser-elm.r/elm-case-statements.d/args.ctags index 405ad9b9ff..41f6dbed62 100644 --- a/Units/parser-elm.r/elm-case-statements.d/args.ctags +++ b/Units/parser-elm.r/elm-case-statements.d/args.ctags @@ -1,3 +1,3 @@ --sort=no --extras=+r ---fields=+rS +--fields=+r diff --git a/Units/parser-elm.r/elm-complex-types.d/args.ctags b/Units/parser-elm.r/elm-complex-types.d/args.ctags index 41f6dbed62..0616e13069 100644 --- a/Units/parser-elm.r/elm-complex-types.d/args.ctags +++ b/Units/parser-elm.r/elm-complex-types.d/args.ctags @@ -1,3 +1,3 @@ --sort=no --extras=+r ---fields=+r +--fields=+r-t diff --git a/Units/parser-elm.r/elm-constructor-signatures.d/args.ctags b/Units/parser-elm.r/elm-constructor-signatures.d/args.ctags index 405ad9b9ff..41f6dbed62 100644 --- a/Units/parser-elm.r/elm-constructor-signatures.d/args.ctags +++ b/Units/parser-elm.r/elm-constructor-signatures.d/args.ctags @@ -1,3 +1,3 @@ --sort=no --extras=+r ---fields=+rS +--fields=+r diff --git a/Units/parser-elm.r/elm-constructor-signatures.d/expected.tags b/Units/parser-elm.r/elm-constructor-signatures.d/expected.tags index 43edeb252a..0b466e2262 100644 --- a/Units/parser-elm.r/elm-constructor-signatures.d/expected.tags +++ b/Units/parser-elm.r/elm-constructor-signatures.d/expected.tags @@ -1,4 +1,4 @@ B input.elm /^type B$/;" t roles:def -B3Cons input.elm /^ | B3Cons$/;" c type:B signature: roles:def -B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B signature:String Integer roles:def -B1Cons input.elm /^ = B1Cons$/;" c type:B signature:{ x : Float , y : Float } roles:def +B3Cons input.elm /^ | B3Cons$/;" c type:B typeref:description: roles:def +B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B typeref:description:String Integer roles:def +B1Cons input.elm /^ = B1Cons$/;" c type:B typeref:description:{ x : Float , y : Float } roles:def diff --git a/Units/parser-elm.r/elm-expressions.d/args.ctags b/Units/parser-elm.r/elm-expressions.d/args.ctags index 405ad9b9ff..41f6dbed62 100644 --- a/Units/parser-elm.r/elm-expressions.d/args.ctags +++ b/Units/parser-elm.r/elm-expressions.d/args.ctags @@ -1,3 +1,3 @@ --sort=no --extras=+r ---fields=+rS +--fields=+r diff --git a/Units/parser-elm.r/elm-functions.d/args.ctags b/Units/parser-elm.r/elm-functions.d/args.ctags index 405ad9b9ff..41f6dbed62 100644 --- a/Units/parser-elm.r/elm-functions.d/args.ctags +++ b/Units/parser-elm.r/elm-functions.d/args.ctags @@ -1,3 +1,3 @@ --sort=no --extras=+r ---fields=+rS +--fields=+r diff --git a/Units/parser-elm.r/elm-functions.d/input.elm b/Units/parser-elm.r/elm-functions.d/input.elm index 513647165b..e52dfc20d9 100644 --- a/Units/parser-elm.r/elm-functions.d/input.elm +++ b/Units/parser-elm.r/elm-functions.d/input.elm @@ -11,7 +11,7 @@ funcB b = funcC = 2 + 1 --- Function with whitespace - ideally this will be stripped in the signature +-- Function with whitespace - ideally this will be stripped in the type description funcD d1 d2 = d1 + d2 diff --git a/Units/parser-elm.r/elm-if-then-else.d/args.ctags b/Units/parser-elm.r/elm-if-then-else.d/args.ctags index 405ad9b9ff..41f6dbed62 100644 --- a/Units/parser-elm.r/elm-if-then-else.d/args.ctags +++ b/Units/parser-elm.r/elm-if-then-else.d/args.ctags @@ -1,3 +1,3 @@ --sort=no --extras=+r ---fields=+rS +--fields=+r diff --git a/Units/parser-elm.r/elm-imports.d/args.ctags b/Units/parser-elm.r/elm-imports.d/args.ctags index 41f6dbed62..0616e13069 100644 --- a/Units/parser-elm.r/elm-imports.d/args.ctags +++ b/Units/parser-elm.r/elm-imports.d/args.ctags @@ -1,3 +1,3 @@ --sort=no --extras=+r ---fields=+r +--fields=+r-t diff --git a/Units/parser-elm.r/elm-let-in.d/args.ctags b/Units/parser-elm.r/elm-let-in.d/args.ctags index 405ad9b9ff..41f6dbed62 100644 --- a/Units/parser-elm.r/elm-let-in.d/args.ctags +++ b/Units/parser-elm.r/elm-let-in.d/args.ctags @@ -1,3 +1,3 @@ --sort=no --extras=+r ---fields=+rS +--fields=+r diff --git a/Units/parser-elm.r/elm-multiline-strings.d/args.ctags b/Units/parser-elm.r/elm-multiline-strings.d/args.ctags index 405ad9b9ff..41f6dbed62 100644 --- a/Units/parser-elm.r/elm-multiline-strings.d/args.ctags +++ b/Units/parser-elm.r/elm-multiline-strings.d/args.ctags @@ -1,3 +1,3 @@ --sort=no --extras=+r ---fields=+rS +--fields=+r diff --git a/Units/parser-elm.r/elm-optlist-compatibility.d/args.ctags b/Units/parser-elm.r/elm-optlist-compatibility.d/args.ctags index a4ff198709..c81d3ab95a 100644 --- a/Units/parser-elm.r/elm-optlist-compatibility.d/args.ctags +++ b/Units/parser-elm.r/elm-optlist-compatibility.d/args.ctags @@ -1,3 +1,3 @@ --sort=no ---fields=+r +--fields=+r-t --extras=+r diff --git a/Units/parser-elm.r/elm-parameter-patterns.d/args.ctags b/Units/parser-elm.r/elm-parameter-patterns.d/args.ctags index 405ad9b9ff..41f6dbed62 100644 --- a/Units/parser-elm.r/elm-parameter-patterns.d/args.ctags +++ b/Units/parser-elm.r/elm-parameter-patterns.d/args.ctags @@ -1,3 +1,3 @@ --sort=no --extras=+r ---fields=+rS +--fields=+r diff --git a/Units/parser-elm.r/elm-ports.d/args.ctags b/Units/parser-elm.r/elm-ports.d/args.ctags index 405ad9b9ff..41f6dbed62 100644 --- a/Units/parser-elm.r/elm-ports.d/args.ctags +++ b/Units/parser-elm.r/elm-ports.d/args.ctags @@ -1,3 +1,3 @@ --sort=no --extras=+r ---fields=+rS +--fields=+r diff --git a/Units/parser-elm.r/elm-ports.d/expected.tags b/Units/parser-elm.r/elm-ports.d/expected.tags index e1d99b5c08..1cbd89d933 100644 --- a/Units/parser-elm.r/elm-ports.d/expected.tags +++ b/Units/parser-elm.r/elm-ports.d/expected.tags @@ -1,3 +1,3 @@ Main input.elm /^port module Main exposing (..)$/;" m roles:def -outgoing input.elm /^port outgoing : Enc.Value -> Cmd msg$/;" p module:Main signature:Enc.Value -> Cmd msg roles:def -incoming input.elm /^port incoming : (Enc.Value -> msg) -> Sub msg$/;" p module:Main signature:(Enc.Value -> msg) -> Sub msg roles:def +outgoing input.elm /^port outgoing : Enc.Value -> Cmd msg$/;" p module:Main typeref:description:Enc.Value -> Cmd msg roles:def +incoming input.elm /^port incoming : (Enc.Value -> msg) -> Sub msg$/;" p module:Main typeref:description:(Enc.Value -> msg) -> Sub msg roles:def diff --git a/Units/parser-elm.r/elm-signatures.d/expected.tags b/Units/parser-elm.r/elm-signatures.d/expected.tags deleted file mode 100644 index d28a1da961..0000000000 --- a/Units/parser-elm.r/elm-signatures.d/expected.tags +++ /dev/null @@ -1,9 +0,0 @@ -funcA input.elm /^funcA a = 1$/;" f signature:Int -> Float -> Float roles:def -funcB input.elm /^funcB b =$/;" f signature:String -> Float roles:def -funcC input.elm /^funcC c = 3$/;" f signature:Int -> {c: String} roles:def -funcD input.elm /^funcD = 4$/;" f signature:(Int, Int) -> String roles:def -funcE input.elm /^funcE = 5$/;" f signature:Float -> (Int -> Int -> Int -> String) roles:def -funcF input.elm /^funcF = 6$/;" f signature:String -> {- Old ->-} Int roles:def -funcG input.elm /^funcG = 7$/;" f signature:G.Int -> G.Other roles:def -funcH input.elm /^funcH h =$/;" f signature:Int -> Int roles:def -h2 input.elm /^ h2 = 34$/;" f function:funcH roles:def diff --git a/Units/parser-elm.r/elm-single-expressions.d/args.ctags b/Units/parser-elm.r/elm-single-expressions.d/args.ctags index 405ad9b9ff..41f6dbed62 100644 --- a/Units/parser-elm.r/elm-single-expressions.d/args.ctags +++ b/Units/parser-elm.r/elm-single-expressions.d/args.ctags @@ -1,3 +1,3 @@ --sort=no --extras=+r ---fields=+rS +--fields=+r diff --git a/Units/parser-elm.r/elm-signatures.d/args.ctags b/Units/parser-elm.r/elm-type-annotations.d/args.ctags similarity index 62% rename from Units/parser-elm.r/elm-signatures.d/args.ctags rename to Units/parser-elm.r/elm-type-annotations.d/args.ctags index 405ad9b9ff..41f6dbed62 100644 --- a/Units/parser-elm.r/elm-signatures.d/args.ctags +++ b/Units/parser-elm.r/elm-type-annotations.d/args.ctags @@ -1,3 +1,3 @@ --sort=no --extras=+r ---fields=+rS +--fields=+r diff --git a/Units/parser-elm.r/elm-type-annotations.d/expected.tags b/Units/parser-elm.r/elm-type-annotations.d/expected.tags new file mode 100644 index 0000000000..070821d2fc --- /dev/null +++ b/Units/parser-elm.r/elm-type-annotations.d/expected.tags @@ -0,0 +1,9 @@ +funcA input.elm /^funcA a = 1$/;" f typeref:description:Int -> Float -> Float roles:def +funcB input.elm /^funcB b =$/;" f typeref:description:String -> Float roles:def +funcC input.elm /^funcC c = 3$/;" f typeref:description:Int -> {c: String} roles:def +funcD input.elm /^funcD = 4$/;" f typeref:description:(Int, Int) -> String roles:def +funcE input.elm /^funcE = 5$/;" f typeref:description:Float -> (Int -> Int -> Int -> String) roles:def +funcF input.elm /^funcF = 6$/;" f typeref:description:String -> {- Old ->-} Int roles:def +funcG input.elm /^funcG = 7$/;" f typeref:description:G.Int -> G.Other roles:def +funcH input.elm /^funcH h =$/;" f typeref:description:Int -> Int roles:def +h2 input.elm /^ h2 = 34$/;" f function:funcH roles:def diff --git a/Units/parser-elm.r/elm-signatures.d/input.elm b/Units/parser-elm.r/elm-type-annotations.d/input.elm similarity index 62% rename from Units/parser-elm.r/elm-signatures.d/input.elm rename to Units/parser-elm.r/elm-type-annotations.d/input.elm index fc1fd37d23..2b076258fb 100644 --- a/Units/parser-elm.r/elm-signatures.d/input.elm +++ b/Units/parser-elm.r/elm-type-annotations.d/input.elm @@ -1,9 +1,9 @@ --- Simple function with a signature +-- Simple function with a type annotation funcA : Int -> Float -> Float funcA a = 1 --- Signature over multiple lines +-- Type annotation over multiple lines funcB : String -> @@ -11,30 +11,30 @@ funcB : funcB b = b + 1 --- Function with a record in the signature +-- Function with a record in the type annotation funcC : Int -> {c: String} funcC c = 3 --- Function with a tuple in the signature +-- Function with a tuple in the type annotation funcD : (Int, Int) -> String funcD = 4 --- Functions in the signature +-- Functions in the type annotation funcE : Float -> (Int -> Int -> Int -> String) funcE = 5 --- Comments in the signature +-- Comments in the type annotation funcF : -- Comment String -> {- Old ->-} Int {-- End--} funcF = 6 --- Dotted types in the signature +-- Dotted types in the type annotation funcG : G.Int -> G.Other funcG = 7 diff --git a/Units/parser-elm.r/elm-types.d/args.ctags b/Units/parser-elm.r/elm-types.d/args.ctags index 41f6dbed62..0616e13069 100644 --- a/Units/parser-elm.r/elm-types.d/args.ctags +++ b/Units/parser-elm.r/elm-types.d/args.ctags @@ -1,3 +1,3 @@ --sort=no --extras=+r ---fields=+r +--fields=+r-t diff --git a/docs/man/ctags-lang-elm.7.rst b/docs/man/ctags-lang-elm.7.rst index 4828886d02..e87c89eedf 100644 --- a/docs/man/ctags-lang-elm.7.rst +++ b/docs/man/ctags-lang-elm.7.rst @@ -80,10 +80,10 @@ with "--sort=no --extras=+r --fields=+r" MyImport input.elm /^import MyImport as NSpace exposing (impFunc)$/;" m roles:imported impFunc input.elm /^import MyImport as NSpace exposing (impFunc)$/;" f module:MyImport roles:imported -Signatures +Type descriptions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Constructors will have signatures. So will any top level function +Constructors will have type descriptions. So will any top level function that has a type annotation. .. code-block:: Elm @@ -100,15 +100,15 @@ that has a type annotation. | B3Cons "output.tags" -with "--sort=no --extras=+r --fields=+rS" +with "--sort=no --extras=+r --fields=+r" .. code-block:: tags - funcA input.elm /^funcA a = a + 1$/;" f signature:Int -> Int roles:def + funcA input.elm /^funcA a = a + 1$/;" f typeref:description:Int -> Int roles:def B input.elm /^type B$/;" t roles:def - B3Cons input.elm /^ | B3Cons$/;" c type:B signature: roles:def - B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B signature:String Integer roles:def - B1Cons input.elm /^ = B1Cons$/;" c type:B signature:{ x : Float , y : Float } roles:def + B3Cons input.elm /^ | B3Cons$/;" c type:B typeref:description: roles:def + B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B typeref:description:String Integer roles:def + B1Cons input.elm /^ = B1Cons$/;" c type:B typeref:description:{ x : Float , y : Float } roles:def KNOWN LIMITATIONS ----------------- @@ -122,7 +122,7 @@ Sometimes functions in let/in blocks will be omitted. Functions in let/in blocks will be marked as being in the scope of their outer function, regardless of how deeply nested the let/in block is. -Functions in let/in blocks won't have signatures. +Functions in let/in blocks won't have type descriptions. SEE ALSO -------- diff --git a/man/ctags-lang-elm.7.rst.in b/man/ctags-lang-elm.7.rst.in index 6455ea12fd..44f9f55bfe 100644 --- a/man/ctags-lang-elm.7.rst.in +++ b/man/ctags-lang-elm.7.rst.in @@ -80,10 +80,10 @@ with "--sort=no --extras=+r --fields=+r" MyImport input.elm /^import MyImport as NSpace exposing (impFunc)$/;" m roles:imported impFunc input.elm /^import MyImport as NSpace exposing (impFunc)$/;" f module:MyImport roles:imported -Signatures +Type descriptions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Constructors will have signatures. So will any top level function +Constructors will have type descriptions. So will any top level function that has a type annotation. .. code-block:: Elm @@ -100,15 +100,15 @@ that has a type annotation. | B3Cons "output.tags" -with "--sort=no --extras=+r --fields=+rS" +with "--sort=no --extras=+r --fields=+r" .. code-block:: tags - funcA input.elm /^funcA a = a + 1$/;" f signature:Int -> Int roles:def + funcA input.elm /^funcA a = a + 1$/;" f typeref:description:Int -> Int roles:def B input.elm /^type B$/;" t roles:def - B3Cons input.elm /^ | B3Cons$/;" c type:B signature: roles:def - B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B signature:String Integer roles:def - B1Cons input.elm /^ = B1Cons$/;" c type:B signature:{ x : Float , y : Float } roles:def + B3Cons input.elm /^ | B3Cons$/;" c type:B typeref:description: roles:def + B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B typeref:description:String Integer roles:def + B1Cons input.elm /^ = B1Cons$/;" c type:B typeref:description:{ x : Float , y : Float } roles:def KNOWN LIMITATIONS ----------------- @@ -122,7 +122,7 @@ Sometimes functions in let/in blocks will be omitted. Functions in let/in blocks will be marked as being in the scope of their outer function, regardless of how deeply nested the let/in block is. -Functions in let/in blocks won't have signatures. +Functions in let/in blocks won't have type descriptions. SEE ALSO -------- diff --git a/peg/elm.peg b/peg/elm.peg index e082023d2e..ea4578e53c 100644 --- a/peg/elm.peg +++ b/peg/elm.peg @@ -26,7 +26,8 @@ # - function: This function is in the scope of function , which # may be dotted. Eg Main.myFunc. # - module: This is in the scope of module . -# - signature: This function, constructor or port has signature . +# - typeref:description: This function, constructor or port +# has type . # - moduleName: This namespace has original module name . # # Functions defined in let/in blocks may be tagged, with these limitations: @@ -42,7 +43,8 @@ # Maybe do: # - let/in blocks # - Allow tuples on the LHS. Eg '(val1, val2) = valFunc'. -# - Inner functions' type annotations are used in the function's signature. +# - Inner functions' type annotations are used in the function's +# type description. # - Inner functions can have more complex parameters. # - Functions # - Allow non-Latin upper and lower case. Use @@ -176,7 +178,7 @@ typeParameterList <- lowerStartIdentifier (_1_ lowerStartIdentifier)* constructorList <- _0_ ? _0_ ('|' _0_ constructorList)? { int r = makeElmTag(auxil, $1, $1s, K_CONSTRUCTOR, ROLE_DEFINITION_INDEX); - addElmSignature(r, $2); + addElmTypeRef(r, $2); } constructorTypes <- singleTypeSpec (_0_ constructorTypes)* @@ -212,7 +214,7 @@ functionTypeSpec <- portDeclaration <- 'port' _1_ _0_ ':' _0_ EOS { int r = makeElmTag(auxil, $1, $1s, K_PORT, ROLE_DEFINITION_INDEX); - addElmSignature(r, $2); + addElmTypeRef(r, $2); } # Import statement @@ -287,7 +289,7 @@ functionWithTypeAnnotation <- _0_ ':' _0_ TLSS <$1> _1_ { int r = makeElmTagSettingScope(auxil, $3, $3s, K_FUNCTION, ROLE_DEFINITION_INDEX); - addElmSignature(r, $2); + addElmTypeRef(r, $2); } functionParameterList? _0_ '=' _0_ expression EOS { POP_SCOPE(auxil); diff --git a/peg/elm_post.h b/peg/elm_post.h index 512ec9c42f..5970a6a398 100644 --- a/peg/elm_post.h +++ b/peg/elm_post.h @@ -61,14 +61,16 @@ static int makeElmTagSettingScope (struct parserCtx *auxil, const char *name, lo return scope_index; } -static void addElmSignature(int scope_index, const char *sig) +static void addElmTypeRef(int scope_index, const char *sig) { tagEntryInfo *e = getEntryInCorkQueue (scope_index); if (e) { vString *vsig = collapseWhitespace (sig); - e->extensionFields.signature = vStringDeleteUnwrap (vsig); + + e->extensionFields.typeRef [0] = eStrdup ("description"); + e->extensionFields.typeRef [1] = vStringDeleteUnwrap (vsig); } } diff --git a/peg/elm_pre.h b/peg/elm_pre.h index 6951a6b016..e8352badb5 100644 --- a/peg/elm_pre.h +++ b/peg/elm_pre.h @@ -98,5 +98,5 @@ struct parserCtx { #define USE_KIND_STACK KIND_GHOST_INDEX static int makeElmTag (struct parserCtx *auxil, const char *name, long offset, int kind, int role); static int makeElmTagSettingScope (struct parserCtx *auxil, const char *name, long offset, int kind, int role); -static void addElmSignature(int scope_index, const char *str); +static void addElmTypeRef(int scope_index, const char *str); static vString *collapseWhitespace (const char *sig); From de6000963eb5a66999dca4c50285f52fd4700ebf Mon Sep 17 00:00:00 2001 From: Nik Silver Date: Sun, 27 Mar 2022 10:22:08 +0100 Subject: [PATCH 09/11] Elm: Typerefs for constructors correctly include arrows. --- .../elm-complex-types.d/expected.tags | 12 ++--- .../expected.tags | 6 +-- .../elm-optlist-compatibility.d/expected.tags | 4 +- Units/parser-elm.r/elm-types.d/expected.tags | 12 ++--- docs/man/ctags-lang-elm.7.rst | 4 +- man/ctags-lang-elm.7.rst.in | 4 +- peg/elm.peg | 48 ++++++++++++++++--- peg/elm_post.h | 37 ++++++++++++++ peg/elm_pre.h | 7 +++ 9 files changed, 107 insertions(+), 27 deletions(-) diff --git a/Units/parser-elm.r/elm-complex-types.d/expected.tags b/Units/parser-elm.r/elm-complex-types.d/expected.tags index e38d67da2a..5480df9e6d 100644 --- a/Units/parser-elm.r/elm-complex-types.d/expected.tags +++ b/Units/parser-elm.r/elm-complex-types.d/expected.tags @@ -1,20 +1,20 @@ A input.elm /^type A = ACons { x : Float, y : Float }$/;" t roles:def ACons input.elm /^type A = ACons { x : Float, y : Float }$/;" c type:A roles:def B input.elm /^type B$/;" t roles:def -B3Cons input.elm /^ | B3Cons$/;" c type:B roles:def -B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B roles:def B1Cons input.elm /^ = B1Cons$/;" c type:B roles:def +B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B roles:def +B3Cons input.elm /^ | B3Cons$/;" c type:B roles:def C input.elm /^type C=CCons{x:Float,y:Float}$/;" t roles:def CCons input.elm /^type C=CCons{x:Float,y:Float}$/;" c type:C roles:def D input.elm /^type D = DCons (String, Float, {x:String, y:Float})$/;" t roles:def DCons input.elm /^type D = DCons (String, Float, {x:String, y:Float})$/;" c type:D roles:def E input.elm /^type E$/;" t roles:def -E2Cons input.elm /^ | E2Cons ()$/;" c type:E roles:def E1Cons input.elm /^ = E1Cons {}$/;" c type:E roles:def +E2Cons input.elm /^ | E2Cons ()$/;" c type:E roles:def F input.elm /^type F$/;" t roles:def -F3Cons input.elm /^ | F3Cons$/;" c type:F roles:def -F2Cons input.elm /^ | F2Cons (Float -> String -> (String -> {x:Float, y:Float}))$/;" c type:F roles:def F1Cons input.elm /^ = F1Cons (String -> Int)$/;" c type:F roles:def +F2Cons input.elm /^ | F2Cons (Float -> String -> (String -> {x:Float, y:Float}))$/;" c type:F roles:def +F3Cons input.elm /^ | F3Cons$/;" c type:F roles:def G input.elm /^type G a$/;" t roles:def -G2Cons input.elm /^ | G2Cons { a | name : String}$/;" c type:G roles:def G1Cons input.elm /^ = G1Cons a Int$/;" c type:G roles:def +G2Cons input.elm /^ | G2Cons { a | name : String}$/;" c type:G roles:def diff --git a/Units/parser-elm.r/elm-constructor-signatures.d/expected.tags b/Units/parser-elm.r/elm-constructor-signatures.d/expected.tags index 0b466e2262..0e6efedf98 100644 --- a/Units/parser-elm.r/elm-constructor-signatures.d/expected.tags +++ b/Units/parser-elm.r/elm-constructor-signatures.d/expected.tags @@ -1,4 +1,4 @@ B input.elm /^type B$/;" t roles:def -B3Cons input.elm /^ | B3Cons$/;" c type:B typeref:description: roles:def -B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B typeref:description:String Integer roles:def -B1Cons input.elm /^ = B1Cons$/;" c type:B typeref:description:{ x : Float , y : Float } roles:def +B1Cons input.elm /^ = B1Cons$/;" c type:B typeref:description:{ x : Float , y : Float } -> B roles:def +B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B typeref:description:String -> Integer -> B roles:def +B3Cons input.elm /^ | B3Cons$/;" c type:B typeref:description:B roles:def diff --git a/Units/parser-elm.r/elm-optlist-compatibility.d/expected.tags b/Units/parser-elm.r/elm-optlist-compatibility.d/expected.tags index 3b5700d11a..c5126b0bee 100644 --- a/Units/parser-elm.r/elm-optlist-compatibility.d/expected.tags +++ b/Units/parser-elm.r/elm-optlist-compatibility.d/expected.tags @@ -5,11 +5,11 @@ withDefault input.elm /^import Maybe exposing (withDefault)$/;" f module:Maybe r Je input.elm /^import Json.Encode as Je$/;" n module:Main roles:def moduleName:Json.Encode Json.Encode input.elm /^import Json.Encode as Je$/;" m roles:imported Thing input.elm /^type Thing$/;" t module:Main roles:def -Two input.elm /^ | Two Int$/;" c type:Main.Thing roles:def One input.elm /^ = One$/;" c type:Main.Thing roles:def +Two input.elm /^ | Two Int$/;" c type:Main.Thing roles:def Param input.elm /^type Param a$/;" t module:Main roles:def -Other input.elm /^ | Other a$/;" c type:Main.Param roles:def Cons input.elm /^ = Cons a$/;" c type:Main.Param roles:def +Other input.elm /^ | Other a$/;" c type:Main.Param roles:def Num input.elm /^type alias Num =$/;" a module:Main roles:def outward input.elm /^port outward : String -> Cmd a$/;" p module:Main roles:def inward input.elm /^port inward : (b -> a) -> Sub a$/;" p module:Main roles:def diff --git a/Units/parser-elm.r/elm-types.d/expected.tags b/Units/parser-elm.r/elm-types.d/expected.tags index d3befc2406..e6a982920e 100644 --- a/Units/parser-elm.r/elm-types.d/expected.tags +++ b/Units/parser-elm.r/elm-types.d/expected.tags @@ -1,20 +1,20 @@ Apple input.elm /^type Apple = Cox | Braeburn$/;" t roles:def -Braeburn input.elm /^type Apple = Cox | Braeburn$/;" c type:Apple roles:def Cox input.elm /^type Apple = Cox | Braeburn$/;" c type:Apple roles:def +Braeburn input.elm /^type Apple = Cox | Braeburn$/;" c type:Apple roles:def Box input.elm /^type Box a = Cardboard a | Wooden$/;" t roles:def -Wooden input.elm /^type Box a = Cardboard a | Wooden$/;" c type:Box roles:def Cardboard input.elm /^type Box a = Cardboard a | Wooden$/;" c type:Box roles:def +Wooden input.elm /^type Box a = Cardboard a | Wooden$/;" c type:Box roles:def Clog input.elm /^type Clog a b = Dutch | English$/;" t roles:def -English input.elm /^type Clog a b = Dutch | English$/;" c type:Clog roles:def Dutch input.elm /^type Clog a b = Dutch | English$/;" c type:Clog roles:def +English input.elm /^type Clog a b = Dutch | English$/;" c type:Clog roles:def DType input.elm /^type DType$/;" t roles:def -D2Cons input.elm /^ | D2Cons Float Float Clog$/;" c type:DType roles:def D1Cons input.elm /^ = D1Cons { x : String, y:Maybe Int}$/;" c type:DType roles:def +D2Cons input.elm /^ | D2Cons Float Float Clog$/;" c type:DType roles:def TypesTwo input-1.elm /^module TypesTwo exposing (..)$/;" m roles:def T2a input-1.elm /^type T2a = T2a_1 | T2a_2$/;" t module:TypesTwo roles:def -T2a_2 input-1.elm /^type T2a = T2a_1 | T2a_2$/;" c type:TypesTwo.T2a roles:def T2a_1 input-1.elm /^type T2a = T2a_1 | T2a_2$/;" c type:TypesTwo.T2a roles:def +T2a_2 input-1.elm /^type T2a = T2a_1 | T2a_2$/;" c type:TypesTwo.T2a roles:def funcT2 input-1.elm /^funcT2 = "T2"$/;" f module:TypesTwo roles:def T2b input-1.elm /^type T2b = T2b_1 | T2b_2$/;" t module:TypesTwo roles:def -T2b_2 input-1.elm /^type T2b = T2b_1 | T2b_2$/;" c type:TypesTwo.T2b roles:def T2b_1 input-1.elm /^type T2b = T2b_1 | T2b_2$/;" c type:TypesTwo.T2b roles:def +T2b_2 input-1.elm /^type T2b = T2b_1 | T2b_2$/;" c type:TypesTwo.T2b roles:def diff --git a/docs/man/ctags-lang-elm.7.rst b/docs/man/ctags-lang-elm.7.rst index e87c89eedf..ec2755a66d 100644 --- a/docs/man/ctags-lang-elm.7.rst +++ b/docs/man/ctags-lang-elm.7.rst @@ -107,8 +107,8 @@ with "--sort=no --extras=+r --fields=+r" funcA input.elm /^funcA a = a + 1$/;" f typeref:description:Int -> Int roles:def B input.elm /^type B$/;" t roles:def B3Cons input.elm /^ | B3Cons$/;" c type:B typeref:description: roles:def - B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B typeref:description:String Integer roles:def - B1Cons input.elm /^ = B1Cons$/;" c type:B typeref:description:{ x : Float , y : Float } roles:def + B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B typeref:description:String -> Integer -> B roles:def + B1Cons input.elm /^ = B1Cons$/;" c type:B typeref:description:{ x : Float , y : Float } -> B roles:def KNOWN LIMITATIONS ----------------- diff --git a/man/ctags-lang-elm.7.rst.in b/man/ctags-lang-elm.7.rst.in index 44f9f55bfe..8c9f785303 100644 --- a/man/ctags-lang-elm.7.rst.in +++ b/man/ctags-lang-elm.7.rst.in @@ -107,8 +107,8 @@ with "--sort=no --extras=+r --fields=+r" funcA input.elm /^funcA a = a + 1$/;" f typeref:description:Int -> Int roles:def B input.elm /^type B$/;" t roles:def B3Cons input.elm /^ | B3Cons$/;" c type:B typeref:description: roles:def - B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B typeref:description:String Integer roles:def - B1Cons input.elm /^ = B1Cons$/;" c type:B typeref:description:{ x : Float , y : Float } roles:def + B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B typeref:description:String -> Integer -> B roles:def + B1Cons input.elm /^ = B1Cons$/;" c type:B typeref:description:{ x : Float , y : Float } -> B roles:def KNOWN LIMITATIONS ----------------- diff --git a/peg/elm.peg b/peg/elm.peg index ea4578e53c..1296f82c63 100644 --- a/peg/elm.peg +++ b/peg/elm.peg @@ -160,28 +160,64 @@ typeAlias <- # Custom type # # Includes type parameters, such as 'x' in 'type MyType x = Wrap x'. +# +# In a definition such as 'type MyType = Cons1 String Int' we +# capture 'MyType', and then for each type in each constructor +# subtype (here, 'String' and 'Int') we append a '->' and finally +# concatentate them all to get the constructor's type description, +# such as 'String -> Int -> MyType' customType <- 'type' _1_ (_0_ typeParameterList)? _0_ '=' _0_ { + initElmConstructorFields(auxil, $1); makeElmTagSettingScope(auxil, $1, $1s, K_TYPE, ROLE_DEFINITION_INDEX); } constructorList EOS { POP_SCOPE(auxil); + tidyElmConstructorFields(auxil); } typeParameterList <- lowerStartIdentifier (_1_ lowerStartIdentifier)* # A type could be defined as a constructor list: # type A = Cons1 String | Cons2 Float Float | ... -# The 'String' and the 'Float Float' etc are the constructor types. +# The 'String' and the 'Float Float' etc are the constructor subtypes. # Each 'String', 'Float', etc is a single type spec. # But a single type spec could also be a record, a tuple or a function spec. - -constructorList <- _0_ ? _0_ ('|' _0_ constructorList)? { +# +# Subtypes in constructors need to be parsed differently from types in +# type annotations and record fields. Consider these: +# type A1Type a b = A1Cons a b -- Line 1 +# type A2Type a b = A2Cons String a b -- Line 2 +# type BType a b = BCons { x : A2Type a b} -- Line 3 +# cFunc : A1Type String Int -> String -- Line 4 +# In line 1, 'a b' must be parsed as two individual types (parameterised). +# In line 2, 'String a b' must be parsed as three individual types. +# In line 3, 'A2Type a b' must be parsed as one type, even though it's +# lexically equivalent to 'String a b' on line 2. +# In line 4, 'A1Type String Int' must also be parsed one type. +# This means we have to have slightly different rules for parsing a +# constructor's subtypes as from other cases. The first case is handled +# by constructorSubtypeList and singleConstructorSubtypeSpec. The second +# case is handled by singleTypeSpec. + +constructorList <- { + initElmConstructorSubtypeFields(auxil); + } _0_ ? { int r = makeElmTag(auxil, $1, $1s, K_CONSTRUCTOR, ROLE_DEFINITION_INDEX); - addElmTypeRef(r, $2); -} + addElmConstructorTypeRef(auxil, r); + } _0_ ('|' _0_ constructorList)? + +constructorSubtypeList <- singleConstructorSubtypeSpec (_0_ singleConstructorSubtypeSpec)* -constructorTypes <- singleTypeSpec (_0_ constructorTypes)* +singleConstructorSubtypeSpec <- + < recordTypeSpec + / tupleTypeSpec + / functionTypeSpec + / dottedIdentifier + > + { + addElmConstructorSubtype(auxil, $1); + } singleTypeSpec <- recordTypeSpec diff --git a/peg/elm_post.h b/peg/elm_post.h index 5970a6a398..0fab2a567d 100644 --- a/peg/elm_post.h +++ b/peg/elm_post.h @@ -74,6 +74,43 @@ static void addElmTypeRef(int scope_index, const char *sig) } } +/* There are several steps to making the type of constructors within + * a custom type: + * 1. Initialise the fields when we encounter the custom type declaration. + * 2. Initialise the subtype field (do this for each new constructor). + * 3. Add each subtype as we find it. + * 4. Make the typeref field. + * 5. Tidy up + */ +static void initElmConstructorFields (struct parserCtx *auxil, const char *name) +{ + auxil->customType = vStringNewInit (name); + auxil->consSubtype = vStringNew (); +} + +static void initElmConstructorSubtypeFields (struct parserCtx *auxil) +{ + vStringClear (auxil->consSubtype); +} + +static void addElmConstructorSubtype (struct parserCtx *auxil, const char *name) +{ + vStringCatS (auxil->consSubtype, name); + vStringCatS (auxil->consSubtype, " -> "); +} + +static void addElmConstructorTypeRef (struct parserCtx *auxil, int tag_index) +{ + vStringCat (auxil->consSubtype, auxil->customType); + addElmTypeRef (tag_index, vStringValue (auxil->consSubtype)); +} + +static void tidyElmConstructorFields (struct parserCtx *auxil) +{ + vStringDelete (auxil->consSubtype); + vStringDelete (auxil->customType); +} + /* For a signature such as "a1 b2 c3" we want to transform it * to "a1 b2 c3" for the signature field. */ diff --git a/peg/elm_pre.h b/peg/elm_pre.h index e8352badb5..2d52458ec4 100644 --- a/peg/elm_pre.h +++ b/peg/elm_pre.h @@ -90,6 +90,8 @@ static kindDefinition ElmKinds [COUNT_KINDS] = { struct parserCtx { struct parserBaseCtx base; + vString *customType; + vString *consSubtype; }; /* @@ -99,4 +101,9 @@ struct parserCtx { static int makeElmTag (struct parserCtx *auxil, const char *name, long offset, int kind, int role); static int makeElmTagSettingScope (struct parserCtx *auxil, const char *name, long offset, int kind, int role); static void addElmTypeRef(int scope_index, const char *str); +static void initElmConstructorFields (struct parserCtx *auxil, const char *name); +static void initElmConstructorSubtypeFields (struct parserCtx *auxil); +static void addElmConstructorSubtype (struct parserCtx *auxil, const char *name); +static void addElmConstructorTypeRef (struct parserCtx *auxil, int tag_index); +static void tidyElmConstructorFields (struct parserCtx *auxil); static vString *collapseWhitespace (const char *sig); From b26f90f69fc93f508c5e05cd6c1b3c7e58ff0ace Mon Sep 17 00:00:00 2001 From: Nik Silver Date: Sun, 27 Mar 2022 14:43:40 +0100 Subject: [PATCH 10/11] Elm: Function parameters appear as ctags signature. --- .../elm-parameter-capture.d/args.ctags | 3 ++ .../elm-parameter-capture.d/expected.tags | 7 ++++ .../elm-parameter-capture.d/input.elm | 33 +++++++++++++++++++ docs/man/ctags-lang-elm.7.rst | 23 +++++++++++++ man/ctags-lang-elm.7.rst.in | 23 +++++++++++++ peg/elm.peg | 22 ++++++++----- peg/elm_post.h | 12 +++++++ peg/elm_pre.h | 1 + 8 files changed, 115 insertions(+), 9 deletions(-) create mode 100644 Units/parser-elm.r/elm-parameter-capture.d/args.ctags create mode 100644 Units/parser-elm.r/elm-parameter-capture.d/expected.tags create mode 100644 Units/parser-elm.r/elm-parameter-capture.d/input.elm diff --git a/Units/parser-elm.r/elm-parameter-capture.d/args.ctags b/Units/parser-elm.r/elm-parameter-capture.d/args.ctags new file mode 100644 index 0000000000..405ad9b9ff --- /dev/null +++ b/Units/parser-elm.r/elm-parameter-capture.d/args.ctags @@ -0,0 +1,3 @@ +--sort=no +--extras=+r +--fields=+rS diff --git a/Units/parser-elm.r/elm-parameter-capture.d/expected.tags b/Units/parser-elm.r/elm-parameter-capture.d/expected.tags new file mode 100644 index 0000000000..ece916c1c1 --- /dev/null +++ b/Units/parser-elm.r/elm-parameter-capture.d/expected.tags @@ -0,0 +1,7 @@ +funcA input.elm /^funcA a1 a2 =$/;" f signature:a1 a2 roles:def +funcB input.elm /^funcB b1$/;" f typeref:description:Int -> Int -> Int signature:b1 b2 roles:def +funcC input.elm /^funcC (c1, c2) {c3} (C4Cons c4 c5) =$/;" f signature:(c1, c2) {c3} (C4Cons c4 c5) roles:def +funcD input.elm /^funcD = 4$/;" f signature: roles:def +funcE input.elm /^funcE=5$/;" f signature: roles:def +funcF1 input.elm /^funcF1 =$/;" f signature: roles:def +funcF2 input.elm /^ funcF2 f1 f2 = 6$/;" f function:funcF1 signature:f1 f2 roles:def diff --git a/Units/parser-elm.r/elm-parameter-capture.d/input.elm b/Units/parser-elm.r/elm-parameter-capture.d/input.elm new file mode 100644 index 0000000000..44562f83ed --- /dev/null +++ b/Units/parser-elm.r/elm-parameter-capture.d/input.elm @@ -0,0 +1,33 @@ +-- Simple paramaeters + +funcA a1 a2 = + a1 + a2 + +-- With extra whitespace and type annotation + +funcB : Int -> Int -> Int +funcB b1 + b2 + = + b1 + b2 + +-- Complex parameters + +funcC (c1, c2) {c3} (C4Cons c4 c5) = + c1 + c2 + +-- No parameters + +funcD = 4 + +-- No whitespace + +funcE=5 + +-- Functions inside let/in block + +funcF1 = + let + funcF2 f1 f2 = 6 + in + 6 diff --git a/docs/man/ctags-lang-elm.7.rst b/docs/man/ctags-lang-elm.7.rst index ec2755a66d..7ba8fee38b 100644 --- a/docs/man/ctags-lang-elm.7.rst +++ b/docs/man/ctags-lang-elm.7.rst @@ -110,8 +110,31 @@ with "--sort=no --extras=+r --fields=+r" B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B typeref:description:String -> Integer -> B roles:def B1Cons input.elm /^ = B1Cons$/;" c type:B typeref:description:{ x : Float , y : Float } -> B roles:def +Function parameter lists +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Function parameter lists can be extracted into the tags file +signature field. They are not really function signatures, but +it's the closest concept available in ctags. +Use "--fields=+S". + +.. code-block:: Elm + + funcA a1 a2 = + a1 + a2 + +"output.tags" +with "--sort=no --extras=+r --fields=+rS" + +.. code-block:: tags + + funcA input.elm /^funcA a1 a2 =$/;" f signature:a1 a2 roles:def + KNOWN LIMITATIONS ----------------- +The ctags signature field is used for function parameter lists, even +though it's not an idea field. See above. + Elm requires all statements at the same logical level to have the same indentation. If there is additional indentation that line is part of the previous one. Therefore without over-complicating the diff --git a/man/ctags-lang-elm.7.rst.in b/man/ctags-lang-elm.7.rst.in index 8c9f785303..7c3c584033 100644 --- a/man/ctags-lang-elm.7.rst.in +++ b/man/ctags-lang-elm.7.rst.in @@ -110,8 +110,31 @@ with "--sort=no --extras=+r --fields=+r" B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B typeref:description:String -> Integer -> B roles:def B1Cons input.elm /^ = B1Cons$/;" c type:B typeref:description:{ x : Float , y : Float } -> B roles:def +Function parameter lists +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Function parameter lists can be extracted into the tags file +signature field. They are not really function signatures, but +it's the closest concept available in ctags. +Use "--fields=+S". + +.. code-block:: Elm + + funcA a1 a2 = + a1 + a2 + +"output.tags" +with "--sort=no --extras=+r --fields=+rS" + +.. code-block:: tags + + funcA input.elm /^funcA a1 a2 =$/;" f signature:a1 a2 roles:def + KNOWN LIMITATIONS ----------------- +The ctags signature field is used for function parameter lists, even +though it's not an idea field. See above. + Elm requires all statements at the same logical level to have the same indentation. If there is additional indentation that line is part of the previous one. Therefore without over-complicating the diff --git a/peg/elm.peg b/peg/elm.peg index 1296f82c63..96cf7b6fb7 100644 --- a/peg/elm.peg +++ b/peg/elm.peg @@ -323,11 +323,11 @@ importedTypeConstructor <- functionWithTypeAnnotation <- _0_ ':' _0_ TLSS - <$1> _1_ { + <$1> _1_ ? { int r = makeElmTagSettingScope(auxil, $3, $3s, K_FUNCTION, ROLE_DEFINITION_INDEX); addElmTypeRef(r, $2); - } - functionParameterList? _0_ '=' _0_ expression EOS { + addElmSignature(r, $4); + } _0_ '=' _0_ expression EOS { POP_SCOPE(auxil); } @@ -337,10 +337,10 @@ typeAnnotation <- # Function without a type annotation functionDefinition <- - _0_ { - makeElmTagSettingScope(auxil, $1, $1s, K_FUNCTION, ROLE_DEFINITION_INDEX); - } - functionParameterList? _0_ '=' _0_ expression EOS { + _0_ ? { + int r = makeElmTagSettingScope(auxil, $1, $1s, K_FUNCTION, ROLE_DEFINITION_INDEX); + addElmSignature(r, $2); + } _0_ '=' _0_ expression EOS { POP_SCOPE(auxil); } @@ -435,10 +435,14 @@ letInLine <- / letInFunctionBody letInFunctionDefinition <- - (WS+ nonKeywordIdentifier)* WS* '=' Non_NL* { - makeElmTag(auxil, $1, $1s, K_FUNCTION, ROLE_DEFINITION_INDEX); + WS* ? WS* '=' Non_NL* { + int r = makeElmTag(auxil, $1, $1s, K_FUNCTION, ROLE_DEFINITION_INDEX); + addElmSignature(r, $2); } +letInFunctionParameters <- + nonKeywordIdentifier (WS+ nonKeywordIdentifier)* + letInFunctionBody <- !('let' / 'in') Non_NL+ diff --git a/peg/elm_post.h b/peg/elm_post.h index 0fab2a567d..07b63bcd65 100644 --- a/peg/elm_post.h +++ b/peg/elm_post.h @@ -61,6 +61,18 @@ static int makeElmTagSettingScope (struct parserCtx *auxil, const char *name, lo return scope_index; } +static void addElmSignature(int scope_index, const char *sig) +{ + tagEntryInfo *e = getEntryInCorkQueue (scope_index); + + if (e) + { + vString *vsig = collapseWhitespace (sig); + + e->extensionFields.signature = vStringDeleteUnwrap (vsig); + } +} + static void addElmTypeRef(int scope_index, const char *sig) { tagEntryInfo *e = getEntryInCorkQueue (scope_index); diff --git a/peg/elm_pre.h b/peg/elm_pre.h index 2d52458ec4..eaaeac834f 100644 --- a/peg/elm_pre.h +++ b/peg/elm_pre.h @@ -100,6 +100,7 @@ struct parserCtx { #define USE_KIND_STACK KIND_GHOST_INDEX static int makeElmTag (struct parserCtx *auxil, const char *name, long offset, int kind, int role); static int makeElmTagSettingScope (struct parserCtx *auxil, const char *name, long offset, int kind, int role); +static void addElmSignature(int scope_index, const char *sig); static void addElmTypeRef(int scope_index, const char *str); static void initElmConstructorFields (struct parserCtx *auxil, const char *name); static void initElmConstructorSubtypeFields (struct parserCtx *auxil); From 1f4c0e6800cf86e77c9678db9dad747387a58080 Mon Sep 17 00:00:00 2001 From: Nik Silver Date: Tue, 29 Mar 2022 18:21:19 +0100 Subject: [PATCH 11/11] Elm: Misc fixes, including description -> typename. - (Format) typeref:description: -> typeref:typename: - (Refactor) Use isspace() for clarity. - (Man page) Man page passes `make man-test`. - (Comments) Remove incorrect task in comments. - (Comments) Add thanks in comments. --- .../elm-bad-lines.d/expected.tags | 2 +- .../expected.tags | 6 ++-- .../elm-parameter-capture.d/expected.tags | 2 +- Units/parser-elm.r/elm-ports.d/expected.tags | 4 +-- .../elm-type-annotations.d/expected.tags | 16 ++++----- docs/man/ctags-lang-elm.7.rst | 33 +++++++++++-------- man/ctags-lang-elm.7.rst.in | 33 +++++++++++-------- peg/elm.peg | 10 ++++-- peg/elm_post.h | 4 +-- 9 files changed, 62 insertions(+), 48 deletions(-) diff --git a/Units/parser-elm.r/elm-bad-lines.d/expected.tags b/Units/parser-elm.r/elm-bad-lines.d/expected.tags index 8756fdd497..fe99fb26ca 100644 --- a/Units/parser-elm.r/elm-bad-lines.d/expected.tags +++ b/Units/parser-elm.r/elm-bad-lines.d/expected.tags @@ -1,6 +1,6 @@ Input input.elm /^import Input exposing (..)$/;" m roles:imported input1a input-1.elm /^input1a = 1$/;" f roles:def -input1b input-1.elm /^input1b = 2$/;" f typeref:description:Int roles:def +input1b input-1.elm /^input1b = 2$/;" f typeref:typename:Int roles:def input2b input-2.elm /^input2b = 1$/;" f roles:def input2c input-2.elm /^input2c = 3$/;" f roles:def module2d input-2.elm /^module2d = 4$/;" f roles:def diff --git a/Units/parser-elm.r/elm-constructor-signatures.d/expected.tags b/Units/parser-elm.r/elm-constructor-signatures.d/expected.tags index 0e6efedf98..87a8b08013 100644 --- a/Units/parser-elm.r/elm-constructor-signatures.d/expected.tags +++ b/Units/parser-elm.r/elm-constructor-signatures.d/expected.tags @@ -1,4 +1,4 @@ B input.elm /^type B$/;" t roles:def -B1Cons input.elm /^ = B1Cons$/;" c type:B typeref:description:{ x : Float , y : Float } -> B roles:def -B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B typeref:description:String -> Integer -> B roles:def -B3Cons input.elm /^ | B3Cons$/;" c type:B typeref:description:B roles:def +B1Cons input.elm /^ = B1Cons$/;" c type:B typeref:typename:{ x : Float , y : Float } -> B roles:def +B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B typeref:typename:String -> Integer -> B roles:def +B3Cons input.elm /^ | B3Cons$/;" c type:B typeref:typename:B roles:def diff --git a/Units/parser-elm.r/elm-parameter-capture.d/expected.tags b/Units/parser-elm.r/elm-parameter-capture.d/expected.tags index ece916c1c1..6d76c9bc81 100644 --- a/Units/parser-elm.r/elm-parameter-capture.d/expected.tags +++ b/Units/parser-elm.r/elm-parameter-capture.d/expected.tags @@ -1,5 +1,5 @@ funcA input.elm /^funcA a1 a2 =$/;" f signature:a1 a2 roles:def -funcB input.elm /^funcB b1$/;" f typeref:description:Int -> Int -> Int signature:b1 b2 roles:def +funcB input.elm /^funcB b1$/;" f typeref:typename:Int -> Int -> Int signature:b1 b2 roles:def funcC input.elm /^funcC (c1, c2) {c3} (C4Cons c4 c5) =$/;" f signature:(c1, c2) {c3} (C4Cons c4 c5) roles:def funcD input.elm /^funcD = 4$/;" f signature: roles:def funcE input.elm /^funcE=5$/;" f signature: roles:def diff --git a/Units/parser-elm.r/elm-ports.d/expected.tags b/Units/parser-elm.r/elm-ports.d/expected.tags index 1cbd89d933..e101ed4dc0 100644 --- a/Units/parser-elm.r/elm-ports.d/expected.tags +++ b/Units/parser-elm.r/elm-ports.d/expected.tags @@ -1,3 +1,3 @@ Main input.elm /^port module Main exposing (..)$/;" m roles:def -outgoing input.elm /^port outgoing : Enc.Value -> Cmd msg$/;" p module:Main typeref:description:Enc.Value -> Cmd msg roles:def -incoming input.elm /^port incoming : (Enc.Value -> msg) -> Sub msg$/;" p module:Main typeref:description:(Enc.Value -> msg) -> Sub msg roles:def +outgoing input.elm /^port outgoing : Enc.Value -> Cmd msg$/;" p module:Main typeref:typename:Enc.Value -> Cmd msg roles:def +incoming input.elm /^port incoming : (Enc.Value -> msg) -> Sub msg$/;" p module:Main typeref:typename:(Enc.Value -> msg) -> Sub msg roles:def diff --git a/Units/parser-elm.r/elm-type-annotations.d/expected.tags b/Units/parser-elm.r/elm-type-annotations.d/expected.tags index 070821d2fc..eebfafd780 100644 --- a/Units/parser-elm.r/elm-type-annotations.d/expected.tags +++ b/Units/parser-elm.r/elm-type-annotations.d/expected.tags @@ -1,9 +1,9 @@ -funcA input.elm /^funcA a = 1$/;" f typeref:description:Int -> Float -> Float roles:def -funcB input.elm /^funcB b =$/;" f typeref:description:String -> Float roles:def -funcC input.elm /^funcC c = 3$/;" f typeref:description:Int -> {c: String} roles:def -funcD input.elm /^funcD = 4$/;" f typeref:description:(Int, Int) -> String roles:def -funcE input.elm /^funcE = 5$/;" f typeref:description:Float -> (Int -> Int -> Int -> String) roles:def -funcF input.elm /^funcF = 6$/;" f typeref:description:String -> {- Old ->-} Int roles:def -funcG input.elm /^funcG = 7$/;" f typeref:description:G.Int -> G.Other roles:def -funcH input.elm /^funcH h =$/;" f typeref:description:Int -> Int roles:def +funcA input.elm /^funcA a = 1$/;" f typeref:typename:Int -> Float -> Float roles:def +funcB input.elm /^funcB b =$/;" f typeref:typename:String -> Float roles:def +funcC input.elm /^funcC c = 3$/;" f typeref:typename:Int -> {c: String} roles:def +funcD input.elm /^funcD = 4$/;" f typeref:typename:(Int, Int) -> String roles:def +funcE input.elm /^funcE = 5$/;" f typeref:typename:Float -> (Int -> Int -> Int -> String) roles:def +funcF input.elm /^funcF = 6$/;" f typeref:typename:String -> {- Old ->-} Int roles:def +funcG input.elm /^funcG = 7$/;" f typeref:typename:G.Int -> G.Other roles:def +funcH input.elm /^funcH h =$/;" f typeref:typename:Int -> Int roles:def h2 input.elm /^ h2 = 34$/;" f function:funcH roles:def diff --git a/docs/man/ctags-lang-elm.7.rst b/docs/man/ctags-lang-elm.7.rst index 7ba8fee38b..5a9b5845c9 100644 --- a/docs/man/ctags-lang-elm.7.rst +++ b/docs/man/ctags-lang-elm.7.rst @@ -35,10 +35,12 @@ Imported items are tagged, but their role is "imported", not "def". Imported items are marked as being in the scope of their own module, not the module that's doing the importing. +"input.elm" + .. code-block:: Elm module SomeMod exposing (..) - + import MyMod exposing ( map , Maybe @@ -47,7 +49,7 @@ not the module that's doing the importing. ) "output.tags" -with "--sort=no --extras=+r --fields=+r" +with "--options=NONE -o - --sort=no --extras=+r --fields=+r input.elm" .. code-block:: tags @@ -64,14 +66,16 @@ Namespaces Namespaces are tagged and their role is "def". +"input.elm" + .. code-block:: Elm module AMod exposing (..) - + import MyImport as NSpace exposing (impFunc) "output.tags" -with "--sort=no --extras=+r --fields=+r" +with "--options=NONE -o - --sort=no --extras=+r --fields=+r input.elm" .. code-block:: tags @@ -80,17 +84,18 @@ with "--sort=no --extras=+r --fields=+r" MyImport input.elm /^import MyImport as NSpace exposing (impFunc)$/;" m roles:imported impFunc input.elm /^import MyImport as NSpace exposing (impFunc)$/;" f module:MyImport roles:imported -Type descriptions +Type names ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Constructors will have type descriptions. So will any top level function -that has a type annotation. +Constructors top level functions will have type names. + +"input.elm" .. code-block:: Elm funcA : Int -> Int funcA a = a + 1 - + type B = B1Cons { x : Float @@ -100,15 +105,15 @@ that has a type annotation. | B3Cons "output.tags" -with "--sort=no --extras=+r --fields=+r" +with "--options=NONE -o - --sort=no --extras=+r --fields=+r input.elm" .. code-block:: tags - funcA input.elm /^funcA a = a + 1$/;" f typeref:description:Int -> Int roles:def + funcA input.elm /^funcA a = a + 1$/;" f typeref:typename:Int -> Int roles:def B input.elm /^type B$/;" t roles:def - B3Cons input.elm /^ | B3Cons$/;" c type:B typeref:description: roles:def - B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B typeref:description:String -> Integer -> B roles:def - B1Cons input.elm /^ = B1Cons$/;" c type:B typeref:description:{ x : Float , y : Float } -> B roles:def + B1Cons input.elm /^ = B1Cons$/;" c type:B typeref:typename:{ x : Float , y : Float } -> B roles:def + B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B typeref:typename:String -> Integer -> B roles:def + B3Cons input.elm /^ | B3Cons$/;" c type:B typeref:typename:B roles:def Function parameter lists ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -145,7 +150,7 @@ Sometimes functions in let/in blocks will be omitted. Functions in let/in blocks will be marked as being in the scope of their outer function, regardless of how deeply nested the let/in block is. -Functions in let/in blocks won't have type descriptions. +Functions in let/in blocks won't have type names. SEE ALSO -------- diff --git a/man/ctags-lang-elm.7.rst.in b/man/ctags-lang-elm.7.rst.in index 7c3c584033..d9fbfa786d 100644 --- a/man/ctags-lang-elm.7.rst.in +++ b/man/ctags-lang-elm.7.rst.in @@ -35,10 +35,12 @@ Imported items are tagged, but their role is "imported", not "def". Imported items are marked as being in the scope of their own module, not the module that's doing the importing. +"input.elm" + .. code-block:: Elm module SomeMod exposing (..) - + import MyMod exposing ( map , Maybe @@ -47,7 +49,7 @@ not the module that's doing the importing. ) "output.tags" -with "--sort=no --extras=+r --fields=+r" +with "--options=NONE -o - --sort=no --extras=+r --fields=+r input.elm" .. code-block:: tags @@ -64,14 +66,16 @@ Namespaces Namespaces are tagged and their role is "def". +"input.elm" + .. code-block:: Elm module AMod exposing (..) - + import MyImport as NSpace exposing (impFunc) "output.tags" -with "--sort=no --extras=+r --fields=+r" +with "--options=NONE -o - --sort=no --extras=+r --fields=+r input.elm" .. code-block:: tags @@ -80,17 +84,18 @@ with "--sort=no --extras=+r --fields=+r" MyImport input.elm /^import MyImport as NSpace exposing (impFunc)$/;" m roles:imported impFunc input.elm /^import MyImport as NSpace exposing (impFunc)$/;" f module:MyImport roles:imported -Type descriptions +Type names ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Constructors will have type descriptions. So will any top level function -that has a type annotation. +Constructors top level functions will have type names. + +"input.elm" .. code-block:: Elm funcA : Int -> Int funcA a = a + 1 - + type B = B1Cons { x : Float @@ -100,15 +105,15 @@ that has a type annotation. | B3Cons "output.tags" -with "--sort=no --extras=+r --fields=+r" +with "--options=NONE -o - --sort=no --extras=+r --fields=+r input.elm" .. code-block:: tags - funcA input.elm /^funcA a = a + 1$/;" f typeref:description:Int -> Int roles:def + funcA input.elm /^funcA a = a + 1$/;" f typeref:typename:Int -> Int roles:def B input.elm /^type B$/;" t roles:def - B3Cons input.elm /^ | B3Cons$/;" c type:B typeref:description: roles:def - B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B typeref:description:String -> Integer -> B roles:def - B1Cons input.elm /^ = B1Cons$/;" c type:B typeref:description:{ x : Float , y : Float } -> B roles:def + B1Cons input.elm /^ = B1Cons$/;" c type:B typeref:typename:{ x : Float , y : Float } -> B roles:def + B2Cons input.elm /^ | B2Cons String Integer$/;" c type:B typeref:typename:String -> Integer -> B roles:def + B3Cons input.elm /^ | B3Cons$/;" c type:B typeref:typename:B roles:def Function parameter lists ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -145,7 +150,7 @@ Sometimes functions in let/in blocks will be omitted. Functions in let/in blocks will be marked as being in the scope of their outer function, regardless of how deeply nested the let/in block is. -Functions in let/in blocks won't have type descriptions. +Functions in let/in blocks won't have type names. SEE ALSO -------- diff --git a/peg/elm.peg b/peg/elm.peg index 96cf7b6fb7..bff2a618a9 100644 --- a/peg/elm.peg +++ b/peg/elm.peg @@ -3,6 +3,13 @@ # This source code is released for free distribution under the terms of the # GNU General Public License version 2 or later. # +# Thanks to: +# - Mark Skipper, for the original Elm optlib parser, which inspired this; +# - Samuel Stauffer, for the Thrift PEG parser, which showed me how to +# write a PEG parser; +# - Jan DolinĂ¡r, for the Kotlin PEG parser, which also provided insight; +# - Masatake YAMATO, for patience and guidance in code reviews. +# # This parser generates tags for Elm. See https://elm-lang.org/docs/syntax # for language reference. # @@ -50,9 +57,6 @@ # - Allow non-Latin upper and lower case. Use # https://util.unicode.org/UnicodeJsps/properties.html # combined with \p{Lu}, \p{Ll} and \p{L}. -# - If there's no --field=+r then an imported module (say) is still tagged, -# but there's no roles:imported, so it looks like it has been defined. -# Not sure if this is a bug. The Thrift parser has this same behaviour. # # Won't do: # - Handle Elm's indentation properly. diff --git a/peg/elm_post.h b/peg/elm_post.h index 07b63bcd65..d425573071 100644 --- a/peg/elm_post.h +++ b/peg/elm_post.h @@ -81,7 +81,7 @@ static void addElmTypeRef(int scope_index, const char *sig) { vString *vsig = collapseWhitespace (sig); - e->extensionFields.typeRef [0] = eStrdup ("description"); + e->extensionFields.typeRef [0] = eStrdup ("typename"); e->extensionFields.typeRef [1] = vStringDeleteUnwrap (vsig); } } @@ -139,7 +139,7 @@ static vString *collapseWhitespace (const char *sig) // The character, in case we need to change it c2 = *c; - if (c2 == ' ' || c2 == '\t' || c2 == '\r' || c2 == '\n' || c2 == '\f') + if (isspace ((unsigned char) c2)) { // It's whitespace. Make it plain space c2 = ' ';