Skip to content

Commit

Permalink
Correct behaviour of ?page directives containing brackets embedded wi…
Browse files Browse the repository at this point in the history
…thin quotes.

If embedded brackets are in a single line directive (example ?page "Some notes (extra info)") the existing code matched a multi line directive but didn't finish it. This meant the rest of the file was parsed incorrectly.
  • Loading branch information
cnxguy authored Aug 19, 2020
1 parent 810c166 commit 0e44321
Showing 1 changed file with 51 additions and 49 deletions.
100 changes: 51 additions & 49 deletions syntaxes/tal.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,87 +102,89 @@
"1": { "name": "punctuation.accessor.tal" }
}
},
"compiler_directive":{
"compiler_directive": {
"comment": "TAL directive",
"begin": "^(\\?)",
"beginCaptures": {
"1": {
"name": "keyword.preprocessor.tal"
}
},
"end": "$",
"name": "meta.preprocessor.tal",
"patterns": [
{
"comment": "Multiline TAL directive. Match multiline directive and highlight procs inside.",
"begin": "^(\\?)(.*)\\(",
"beginCaptures": {
"include": "#punctuation_comma"
},
{
"include": "#strings"
},
{
"include": "#comments"
},
{
"include": "#compiler_directive_keyword"
}
]
},
"compiler_directive_keyword": {
"patterns": [
{
"comment": "?page directive that is followed by a string",
"match": "(?i)\\b(?<!\\^)(page)(?!\\^)\\b\\s*(\"[^\"]*\")?",
"captures": {
"1": {
"name": "keyword.preprocessor.tal"
},
"2": {
"patterns": [
{
"include": "#compiler_directive_keyword"
},
{
"include": "#punctuation_comma"
}
]
"name": "string.quoted.double.tal"
}
},
}
},
{
"comment": "Multiline TAL directive. Match multiline directive and highlight procs inside.",
"begin": "\\(",
"end": "\\)",
"name": "meta.preprocessor",
"name": "meta.preprocessor.multiline-directive.tal",
"patterns": [
{
"include": "#comments"
},
{
"match": "^(\\?)",
"name": "keyword.preprocessor.tal"
},
{
"match": "(?i)\\s*\\b([a-zA-Z\\^_][a-zA-Z0-9\\^_]*)",
"match": "(?i)^(\\?)\\s*\\b([a-zA-Z\\^_][a-zA-Z0-9\\^_]*)",
"name": "meta.function-import.tal",
"captures": {
"1": { "name": "entity.name.function.tal" }
"1": { "name": "keyword.preprocessor.tal" },
"2": { "name": "entity.name.function.tal" }
}
},
{
"match": "(?i)^(\\?)\\s*\\b([a-zA-Z\\^_][a-zA-Z0-9\\^_]*)",
"match": "(?i)^[^\\?]?\\s*\\b([a-zA-Z\\^_][a-zA-Z0-9\\^_]*)",
"name": "invalid.illegal.tal"
},
{
"match": "(?i)\\s*\\b([a-zA-Z\\^_][a-zA-Z0-9\\^_]*)",
"name": "meta.function-import.tal",
"captures": {
"2": { "name": "entity.name.function.tal" }
"1": { "name": "entity.name.function.tal" }
}
},
{
"include": "#punctuation_comma"
}
]
},
{
"comment": "TAL directive line. Match a single line directive line.",
"begin": "^(\\?)",
"beginCaptures": {
"1": {
"match": "^(\\?)",
"name": "keyword.preprocessor.tal"
}
},
"end": "$",
"name": "meta.preprocessor",
"patterns": [
{
"include": "#compiler_directive_keyword"
},
{
"include": "#punctuation_comma"
},
{
"include": "#strings"
},
{
"include": "#comments"
}
]
},
{
"name": "keyword.preprocessor.tal",
"match": "(?i)\\b(?<!\\^)(assertion|begincompilation|cpu|decs|definetog|dumpcons|(end)?if|ifnot|extendstack|compact|rp|section|source|(no)?list|(no)?code|inspect|symbols|(no)?(l)?map|gmap|(no)?crossref|innerlist|search)(?!\\^)\\b",
"comment": "Compiler directive keywords. Look behind to avoid matching ^keyword."
}
]
},
"compiler_directive_keyword": {
"name": "keyword.preprocessor.tal",
"match": "(?i)\\b(?<!\\^)(assertion|begincompilation|cpu|decs|definetog|dumpcons|(end)?if|ifnot|page|extendstack|compact|rp|section|source|(no)?list|(no)?code|inspect|symbols|(no)?(l)?map|gmap|(no)?crossref|innerlist|search)(?!\\^)\\b",
"comment": "Compiler directive keywords. Look behind to avoid matching ^keyword."
},
"comments": {
"patterns": [
{
Expand Down

0 comments on commit 0e44321

Please sign in to comment.