Permalink
Browse files

FIX: comment-like lines inside a string-block

CHANGE: going back to picky-comments, since my preprocessor was pretty wrong sometimes. Now things are all correct, just over picky.
HOWEVER - I did fix the biggest problem previously with pick comments. An indented comment after a statement no longer converts it into a funciton invocation.
ALL TESTS PASS
  • Loading branch information...
shanebdavis committed Sep 6, 2018
1 parent a0d2aca commit 16db9e02f7c380569402894108c5d8c4c8b573e7
@@ -106,4 +106,6 @@ class Preprocessors
source
@preprocess: (source) =>
@normalizeComments @normalizeIndentation source
# DISABLED - this needs to be applied at the block level
# @normalizeComments
@normalizeIndentation source
@@ -9,18 +9,28 @@ import &StandardImport
{} pattern: "/##[^\n]*/ unparsedBlock*"
{} pattern: /\ *#([^\n$\w\u007f-\uffff]+[^\n]*|(?=\n|$))/
##
Statement-ends are:
new-line "\n"
end-of-buffer ($)
semi-column ";"
close-parenthesis ")"
NOTE: A close-parenthesis can be considered an 'end'
WHY? It's needed to make this parse: (-> 1)
Without it, the "1" wouldn't be a statement.
NOTE: The close-paren is not 'consumed' by this regexp.
_end:
///
(\ * (\n | ;\ * | $) )+
|
(\ * (?=\)))
# A close-parenthesis can be considered an 'end'
# This is makes this parse: (-> 1).
# Without it, the "1" wouldn't be a statement.
# NOTE: the close-paren is not 'consumed' by this regexp.
lineStartComment: "comment _end" "_end"
lineEndComment: "_? comment? _end lineStartComment*"
# commenting this out breacks compiling: LiteralStrings.caf
{} getPresent: ~> false
onlyCommentsRemain: "lineEndComment /$/"
@@ -60,8 +60,8 @@ multilineRegExpEscape:
multilineRegExpComment:
pattern: "/^|\\n|\\s/ comment" #/(^|\n|\s)+#(?!\{)[^\n]+[\s\n]*/
stnFactory: :StringStn
stnProps: ~> value: ""
# stnFactory: :StringStn
# stnProps: ~> value: ""
multilineRegExpInterpolation:
pattern: "/ */ interpolationStart expression interpolationEnd"
@@ -6,7 +6,7 @@ import &StandardImport, &CaffeineEight
@rule
valueListBlock: Extensions.IndentBlocks.getPropsToSubparseBlock rule: "valueListBlockSubParse"
valueListBlockSubParse: "end* listItemStatement*"
valueListBlockSubParse: "end* listItemStatement+"
@rule
simpleValueList:
@@ -149,8 +149,7 @@ Caf.defMod(module, () => {
lines.join("\n"))
: source;
};
this.preprocess = source =>
this.normalizeComments(this.normalizeIndentation(source));
this.preprocess = source => this.normalizeIndentation(source);
}
));
}
@@ -19,7 +19,8 @@ Caf.defMod(module, () => {
getPresent: function() {
return false;
}
}
},
{ onlyCommentsRemain: "lineEndComment /$/" }
);
};
})();
@@ -65,13 +65,7 @@ Caf.defMod(module, () => {
return { value: this.text === "\\ " ? " " : this.text };
}
},
multilineRegExpComment: {
pattern: "/^|\\n|\\s/ comment",
stnFactory: "StringStn",
stnProps: function() {
return { value: "" };
}
},
multilineRegExpComment: { pattern: "/^|\\n|\\s/ comment" },
multilineRegExpInterpolation: {
pattern: "/ */ interpolationStart expression interpolationEnd"
},
@@ -11,7 +11,7 @@ Caf.defMod(module, () => {
valueListBlock: Extensions.IndentBlocks.getPropsToSubparseBlock({
rule: "valueListBlockSubParse"
}),
valueListBlockSubParse: "end* listItemStatement*"
valueListBlockSubParse: "end* listItemStatement+"
});
this.rule({
simpleValueList: [
@@ -392,6 +392,11 @@ module.exports = suite: parseTestSuite
thing.
''': '`This\\nthat and the ${Caf.toString(b)}\\nthing.`;'
regressions:
"""
""
# looks like a comment but its not
""": '"# looks like a comment but its not";'
interpolated:
basic:
'"${#{foo}}"': '`\\${${Caf.toString(foo)}}`;'
@@ -413,4 +418,5 @@ module.exports = suite: parseTestSuite
1
2
}there"
""": "`hi${Caf.toString([1, 2])}there`;"
""": "`hi${Caf.toString([1, 2])}there`;"

0 comments on commit 16db9e0

Please sign in to comment.