-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocs.json
1 lines (1 loc) · 11.1 KB
/
docs.json
1
[{"name":"Parser.Advanced.Workaround","comment":" Workarounds for [a bug](https://github.com/elm/parser/issues/53) in\n[`Parser.Advanced`](https://package.elm-lang.org/packages/elm/parser/latest/Parser-Advanced).\n\n---\n\n**Everything here works just like in the\n[`Parser.Workaround`](Parser-Workaround) module, except that `String`\narguments become `Token` arguments, and you need to provide a `Problem` for\ncertain scenarios.**\n\n---\n\n\n# Bug Workarounds\n\n---\n\nSee the [`Parser.Workaround`](Parser-Workaround) documentation\nfor a description of the [problem](Parser-Workaround#the-problem)\nand [guidelines](Parser-Workaround#guidelines) for the use of the workaround parsers.\n\n---\n\n@docs lineCommentBefore, lineCommentAfter, multiCommentBefore, multiCommentAfter\n@docs chompUntilBefore, chompUntilAfter, chompUntilEndOrBefore, chompUntilEndOrAfter\n\n","unions":[],"aliases":[],"values":[{"name":"chompUntilAfter","comment":" Just like [`Parser.Advanced.chompUntil`](https://package.elm-lang.org/packages/elm/parser/latest/Parser.Advanced#chompUntil)\nexcept it consistently stops after the token.\n","type":"Parser.Advanced.Token x -> Parser.Advanced.Parser c x ()"},{"name":"chompUntilBefore","comment":" Just like [`Parser.Advanced.chompUntil`](https://package.elm-lang.org/packages/elm/parser/latest/Parser.Advanced#chompUntil)\nexcept it consistently stops before the token.\n","type":"Parser.Advanced.Token x -> Parser.Advanced.Parser c x ()"},{"name":"chompUntilEndOrAfter","comment":" Just like [`Parser.Advanced.chompUntilEndOr`](https://package.elm-lang.org/packages/elm/parser/latest/Parser.Advanced#chompUntilEndOr)\nexcept it consistently stops after the token (if it is found).\n","type":"Parser.Advanced.Token x -> Parser.Advanced.Parser c x ()"},{"name":"chompUntilEndOrBefore","comment":" Just like [`Parser.Advanced.chompUntilEndOr`](https://package.elm-lang.org/packages/elm/parser/latest/Parser.Advanced#chompUntilEndOr)\nexcept it consistently stops before the token (if it is found).\n","type":"Parser.Advanced.Token x -> Parser.Advanced.Parser c x ()"},{"name":"lineCommentAfter","comment":" Just like [`Parser.Advanced.lineComment`](https://package.elm-lang.org/packages/elm/parser/latest/Parser.Advanced#lineComment)\nexcept it consistently stops after the linefeed character.\n","type":"Parser.Advanced.Token x -> Parser.Advanced.Parser c x ()"},{"name":"lineCommentBefore","comment":" Just like [`Parser.Advanced.lineComment`](https://package.elm-lang.org/packages/elm/parser/latest/Parser.Advanced#lineComment)\nexcept it consistently stops before the linefeed character.\n","type":"Parser.Advanced.Token x -> Parser.Advanced.Parser c x ()"},{"name":"multiCommentAfter","comment":" Just like [`Parser.Advanced.multiComment`](https://package.elm-lang.org/packages/elm/parser/latest/Parser.Advanced#multiComment)\nexcept it consistently stops after the last closing token.\n","type":"Parser.Advanced.Token x -> Parser.Advanced.Token x -> Parser.Advanced.Nestable -> Parser.Advanced.Parser c x ()"},{"name":"multiCommentBefore","comment":" Just like [`Parser.Advanced.multiComment`](https://package.elm-lang.org/packages/elm/parser/latest/Parser.Advanced#multiComment)\nexcept it consistently stops before the last closing token.\n","type":"Parser.Advanced.Token x -> Parser.Advanced.Token x -> Parser.Advanced.Nestable -> Parser.Advanced.Parser c x ()"}],"binops":[]},{"name":"Parser.Workaround","comment":" Workarounds for [a bug](https://github.com/elm/parser/issues/53) in\n[`Parser`](https://package.elm-lang.org/packages/elm/parser/latest/Parser).\n\n\n## The Problem\n\nThe Elm Parser internally keeps track of the current position in two ways:\n\n - as a row and a column (like a code editor)\n - as an offset into the source string.\n\nSee the [Positions](https://package.elm-lang.org/packages/elm/parser/latest/Parser#positions)\nchapter in the Parser documentation for more details.\n\nNormally both kinds of position infos (row and column vs. offset) are in sync with each other.\n(For a given source string, you can calculate both row and column from the offset and vice versa.)\n\nThere's [a bug](https://github.com/elm/parser/issues/53) in the Parser code though.\nThe following parsers break this synchronicity:\n[`lineComment`](https://package.elm-lang.org/packages/elm/parser/latest/Parser#lineComment),\n[`multiComment`](https://package.elm-lang.org/packages/elm/parser/latest/Parser#multiComment),\n[`chompUntil`](https://package.elm-lang.org/packages/elm/parser/latest/Parser#chompUntil), and\n[`chompUntilEndOr`](https://package.elm-lang.org/packages/elm/parser/latest/Parser#chompUntilEndOr).\nThey set...\n\n - row and column **after** the (closing) token\n - the offset **before** the (closing) token\n\nHere's an example with [`chompUntil`](https://package.elm-lang.org/packages/elm/parser/latest/Parser#chompUntil):\n\n import Parser exposing ((|.), (|=), Parser)\n\n testParser : Parser { row : Int, col : Int, offset : Int }\n testParser =\n Parser.succeed (\\row col offset -> { row = row, col = col, offset = offset })\n |. Parser.chompUntil \"token\"\n |= Parser.getRow\n |= Parser.getCol\n |= Parser.getOffset\n\n Parser.run testParser \"< token >\"\n --> Ok { row = 1, col = 8, offset = 2 }\n\nThe state after the test parser is run:\n\n - row = 1, col = 8 (corresponding to offset = 7) --> **after** the token\n - offset = 2 (corresponding to row = 1, col = 3) --> **before** the token\n\n\n## Workaround\n\nAs a workaround, this package offers `xxxBefore` and `xxxAfter` parsers which consistently position\nboth row/column and offset either before or after the (closing) token.\n\n - [`lineCommentBefore`](#lineCommentBefore) and [`lineCommentAfter`](#lineCommentAfter)\n - [`multiCommentBefore`](#multiCommentBefore) and [`multiCommentAfter`](#multiCommentAfter)\n - [`chompUntilBefore`](#chompUntilBefore) and [`chompUntilAfter`](#chompUntilAfter)\n - [`chompUntilEndOrBefore`](#chompUntilEndOrBefore) and [`chompUntilEndOrAfter`](#chompUntilEndOrAfter)\n\nWhy are there two different workarounds for each buggy parser?\n\nOn the one hand, if you already have working parsers and don't use the row or column information,\nthen you can replace them with the `xxxBefore` variants and they will continue to work.\n(There's one exception for the `multiComment` parser though, [see below](#exception).)\n\nOn the other hand, most often the `xxxAfter` variants are easier to use,\nbecause you don't need to chomp the (closing) token yourself.\nSo if you write new parsers, you'll likely want to use the `xxxAfter` variants.\nPlus, if the bug will be fixed, it can be assumed that the\nfixed parsers will work like the `xxxAfter` variants.\n(If you want to know why, you can look at the description of\n[this pull request](https://github.com/elm/parser/pull/54).)\n\n\n## Guidelines\n\nIf you are unsure whether to use the `xxxBefore` or the `xxxAfter` parsers\nor whether to use the workarounds at all, you could follow these guidelines:\n\n - If you already use one or more of the four buggy parsers:\n - If they work the way you want:\n - If it's likely that you'll need to modify your parsers:\n - Switch to the `xxxBefore` workarounds.\n Then you don't have to change your existing parsers,\n but the workarounds maintain an internally consistent state.\n This makes it easier to combine them with other parsers later.\n (There's one exception for the `multiComment` parser though, [see below](#exception).)\n - If it's unlikely that you'll need to modify your parsers:\n - Don't change anything (never touch a running system).\n - If they don't work the way you want:\n - Switch to the `xxxAfter` workarounds, because often they are easier to use\n and because they implement the intended behavior.\n You'll have to modify the surrounding parsers, but they don't work anyhow.\n - If you don't use one or more of the four buggy parsers yet but are planning to do so:\n - Use the `xxxAfter` workarounds, because often they are easier to use\n and because they implement the intended behavior.\n - If you don't use any buggy parser yet and are not planning to do so:\n - No buggy parser, no need for a workaround 🙂\n\n\n### Exception\n\nThere's one exception to the rules above: if the\n[`multiComment`](https://package.elm-lang.org/packages/elm/parser/latest/Parser#multiComment)\nparser is used with\n[`Nestable`](https://package.elm-lang.org/packages/elm/parser/latest/Parser#Nestable)\ncomments, then it isn't affected from the bug.\n(For this mode it's implemented differently.)\n\nTherefore this parser should be replaced with the [`multiCommentAfter`](#multiCommentAfter)\nworkaround to keep the current behavior.\n\n\n## Parsers\n\n@docs lineCommentBefore, lineCommentAfter, multiCommentBefore, multiCommentAfter\n@docs chompUntilBefore, chompUntilAfter, chompUntilEndOrBefore, chompUntilEndOrAfter\n\n","unions":[],"aliases":[],"values":[{"name":"chompUntilAfter","comment":" Just like [`Parser.chompUntil`](https://package.elm-lang.org/packages/elm/parser/latest/Parser#chompUntil)\nexcept it consistently stops after the string.\n","type":"String.String -> Parser.Parser ()"},{"name":"chompUntilBefore","comment":" Just like [`Parser.chompUntil`](https://package.elm-lang.org/packages/elm/parser/latest/Parser#chompUntil)\nexcept it consistently stops before the string.\n","type":"String.String -> Parser.Parser ()"},{"name":"chompUntilEndOrAfter","comment":" Just like [`Parser.chompUntilEndOr`](https://package.elm-lang.org/packages/elm/parser/latest/Parser#chompUntilEndOr)\nexcept it consistently stops after the string (if it is found).\n","type":"String.String -> Parser.Parser ()"},{"name":"chompUntilEndOrBefore","comment":" Just like [`Parser.chompUntilEndOr`](https://package.elm-lang.org/packages/elm/parser/latest/Parser#chompUntilEndOr)\nexcept it consistently stops before the string (if it is found).\n","type":"String.String -> Parser.Parser ()"},{"name":"lineCommentAfter","comment":" Just like [`Parser.lineComment`](https://package.elm-lang.org/packages/elm/parser/latest/Parser#lineComment)\nexcept it consistently stops after the linefeed character.\n","type":"String.String -> Parser.Parser ()"},{"name":"lineCommentBefore","comment":" Just like [`Parser.lineComment`](https://package.elm-lang.org/packages/elm/parser/latest/Parser#lineComment)\nexcept it consistently stops before the linefeed character.\n","type":"String.String -> Parser.Parser ()"},{"name":"multiCommentAfter","comment":" Just like [`Parser.multiComment`](https://package.elm-lang.org/packages/elm/parser/latest/Parser#multiComment)\nexcept it consistently stops after the last closing string.\n","type":"String.String -> String.String -> Parser.Nestable -> Parser.Parser ()"},{"name":"multiCommentBefore","comment":" Just like [`Parser.multiComment`](https://package.elm-lang.org/packages/elm/parser/latest/Parser#multiComment)\nexcept it consistently stops before the last closing string.\n","type":"String.String -> String.String -> Parser.Nestable -> Parser.Parser ()"}],"binops":[]}]