diff --git a/Erlang.plist b/Erlang.plist index d914a6f..a3fb925 100644 --- a/Erlang.plist +++ b/Erlang.plist @@ -813,6 +813,14 @@ include #atom + + include + #sigil-docstring + + + include + #sigil-string + include #docstring @@ -1788,6 +1796,87 @@ + internal-string-body + + patterns + + + captures + + 1 + + name + punctuation.definition.escape.erlang + + 3 + + name + punctuation.definition.escape.erlang + + + comment + escape sequence + match + (\\)([bdefnrstv\\'"]|(\^)[@-_a-z]|[0-7]{1,3}|x[\da-fA-F]{2}) + name + constant.character.escape.erlang + + + match + \\\^?.? + name + invalid.illegal.string.erlang + + + captures + + 1 + + name + punctuation.definition.placeholder.erlang + + 10 + + name + punctuation.separator.placeholder-parts.erlang + + 6 + + name + punctuation.separator.placeholder-parts.erlang + + + comment + io:fwrite format contorl sequence + match + (~)((\-)?\d++|(\*))?((\.)(\d++|(\*))?((\.)((\*)|.))?)?[tlkK]*[~cfegswpWPBX#bx\+ni] + name + constant.character.format.placeholder.other.erlang + + + captures + + 1 + + name + punctuation.definition.placeholder.erlang + + + comment + io:fread format contorl sequence + match + (~)(\*)?(\d++)?(t)?[~du\-#fsacl] + name + constant.character.format.placeholder.other.erlang + + + match + ~[^"]? + name + invalid.illegal.string.erlang + + + internal-type-specifiers begin @@ -2770,106 +2859,1039 @@ - string + sigil-docstring + + comment + It is possible to use more than 3 double quote characters as beginning and closing sequences (must be the same). Cover 3-9 characters here. + patterns + + + include + #sigil-docstring3 + + + include + #sigil-docstring4 + + + include + #sigil-docstring5 + + + include + #sigil-docstring6 + + + include + #sigil-docstring7 + + + include + #sigil-docstring8 + + + include + #sigil-docstring9 + + + + sigil-docstring3 begin - (") + (~[bBsS]?)(["]{3}\s*)$ beginCaptures 1 name - punctuation.definition.string.begin.erlang + storage.type.string.erlang + + 2 + + name + punctuation.definition.docstring.begin.erlang + comment + Only whitespace characters are allowed after the beggining and before the closing sequences and those cannot be in the same line end - (") + ^(\s*["]{3})(?!") endCaptures 1 name - punctuation.definition.string.end.erlang + punctuation.definition.docstring.end.erlang name - string.quoted.double.erlang - patterns - + string.string.docstring.multi.erlang + + sigil-docstring4 + + begin + (~[bBsS]?)(["]{4}\s*)$ + beginCaptures + + 1 - captures - - 1 - - name - punctuation.definition.escape.erlang - - 3 - - name - punctuation.definition.escape.erlang - - - comment - escape sequence - match - (\\)([bdefnrstv\\'"]|(\^)[@-_a-z]|[0-7]{1,3}|x[\da-fA-F]{2}) name - constant.character.escape.erlang + storage.type.string.erlang + 2 - match - \\\^?.? name - invalid.illegal.string.erlang + punctuation.definition.docstring.begin.erlang + + end + ^(\s*["]{4})(?!") + endCaptures + + 1 - captures - - 1 - - name - punctuation.definition.placeholder.erlang - - 10 - - name - punctuation.separator.placeholder-parts.erlang - - 6 - - name - punctuation.separator.placeholder-parts.erlang - - - comment - io:fwrite format contorl sequence - match - (~)((\-)?\d++|(\*))?((\.)(\d++|(\*))?((\.)((\*)|.))?)?[tlkK]*[~cfegswpWPBX#bx\+ni] name - constant.character.format.placeholder.other.erlang + punctuation.definition.docstring.end.erlang + + + name + string.string.docstring.multi.erlang + + sigil-docstring5 + + begin + (~[bBsS]?)(["]{5}\s*)$ + beginCaptures + + 1 + + name + storage.type.string.erlang + 2 - captures - - 1 - - name - punctuation.definition.placeholder.erlang - - - comment - io:fread format contorl sequence - match - (~)(\*)?(\d++)?(t)?[~du\-#fsacl] name - constant.character.format.placeholder.other.erlang + punctuation.definition.docstring.begin.erlang + + + end + ^(\s*["]{5})(?!") + endCaptures + + 1 + + name + punctuation.definition.docstring.end.erlang + + name + string.string.docstring.multi.erlang + + sigil-docstring6 + + begin + (~[bBsS]?)(["]{6}\s*)$ + beginCaptures + + 1 - match - ~[^"]? name - invalid.illegal.string.erlang + storage.type.string.erlang + + 2 + + name + punctuation.definition.docstring.begin.erlang + + + end + ^(\s*["]{6})(?!") + endCaptures + + 1 + + name + punctuation.definition.docstring.end.erlang + + + name + string.string.docstring.multi.erlang + + sigil-docstring7 + + begin + (~[bBsS]?)(["]{7}\s*)$ + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.docstring.begin.erlang + + + end + ^(\s*["]{7})(?!") + endCaptures + + 1 + + name + punctuation.definition.docstring.end.erlang + + + name + string.string.docstring.multi.erlang + + sigil-docstring8 + + begin + (~[bBsS]?)(["]{8}\s*)$ + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.docstring.begin.erlang + + + end + ^(\s*["]{8})(?!") + endCaptures + + 1 + + name + punctuation.definition.docstring.end.erlang + + + name + string.string.docstring.multi.erlang + + sigil-docstring9 + + begin + (~[bBsS]?)(["]{9}\s*)$ + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.docstring.begin.erlang + + + end + ^(\s*["]{9})(?!") + endCaptures + + 1 + + name + punctuation.definition.docstring.end.erlang + + + name + string.string.docstring.multi.erlang + + sigil-string + + patterns + + + include + #sigil-string-parenthesis + + + include + #sigil-string-parenthesis-verbatim + + + include + #sigil-string-curly-brackets + + + include + #sigil-string-curly-brackets-verbatim + + + include + #sigil-string-square-brackets + + + include + #sigil-string-square-brackets-verbatim + + + include + #sigil-string-less-greater + + + include + #sigil-string-less-greater-verbatim + + + include + #sigil-string-slash + + + include + #sigil-string-slash-verbatim + + + include + #sigil-string-pipe + + + include + #sigil-string-pipe-verbatim + + + include + #sigil-string-single-quote + + + include + #sigil-string-single-quote-verbatim + + + include + #sigil-string-double-quote + + + include + #sigil-string-double-quote-verbatim + + + include + #sigil-string-backtick + + + include + #sigil-string-backtick-verbatim + + + include + #sigil-string-hashmark + + + include + #sigil-string-hashmark-verbatim + + + + sigil-string-backtick + + begin + (~[bs]?)(`) + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.string.begin.erlang + + + end + (`) + endCaptures + + 1 + + name + punctuation.definition.string.end.erlang + + + name + string.quoted.backtick.erlang + patterns + + + include + #internal-string-body + + + + sigil-string-backtick-verbatim + + begin + (~[BS])(`) + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.string.begin.erlang + + + end + (`) + endCaptures + + 1 + + name + punctuation.definition.string.end.erlang + + + name + string.quoted.backtick.erlang + + sigil-string-curly-brackets + + begin + (~[bs]?)([{]) + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.string.begin.erlang + + + end + ([}]) + endCaptures + + 1 + + name + punctuation.definition.string.end.erlang + + + name + string.quoted.curly-brackets.erlang + patterns + + + include + #internal-string-body + + + + sigil-string-curly-brackets-verbatim + + begin + (~[BS])([{]) + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.string.begin.erlang + + + end + ([}]) + endCaptures + + 1 + + name + punctuation.definition.string.end.erlang + + + name + string.quoted.curly-brackets.erlang + + sigil-string-double-quote + + begin + (~[bs]?)(") + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.string.begin.erlang + + + end + (") + endCaptures + + 1 + + name + punctuation.definition.string.end.erlang + + + name + string.quoted.double.erlang + patterns + + + include + #internal-string-body + + + + sigil-string-double-quote-verbatim + + begin + (~[BS])(") + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.string.begin.erlang + + + end + (") + endCaptures + + 1 + + name + punctuation.definition.string.end.erlang + + + name + string.quoted.double.erlang + + sigil-string-hashmark + + begin + (~[bs]?)(#) + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.string.begin.erlang + + + end + (#) + endCaptures + + 1 + + name + punctuation.definition.string.end.erlang + + + name + string.quoted.hashmark.erlang + patterns + + + include + #internal-string-body + + + + sigil-string-hashmark-verbatim + + begin + (~[BS])(#) + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.string.begin.erlang + + + end + (#) + endCaptures + + 1 + + name + punctuation.definition.string.end.erlang + + + name + string.quoted.hashmark.erlang + + sigil-string-less-greater + + begin + (~[bs]?)(<) + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.string.begin.erlang + + + end + (>) + endCaptures + + 1 + + name + punctuation.definition.string.end.erlang + + + name + string.quoted.less-greater.erlang + patterns + + + include + #internal-string-body + + + + sigil-string-less-greater-verbatim + + begin + (~[BS])(<) + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.string.begin.erlang + + + end + (>) + endCaptures + + 1 + + name + punctuation.definition.string.end.erlang + + + name + string.quoted.less-greater.erlang + + sigil-string-parenthesis + + begin + (~[bs]?)([(]) + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.string.begin.erlang + + + end + ([)]) + endCaptures + + 1 + + name + punctuation.definition.string.end.erlang + + + name + string.quoted.parenthesis.erlang + patterns + + + include + #internal-string-body + + + + sigil-string-parenthesis-verbatim + + begin + (~[BS])([(]) + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.string.begin.erlang + + + end + ([)]) + endCaptures + + 1 + + name + punctuation.definition.string.end.erlang + + + name + string.quoted.parenthesis.erlang + + sigil-string-pipe + + begin + (~[bs]?)([|]) + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.string.begin.erlang + + + end + ([|]) + endCaptures + + 1 + + name + punctuation.definition.string.end.erlang + + + name + string.quoted.pipe.erlang + patterns + + + include + #internal-string-body + + + + sigil-string-pipe-verbatim + + begin + (~[BS])([|]) + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.string.begin.erlang + + + end + ([|]) + endCaptures + + 1 + + name + punctuation.definition.string.end.erlang + + + name + string.quoted.pipe.erlang + + sigil-string-single-quote + + begin + (~[bs]?)(') + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.string.begin.erlang + + + end + (') + endCaptures + + 1 + + name + punctuation.definition.string.end.erlang + + + name + string.quoted.single.erlang + patterns + + + include + #internal-string-body + + + + sigil-string-single-quote-verbatim + + begin + (~[BS])(') + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.string.begin.erlang + + + end + (') + endCaptures + + 1 + + name + punctuation.definition.string.end.erlang + + + name + string.quoted.single.erlang + + sigil-string-slash + + begin + (~[bs]?)(/) + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.string.begin.erlang + + + end + (/) + endCaptures + + 1 + + name + punctuation.definition.string.end.erlang + + + name + string.quoted.slash.erlang + patterns + + + include + #internal-string-body + + + + sigil-string-slash-verbatim + + begin + (~[BS])(/) + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.string.begin.erlang + + + end + (/) + endCaptures + + 1 + + name + punctuation.definition.string.end.erlang + + + name + string.quoted.slash.erlang + + sigil-string-square-brackets + + begin + (~[bs]?)([\[]) + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.string.begin.erlang + + + end + ([\]]) + endCaptures + + 1 + + name + punctuation.definition.string.end.erlang + + + name + string.quoted.square-brackets.erlang + patterns + + + include + #internal-string-body + + + + sigil-string-square-brackets-verbatim + + begin + (~[BS])([\[]) + beginCaptures + + 1 + + name + storage.type.string.erlang + + 2 + + name + punctuation.definition.string.begin.erlang + + + end + ([\]]) + endCaptures + + 1 + + name + punctuation.definition.string.end.erlang + + + name + string.quoted.square-brackets.erlang + + string + + begin + (") + beginCaptures + + 1 + + name + punctuation.definition.string.begin.erlang + + + end + (") + endCaptures + + 1 + + name + punctuation.definition.string.end.erlang + + + name + string.quoted.double.erlang + patterns + + + include + #internal-string-body diff --git a/samples/sigil.erl b/samples/sigil.erl new file mode 100644 index 0000000..4f6ba11 --- /dev/null +++ b/samples/sigil.erl @@ -0,0 +1,127 @@ +-module(sigil). + +-export([f/0, g/0]). + +-doc """ + Sigil examples + """. +-spec f() -> ok. +f() -> + ~(monkey ~2..0b\n), + ~b(monkey ~2..0b\n), + ~B(monkey ~2..0b\n), % verbatim + ~s(monkey ~2..0b\n), + ~S(monkey ~2..0b\n), % verbatim + + ~{monkey ~2..0b\n}, + ~b{monkey ~2..0b\n}, + ~B{monkey ~2..0b\n}, % verbatim + ~s{monkey ~2..0b\n}, + ~S{monkey ~2..0b\n}, % verbatim + + ~[monkey ~2..0b\n], + ~b[monkey ~2..0b\n], + ~B[monkey ~2..0b\n], % verbatim + ~s[monkey ~2..0b\n], + ~S[monkey ~2..0b\n], % verbatim + + ~, + ~b, + ~B, % verbatim + ~s, + ~S, % verbatim + + ~/monkey ~2..0b\n/, + ~b/monkey ~2..0b\n/, + ~B/monkey ~2..0b\n/, % verbatim + ~s/monkey ~2..0b\n/, + ~S/monkey ~2..0b\n/, % verbatim + + ~|monkey ~2..0b\n|, + ~b|monkey ~2..0b\n|, + ~B|monkey ~2..0b\n|, % verbatim + ~s|monkey ~2..0b\n|, + ~S|monkey ~2..0b\n|, % verbatim + + ~'monkey ~2..0b\n', + ~b'monkey ~2..0b\n', + ~B'monkey ~2..0b\n', % verbatim + ~s'monkey ~2..0b\n', + ~S'monkey ~2..0b\n', % verbatim + + ~"monkey ~2..0b\n", + ~b"monkey ~2..0b\n", + ~B"monkey ~2..0b\n", % verbatim + ~s"monkey ~2..0b\n", + ~S"monkey ~2..0b\n", % verbatim + + ~`monkey ~2..0b\n`, + ~b`monkey ~2..0b\n`, + ~B`monkey ~2..0b\n`, % verbatim + ~s`monkey ~2..0b\n`, + ~S`monkey ~2..0b\n`, % verbatim + + ~#monkey ~2..0b\n#, + ~b#monkey ~2..0b\n#, + ~B#monkey ~2..0b\n#, % verbatim + ~s#monkey ~2..0b\n#, + ~S#monkey ~2..0b\n#, % verbatim + + X = lists:seq(1,3), % just to check is syntax highlight is still ok + ok. + +-spec g() -> ok. % just to check is syntax highlight is still ok +g() -> + ~""" + monkey ~2..0b\n + business + """, + ~b"""" + monkey ~2..0b\n + """ + business + """", + ~B""""" + monkey ~2..0b\n + """ + business + """"", + ~s"""""" + monkey ~2..0b\n + """ + business + """""", + ~S""""""" + monkey ~2..0b\n + """ + business + """"""", + X = lists:seq(1,3), % just to check is syntax highlight is still ok + + <<"\"\\µA\""/utf8>> = <<$",$\\,194,181,$A,$">> = + ~b""" + "\\µA" + """ = ~b'"\\µA"' = + ~B""" + "\µA" + """ = ~B<"\µA"> = + ~""" + "\µA" + """ = ~"\"\\µA\"" = ~/"\\µA"/ + X = lists:seq(1,3), % just to check is syntax highlight is still ok + + [$",$\\,$µ,$A,$"] = + ~s""" + "\\µA" + """ = ~s"\"\\µA\"" = ~s["\\µA"] = + ~S""" + "\µA" + """ = ~S("\µA") = + """ + "\µA" + """ = "\"\\µA\"" + X = lists:seq(1,3), % just to check is syntax highlight is still ok + + ok. + +-define(THIS_IS_THE_END, "end").