Skip to content

Commit

Permalink
Mostly formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueChip Bot committed Oct 10, 2023
1 parent 2378a3a commit b5f76c8
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 65 deletions.
128 changes: 64 additions & 64 deletions grammar.js
Original file line number Diff line number Diff line change
@@ -1,107 +1,107 @@
module.exports = grammar({
name: 'TypoScript',
name: 'TypoScript',

extras: $ => [/[\t ]/ ],
extras: $ => [/[\t ]/],

rules: {
rules: {

typoscript: $ => repeat(choice(
$._block_item
)),
typoscript: $ => repeat(choice(
$._block_item
)),

_block_item: $ => choice(
/\n/,
$.modification_line,
$.reference_line,
$.assignment_line,
$.deletion_line,
$.copy_line,
$.configuration_block,
$._imports,
$.condition_predefined,
$._condition_segment,
$.comment,
$.single_line_comment
),
_block_item: $ => choice(
/\n/,
$.modification_line,
$.reference_line,
$.assignment_line,
$.deletion_line,
$.copy_line,
$.configuration_block,
$._imports,
$.condition_predefined,
$._condition_segment,
$.comment,
$.single_line_comment
),

assignment_line: $ => seq($.identifier, '=', optional(choice($.cobject, $.value, $.multiline_value)), '\n'),
assignment_line: $ => seq($.identifier, '=', optional(choice($.cobject, $.value, $.multiline_value)), '\n'),

deletion_line: $ => seq($.identifier, '>', optional($._comments), '\n'),
deletion_line: $ => seq($.identifier, '>', optional($._comments), '\n'),

copy_line: $ => seq($.identifier, '<', alias($.identifier, $.copy_identifier), optional($._comments), '\n'),
copy_line: $ => seq($.identifier, '<', alias($.identifier, $.copy_identifier), optional($._comments), '\n'),

reference_line: $ => seq($.identifier, /=\s*</, alias($.identifier, $.reference_identifier), optional($._comments), '\n'),
reference_line: $ => seq($.identifier, /=\s*</, alias($.identifier, $.reference_identifier), optional($._comments), '\n'),

modification_line: $ => seq($.identifier, ':=', choice($.modifier_predefined, $.modifier_function), $.modifier_parameters, optional($._comments), '\n'),
modification_line: $ => seq($.identifier, ':=', choice($.modifier_predefined, $.modifier_function), $.modifier_parameters, optional($._comments), '\n'),

configuration_block: $ => seq($.identifier, $.block),
configuration_block: $ => seq($.identifier, $.block),

_condition_segment: $ => seq($.condition, optional($.condition_bool)),
_condition_segment: $ => seq($.condition, optional($.condition_bool)),

condition_bool: $ => choice('&&', '||', 'AND', 'OR'),
condition_bool: $ => choice('&&', '||', 'AND', 'OR'),

condition: $ => seq('[', $._condition_inner, ']'),
condition: $ => seq('[', $._condition_inner, ']'),

_condition_inner: $ => repeat1(choice($.constant, $.condition_bool, alias($.condition, 'bracket_parameter'), /[^\]]/)),
_condition_inner: $ => repeat1(choice($.constant, $.condition_bool, alias($.condition, 'bracket_parameter'), /[^\]]/)),

condition_predefined: $ => seq(/\[(end|else|global)\]/i, '\n'),
condition_predefined: $ => seq(/\[(end|else|global)\]/i, '\n'),

block: $ => seq(alias('{', $.block_punctuation), repeat($._block_item), alias('}', $.block_punctuation)),
block: $ => seq(alias('{', $.block_punctuation), repeat($._block_item), alias('}', $.block_punctuation)),

constant: $ => seq('{$', /[a-zA-Z0-9_\-\\\.]+/, '}'),
constant: $ => seq('{$', /[a-zA-Z0-9_\-\\\.]+/, '}'),

value: $ => repeat1(choice(/[^\n]/, $.constant)),
value: $ => repeat1(choice(/[^\n]/, $.constant)),

multiline_value: $ => stringWithConstants($, '(', ')', ')', true),
multiline_value: $ => stringWithConstants($, '(', ')', ')', true),

identifier: $ => /((?:\.)|(?:[a-zA-Z0-9_\-\\]+(?:\.[a-zA-Z0-9_\-\\]*)*))/,
identifier: $ => /((?:\.)|(?:[a-zA-Z0-9_\-\\]+(?:\.[a-zA-Z0-9_\-\\]*)*))/,

cobject: $ => /CASE|COA|COA_INT|CONTENT|EDITPANEL|FILE|FILES|FLUIDTEMPLATE|HMENU|TMENU|IMAGE|IMG_RESOURCE|LOAD_REGISTER|RECORDS|RESTORE_REGISTER|SVG|TEMPLATE|TEXT|USER|USER_INT|PAGE|EXTBASEPLUGIN/,
cobject: $ => /(?:CASE|COA|COA_INT|CONTENT|EDITPANEL|FILE|FILES|FLUIDTEMPLATE|HMENU|TMENU|IMAGE|IMG_RESOURCE|LOAD_REGISTER|RECORDS|RESTORE_REGISTER|SVG|TEMPLATE|TEXT|USER|USER_INT|PAGE|EXTBASEPLUGIN)/,

modifier_predefined: $ => /(prepend|append|remove|replace)String|(addTo|removeFrom|unique|reverse|sort)List/,
modifier_predefined: $ => /(prepend|append|remove|replace)String|(addTo|removeFrom|unique|reverse|sort)List/,

modifier_function: $ => /[a-zA-Z0-9_\-\\]+/,
modifier_function: $ => /[a-zA-Z0-9_\-\\]+/,

modifier_parameters: $ => seq("(", sep(",", $.modifier_parameter), ")"),
modifier_parameters: $ => seq("(", sep(",", $.modifier_parameter), ")"),

modifier_parameter: $ => repeat1(choice($.constant, /[^,\)]/, alias($.modifier_parameters, "function"))),
modifier_parameter: $ => repeat1(choice($.constant, /[^,\)]/, alias($.modifier_parameters, "function"))),

_comments: $ => choice($.comment, $.single_line_comment),
_comments: $ => choice($.comment, $.single_line_comment),

comment: $ => token(seq("/*", /[^*]*\*+([^/*][^*]*\*+)*/, "/")),
comment: $ => token(seq("/*", /[^*]*\*+([^/*][^*]*\*+)*/, "/")),

single_line_comment: $ => token(seq(choice("#", "//"), /.*/)),
single_line_comment: $ => token(seq(choice("#", "//"), /.*/)),

string: $ => choice(
stringWithConstants($, '"'),
stringWithConstants($, '\'')
),
string: $ => choice(
stringWithConstants($, '"'),
stringWithConstants($, '\'')
),

_imports: $ => choice($.import_legacy, $.import),
_imports: $ => choice($.import_legacy, $.import),

import_legacy: $ => seq("<", "INCLUDE_TYPOSCRIPT", ":", /\s*/, "source=", $.string, optional(seq(/\s+/, alias($.modifier_function, $.condition_attribute), '=', $.string)), ">"),
import_legacy: $ => seq("<", "INCLUDE_TYPOSCRIPT", ":", /\s*/, "source=", $.string, optional(seq(/\s+/, alias($.modifier_function, $.condition_attribute), '=', $.string)), ">"),

import: $ => seq('@import', $.string)
}
import: $ => seq('@import', $.string)
}
});

function stringWithConstants($, startString, endString, endStringForRegex) {
if(typeof(endString) === 'undefined') {
endString = startString;
}
if(typeof(endStringForRegex) === 'undefined') {
endStringForRegex = endString;
}
return seq(startString, optional(repeat1(choice(
$.constant,
new RegExp('[^\\'+endStringForRegex+']')
))), endString);
if (typeof (endString) === 'undefined') {
endString = startString;
}
if (typeof (endStringForRegex) === 'undefined') {
endStringForRegex = endString;
}
return seq(startString, optional(repeat1(choice(
$.constant,
new RegExp('[^\\' + endStringForRegex + ']')
))), endString);
}

function sep(separator, rule) {
return optional(sep1(separator, rule));
return optional(sep1(separator, rule));
}

function sep1(separator, rule) {
return seq(rule, repeat(seq(separator, rule)));
return seq(rule, repeat(seq(separator, rule)));
}
2 changes: 1 addition & 1 deletion src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@
},
"cobject": {
"type": "PATTERN",
"value": "CASE|COA|COA_INT|CONTENT|EDITPANEL|FILE|FILES|FLUIDTEMPLATE|HMENU|TMENU|IMAGE|IMG_RESOURCE|LOAD_REGISTER|RECORDS|RESTORE_REGISTER|SVG|TEMPLATE|TEXT|USER|USER_INT|PAGE|EXTBASEPLUGIN"
"value": "(?:CASE|COA|COA_INT|CONTENT|EDITPANEL|FILE|FILES|FLUIDTEMPLATE|HMENU|TMENU|IMAGE|IMG_RESOURCE|LOAD_REGISTER|RECORDS|RESTORE_REGISTER|SVG|TEMPLATE|TEXT|USER|USER_INT|PAGE|EXTBASEPLUGIN)"
},
"modifier_predefined": {
"type": "PATTERN",
Expand Down

0 comments on commit b5f76c8

Please sign in to comment.