Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Don't accept spaces after heredoc beginning identifier. (was: Make Heredoc syntax highlighting work) #77

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 27 additions & 10 deletions grammars/php.cson
Expand Up @@ -436,7 +436,8 @@
'heredoc':
'patterns': [
{
'begin': '(?=<<<\\s*("?)([a-zA-Z_]+[a-zA-Z0-9_]*)(\\1)\\s*$)'
# [ \\t] was used instead of \\s because \\s will match a newline
'begin': '(?=<<<\\s*("?)([a-zA-Z_]+[a-zA-Z0-9_]*)(\\1)[ \\t]*$)'
'end': '(?!\\G)'
'injections':
'*':
Expand All @@ -453,7 +454,7 @@
]
}
{
'begin': '(?=<<<\\s*(\'?)([a-zA-Z_]+[a-zA-Z0-9_]*)(\\1)\\s*$)'
'begin': '(?=<<<\\s*\'([a-zA-Z_]+[a-zA-Z0-9_]*)\'[ \\t]*$)'
'end': '(?!\\G)'
'name': 'string.unquoted.heredoc.nowdoc.php'
'patterns': [
Expand All @@ -467,14 +468,16 @@
'heredoc_interior':
'patterns': [
{
'begin': '(<<<)\\s*([\'"]?)(HTML)(\\2)\\s*$\\n?'
'begin': '(<<<)\\s*([\'"]?)(HTML)(\\2)([ \\t]+)?$'
'beginCaptures':
'0':
'name': 'punctuation.section.embedded.begin.php'
'1':
'name': 'punctuation.definition.string.php'
'3':
'name': 'keyword.operator.heredoc.php'
'5':
'name': 'invalid.illegal.whitespace-in-end-of-line.php'
'contentName': 'text.html'
'end': '^(\\3)\\b'
'endCaptures':
Expand All @@ -490,14 +493,16 @@
]
}
{
'begin': '(<<<)\\s*([\'"]?)(XML)(\\2)\\s*$\\n?'
'begin': '(<<<)\\s*([\'"]?)(XML)(\\2)([ \\t]+)?$'
'beginCaptures':
'0':
'name': 'punctuation.section.embedded.begin.php'
'1':
'name': 'punctuation.definition.string.php'
'3':
'name': 'keyword.operator.heredoc.php'
'5':
'name': 'invalid.illegal.whitespace-in-end-of-line.php'
'contentName': 'text.xml'
'end': '^(\\3)\\b'
'endCaptures':
Expand All @@ -513,14 +518,16 @@
]
}
{
'begin': '(<<<)\\s*([\'"]?)(SQL)(\\2)\\s*$\\n?'
'begin': '(<<<)\\s*([\'"]?)(SQL)(\\2)([ \\t]+)?$'
'beginCaptures':
'0':
'name': 'punctuation.section.embedded.begin.php'
'1':
'name': 'punctuation.definition.string.php'
'3':
'name': 'keyword.operator.heredoc.php'
'5':
'name': 'invalid.illegal.whitespace-in-end-of-line.php'
'contentName': 'source.sql'
'end': '^(\\3)\\b'
'endCaptures':
Expand All @@ -536,14 +543,16 @@
]
}
{
'begin': '(<<<)\\s*([\'"]?)(JAVASCRIPT)(\\2)\\s*$\\n?'
'begin': '(<<<)\\s*([\'"]?)(JAVASCRIPT)(\\2)([ \\t]+)?$'
'beginCaptures':
'0':
'name': 'punctuation.section.embedded.begin.php'
'1':
'name': 'punctuation.definition.string.php'
'3':
'name': 'keyword.operator.heredoc.php'
'5':
'name': 'invalid.illegal.whitespace-in-end-of-line.php'
'contentName': 'source.js'
'end': '^(\\3)\\b'
'endCaptures':
Expand All @@ -559,14 +568,16 @@
]
}
{
'begin': '(<<<)\\s*([\'"]?)(JSON)(\\2)\\s*$\\n?'
'begin': '(<<<)\\s*([\'"]?)(JSON)(\\2)([ \\t]+)?$'
'beginCaptures':
'0':
'name': 'punctuation.section.embedded.begin.php'
'1':
'name': 'punctuation.definition.string.php'
'3':
'name': 'keyword.operator.heredoc.php'
'5':
'name': 'invalid.illegal.whitespace-in-end-of-line.php'
'contentName': 'source.json'
'end': '^(\\3)\\b'
'endCaptures':
Expand All @@ -582,14 +593,16 @@
]
}
{
'begin': '(<<<)\\s*([\'"]?)(CSS)(\\2)\\s*$\\n?'
'begin': '(<<<)\\s*([\'"]?)(CSS)(\\2)([ \\t]+)?$'
'beginCaptures':
'0':
'name': 'punctuation.section.embedded.begin.php'
'1':
'name': 'punctuation.definition.string.php'
'3':
'name': 'keyword.operator.heredoc.php'
'5':
'name': 'invalid.illegal.whitespace-in-end-of-line.php'
'contentName': 'source.css'
'end': '^(\\3)\\b'
'endCaptures':
Expand All @@ -605,14 +618,16 @@
]
}
{
'begin': '(<<<)\\s*([\'"]?)(REGEX)(\\2)\\s*$\\n?'
'begin': '(<<<)\\s*([\'"]?)(REGEX)(\\2)([ \\t]+)?$'
'beginCaptures':
'0':
'name': 'punctuation.section.embedded.begin.php'
'1':
'name': 'punctuation.definition.string.php'
'3':
'name': 'keyword.operator.heredoc.php'
'5':
'name': 'invalid.illegal.whitespace-in-end-of-line.php'
'contentName': 'string.regexp.heredoc.php'
'end': '^(\\3)\\b'
'endCaptures':
Expand Down Expand Up @@ -668,12 +683,14 @@
]
}
{
'begin': '(<<<)\\s*([\'"]?)([a-zA-Z_]+[a-zA-Z0-9_]*)(\\2)'
'begin': '(<<<)\\s*([\'"]?)([a-zA-Z_]+[a-zA-Z0-9_]*)(\\2)([ \\t]+)?'
'beginCaptures':
'1':
'name': 'punctuation.definition.string.php'
'3':
'name': 'keyword.operator.heredoc.php'
'5':
'name': 'invalid.illegal.whitespace-in-end-of-line.php'
'end': '^(\\3)\\b'
'endCaptures':
'1':
Expand Down