-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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 Civet #873
Comments
Since both comment styles may exist in the same file, what, if anything, ends coffeeComment mode? |
coffeeComment mode lasts until the end of the file. There is no way to turn it back off. |
I'll need to write a custom parser for Civet. Please point me to some representative Civet files that I can work with. |
The Civet compiler itself is written in Civet, but I don't know how representative that is. I also have a few Civet projects, including Template Qdeql and my MarioKart build optimizer, but neither of those have coffeeCompat mode enabled. For a representative coffeeCompat file, you can probably take any CoffeeScript file and add 'civet coffeeCompat' or // @ts-nocheck
'civet coffeeCompat' to the top of it. |
One last question: must the triple slashes and triple pounds exist as a distinct set of three? In other words if a file contains |
|
Give 0563ada a try. Many corner cases seem possible; I didn't test them all. |
if ($coffeeComment) {
@step_4 = remove_matches($ra_lines, '^\s*#');
} else {
@step_1 = call_regexp_common($ra_lines, 'C');
@step_2 = remove_matches( \@step_1, '^///');
@step_3 = remove_matches( \@step_2, '^\s*//[^/]');
@step_4 = remove_between_general(\@step_3, '###', '###');
} This looks like it'll only detect |
Right, I added |
Here's some edge cases for block comments for you. All of the following files should parse successfully; all instances of
These will all also behave the same if you replace any line break with a space. However, if you remove some whitespace, things change:
|
The 3rd and 4th examples,
and
contradict each other: if
for the 3rd example but if |
Yep, they aren't handled one after the other, they're handled simultaneously in source order. |
"Simultaneously in source order..." that's a neat trick, but not one I'm going to try to implement. I'm hoping the existing implementation meets the "good enough" bar so I can close this out. |
If you want an unsupported language added, provide:
.civet
,.cvt
,.cvtx
"use strict";
.By default,
//
is line comments and/* ... */
is block comments, like in JS.///
may start a line comment only at the top level of the file; inside an indented block, it serves as a multiline regex delimiter.In coffeeComment mode, which is triggered by
"civet coffeeComment"
or"civet coffeeCompat"
, the above comment styles don't work, and instead line comments are marked with#
. Note that JS-style comments and"use strict"
may occur before this directive (but no other code can).In both modes,
### ... ###
is a valid block comment.If it weren't for the CoffeeScript compatibility mode, this would be fairly easy for me to add myself.
The text was updated successfully, but these errors were encountered: