From 4fd257bb084d173fa07aa057e6d294ee525721e8 Mon Sep 17 00:00:00 2001 From: Matthew Hall Date: Sun, 2 Apr 2023 11:38:47 +1200 Subject: Refactor parser_chain argument order --- src/parcom.cr | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/parcom.cr') diff --git a/src/parcom.cr b/src/parcom.cr index b75cb0f..0963184 100644 --- a/src/parcom.cr +++ b/src/parcom.cr @@ -9,9 +9,9 @@ module Parcom end # Provides a more convenient syntax for combining parsers via `Parser#and_then`. - # The first argument is a string literal used for the name of the parser. - # The second and third arguments are types used for the parser's type. - # These are followed by any number of 2-tuples containing a variable name and + # The first and second arguments are types used for the parser's type. + # The thirs argument is a string literal used for the name of the parser. + # This is followed by any number of 2-tuples containing a variable name and # an expression resolving to a `Parser(t.Class, _)`, whose success value will # be stored in the aformentioned variable. The `finally` named argument is an # expression that resolves to a `Parser(t.class, u.class)`. @@ -20,7 +20,7 @@ module Parcom # ``` # any_word = Parser(Char, Char).satisfy(&.letter?).some.map(&.join) # ws = Parser(Char, Array(Char)).satisfy(&.whitespace?).many - # two_of_same_word = parser_chain "two words", Char, String, + # two_of_same_word = parser_chain Char, String, "two words", # {word, any_word}, # {_, ws}, # finally: Parser.token_sequence(word.chars).map(&.join) @@ -39,7 +39,7 @@ module Parcom # ``` # # This macro is based on Haskell's do-notation. - macro parser_chain(name, t, u, *steps, finally) + macro parser_chain(t, u, name, *steps, finally) Parser({{t}}, {{u}}).new({{name}}) do |tokens| {% for tup, index in steps %} {{tup.last}}.and_then do |{{tup.first}}| -- cgit v1.2.1