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

Language syntax #26 #34

Merged
merged 6 commits into from
Nov 6, 2015
Merged

Language syntax #26 #34

merged 6 commits into from
Nov 6, 2015

Conversation

DarthKipsu
Copy link
Contributor

This is a fix for #26

Language comment styles are passed on using LanguageSyntax, this will require only new comment regexes to be added when creating a new language plugin. I have not yet added the syntax files for any of the plugins as I'm worried it will break any current exercises if the syntax for the comments is suddenly changed. For backwards compatibility, should single line java comments always be accepted?

@DarthKipsu DarthKipsu changed the title Lang syntax Language syntax #26 Oct 14, 2015
@jamo
Copy link
Member

jamo commented Oct 14, 2015

Initial thoughts after first glimpse; it seems like there is a one to one relation for syntax plugin and language.
Could we generalise this a bit more; to have both // and /* <something>*/ to both be separate plugins.
And maybe then we could just blindly just use every possible filter for a given file or with annotations or more manually link plugins to specific files.

(In, say a maven project, we could have .java, .xml, .html, .js and .css files...)

@DarthKipsu
Copy link
Contributor Author

Now you're able to build a custom comment syntax that can include all the comments you wish to support for a plugin. It defaults to Java single line comments if no syntax is given.

One way to improve might be by creating an enum to store the different comment regexes for all languages, so that if two plugins use the same language, they would not have to come up with the regex again. Not sure if using enums like this is a good practice?

@jamo
Copy link
Member

jamo commented Oct 21, 2015

Awesome!
I really like the CommentSyntax and the builder for it!

What I'm not fully sure about though is whether we want or need to have each different language plugin to say "I'm Going to allow there kind of syntaxes" but rather just have a set of plugins, each defined for a set of file-extensions so that it would just ask "Hey, I have this .js file - who wants to parse it"

That being said, it might be too early for that... -- anyways the builder makes building and adding these much nicer task!

@DarthKipsu
Copy link
Contributor Author

I'm not sure what's the best way to do that. Should the file extension be checked in prepareStubFile() and prepareSolutionFile() and only create a CommentSyntax (or maybe get from a mapping of some sort) after checking the extension every time?

@jamo
Copy link
Member

jamo commented Oct 21, 2015

For both, stubs and solutions we need to process the files.. We could have a map<Extension, List<SyntaxPlugin>> and we would apply each available plugin for given file in order.
One nice way would be to do use reflection to build the filetype: syntaxPlugin map - maybe even with out having annotations.

A nice way with annotations and reflection could be to have @SyntaxPlugin(list of supported extensions) annotations

jamo added a commit that referenced this pull request Nov 6, 2015
Language syntax parser plugin
@jamo jamo merged commit fdad46d into testmycode:master Nov 6, 2015
jamo added a commit that referenced this pull request Nov 6, 2015
This reverts commit fdad46d, reversing
changes made to cf7c78c.
jamo added a commit that referenced this pull request Nov 6, 2015
Revert "Merge pull request #34 from DarthKipsu/lang-syntax"
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

Successfully merging this pull request may close these issues.

2 participants