Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature : provide a transform module. #10

Open
niahoo opened this issue Jul 6, 2016 · 0 comments
Open

Feature : provide a transform module. #10

niahoo opened this issue Jul 6, 2016 · 0 comments

Comments

@niahoo
Copy link

niahoo commented Jul 6, 2016

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant