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
Add Syntax_config #71
Conversation
Let me show you the current state of this @rvantonder:
{
"user_defined_delimiters": [
[ "if", "fi" ],
[ "BLOCK-BEGIN", "BLOCK-END" ]
],
"escapable_string_literals": [],
"escape_char": "\\",
"raw_string_literals": [
[ "\"", "\"" ]
],
"comment_parser": [
[ "Until_newline", "#" ]
]
} Now I can use this to run $ ./comby -custom-matcher ~/work/misc/custom_comby_matcher.json 'BLOCK-BEGIN :[1] BLOCK-END' 'BLOCK-BEGIN nuked blocks BLOCK-END' -stdin << EOF
BLOCK-BEGIN
BLOCK-BEGIN
block 1
BLOCK-END
BLOCK-BEGIN
block 2
BLOCK-END
BLOCK-END
EOF And the output is this: ------ /dev/null
++++++ /dev/null
@|-1,9 +1,1 ============================================================
-| BLOCK-BEGIN
-| BLOCK-BEGIN
-| block 1
-| BLOCK-END
-|
-| BLOCK-BEGIN
-| block 2
-| BLOCK-END
-| BLOCK-END
+| BLOCK-BEGIN nuked blocks BLOCK-END :) What do you imagine the CLI to look like? Should users be able to specify a list of custom-matchers? A directory of them? I think what I'd love to have is a way to connect a custom matcher with a file extension, so we could say ".foobar is handled by foobar-matcher, .monkey is handled by monkey matcher" etc.
That would register 3 custom matchers:
What do you think of that? |
That sounds good to me! Initially I thought this could go in the JSON schema, but since the language extension is the only 'meta' data we need, I think your proposal works much better (and also easier to change). The current solution would assume that we match substring extensions based on one dot separator (i.e., we won't support defining a custom matcher for a file extension like |
Also: yes, I think a comma-separated list on the CLI is a good way to specify multiple configurations (as opposed to pointing at a directory containing them). The latter could be supported later, but I think CLI is likely the more convenient obvious use case. |
Aside: it's not currently possible to have a matcher for language 1 and a matcher for language 2 and run these on different languages in one execution. So supporting a comma-separated list doesn't make much sense until that is supported (and I'm not sure that that is a common use case). You can of course associate multiple file extensions with a single matcher, just pass it in the configuration after parsing: https://github.com/comby-tools/comby/blob/master/src/main.ml#L356. |
Since we already have Then the only thing left to do would be to update the documentation for I actually really like this, because it keeps every piece simple and they all work together. What do you think? |
Update: that already works really well. Here's an example of using a custom matcher with a file filter: ./comby\
-custom-matcher ~/work/misc/custom_comby_matcher.json\
-f .custom_block
'BLOCK-BEGIN :[1] BLOCK-END'\
'BLOCK-BEGIN nuked blocks BLOCK-END' ------ /Users/thorstenball/work/comby/example.custom_block
++++++ /Users/thorstenball/work/comby/example.custom_block
@|-1,9 +1,1 ============================================================
-|BLOCK-BEGIN
-| BLOCK-BEGIN
-| block 1
-| BLOCK-END
-|
-| BLOCK-BEGIN
-| block 2
-| BLOCK-END
-|BLOCK-END
+|BLOCK-BEGIN nuked blocks BLOCK-END |
No description provided.