Skip to content

Feature : provide a transform module. #10

Description

@niahoo

Hi !

To keep the abnf syntax clear, I could be cool to provide a transform module to the parse function. So insteal of writing this :

special-number = integer (frac / frac exp / exp) !!!
    case do_something_complicated_here(state, values) do
      stuff -> more_stuff()
      :error -> fail_badly()
    end
!!!

You just pass a transform module and implement the function transform/4 where you can match on the rule name. And you can return :ignore to keep the original behaviour (when there is no !!! code block !!!)

def transform("special-number", state, values, string_values) do
  case do_something_complicated_here(state, values) do
    stuff -> more_stuff()
    :error -> fail_badly()
  end
end


def transform(_other, state, values, string_values) do
  :ignore
end

What do you think about that ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions