Skip to content

Commit

Permalink
possible fix for #39
Browse files Browse the repository at this point in the history
  • Loading branch information
EmranMR committed Dec 2, 2023
1 parent 763b95e commit a54fb1e
Show file tree
Hide file tree
Showing 5 changed files with 133,728 additions and 131,252 deletions.
48 changes: 0 additions & 48 deletions corpus/envoy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,6 @@
(php_statement
(directive_start)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(directive_end)))

================================================================================
Expand All @@ -166,12 +160,6 @@
(php_statement
(directive_start)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(directive_end)))

================================================================================
Expand All @@ -190,12 +178,6 @@
(php_statement
(directive_start)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(directive_end)))

================================================================================
Expand Down Expand Up @@ -230,12 +212,6 @@
(php_statement
(directive_start)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(directive_end)))

================================================================================
Expand All @@ -259,12 +235,6 @@
(parameter)
(bracket_end)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(directive_end)))

================================================================================
Expand All @@ -288,12 +258,6 @@
(parameter)
(bracket_end)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(directive_end)))

================================================================================
Expand All @@ -317,12 +281,6 @@
(parameter)
(bracket_end)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(directive_end)))

================================================================================
Expand All @@ -346,10 +304,4 @@
(parameter)
(bracket_end)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(php_only)
(directive_end)))
3 changes: 2 additions & 1 deletion corpus/php-statements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ multi line raw
================================================================================

@php
echo 'test'
$name = $attributes->get('name');
$value = resolve_input($name, $value, empty($model) ? null : $model, $useOld);
@endphp

--------------------------------------------------------------------------------
Expand Down
76 changes: 27 additions & 49 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ module.exports = grammar({
$._inline_directive,
$._nested_directive,
$.loop_operator,
$.text
alias($._text, $.text)
),

comment: ($) => seq('{{--', optional(repeat($.text)), '--}}'),
comment: ($) =>
seq(
'{{--',
optional(repeat(alias($._text, $.text))),
'--}}'
),

// !keywords
keyword: ($) =>
Expand All @@ -36,13 +41,13 @@ module.exports = grammar({
_escaped: ($) =>
seq(
alias('{{', $.bracket_start),
optional(repeat(alias($.text, $.php_only))),
optional($.php_only),
alias('}}', $.bracket_end)
),
_unescaped: ($) =>
seq(
alias('{!!', $.bracket_start),
optional(repeat(alias($.text, $.php_only))),
optional($.php_only),
alias('!!}', $.bracket_end)
),

Expand All @@ -55,7 +60,7 @@ module.exports = grammar({
_multi_line_raw: ($) =>
seq(
alias('@php', $.directive_start),
optional(repeat(alias($.text, $.php_only))),
optional($.php_only),
alias('@endphp', $.directive_end)
),
// ! Conditional Attributes
Expand Down Expand Up @@ -399,7 +404,7 @@ module.exports = grammar({
_setup: ($) =>
seq(
alias('@setup', $.directive_start),
optional(repeat(alias($.text, $.php_only))),
optional($.php_only),
alias('@endsetup', $.directive_end)
),

Expand Down Expand Up @@ -429,66 +434,31 @@ module.exports = grammar({
_before: ($) =>
seq(
alias('@before', $.directive_start),
optional(
repeat(
choice(
$._notification,
alias($.text, $.php_only)
)
)
),
optional(repeat(choice($._notification, $.php_only))),
alias('@endbefore', $.directive_end)
),
_after: ($) =>
seq(
alias('@after', $.directive_start),
optional(
repeat(
choice(
$._notification,
alias($.text, $.php_only)
)
)
),
optional(repeat(choice($._notification, $.php_only))),
alias('@endafter', $.directive_end)
),
_envoy_error: ($) =>
seq(
alias('@error', $.directive_start),
optional(
repeat(
choice(
$._notification,
alias($.text, $.php_only)
)
)
),
optional(repeat(choice($._notification, $.php_only))),
alias('@enderror', $.directive_end)
),
_success: ($) =>
seq(
alias('@success', $.directive_start),
optional(
repeat(
choice(
$._notification,
alias($.text, $.php_only)
)
)
),
optional(repeat(choice($._notification, $.php_only))),
alias('@endsuccess', $.directive_end)
),
_finished: ($) =>
seq(
alias('@finished', $.directive_start),
optional(
repeat(
choice(
$._notification,
alias($.text, $.php_only)
)
)
),
optional(repeat(choice($._notification, $.php_only))),
alias('@endfinished', $.directive_end)
),

Expand Down Expand Up @@ -568,9 +538,17 @@ module.exports = grammar({
),
// !section parameters
_section_parameter: ($) =>
seq(optional(/[\"\']/), $.text, optional(/[\"\']/)),
// !text
text: ($) =>
seq(
optional(/[\"\']/),
alias($._text, $.text),
optional(/[\"\']/)
),

// !text definitions
php_only: ($) => prec.right(repeat1($._text)),
// hidden to reduce AST noise in php_only #39
// It is selectively unhidden for other areas
_text: ($) =>
choice(
token(prec(-1, /@[a-zA-Z\d]*[^\(-]/)), // custom directive conflict resolution
token(prec(-2, /[{}!@()?,-]/)), // orphan tags
Expand Down
Loading

0 comments on commit a54fb1e

Please sign in to comment.