Skip to content

Commit

Permalink
Handle whitespace with builtin function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Beaglefoot committed Nov 1, 2024
1 parent 553fdc4 commit 595ef1c
Show file tree
Hide file tree
Showing 6 changed files with 142,641 additions and 93,960 deletions.
1 change: 1 addition & 0 deletions grammar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ declare interface IRules {
func_def: ($: IRules & IExternals) => any;
param_list: ($: IRules & IExternals) => any;
func_call: ($: IRules & IExternals) => any;
_builtin_func_call: ($: IRules & IExternals) => any;
indirect_func_call: ($: IRules & IExternals) => any;
args: ($: IRules & IExternals) => any;
comment: ($: IRules & IExternals) => any;
Expand Down
57 changes: 53 additions & 4 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,11 +441,60 @@ module.exports = grammar({
param_list: $ => seq($.identifier, repeat(seq(',', optional($.comment), $.identifier))),

func_call: $ =>
choice(
seq(
field('name', choice($.identifier, $.ns_qualified_name)),
// Otherwise $.concatenating_space takes precedence
$._func_call,
token.immediate('('),
optional($.args),
')'
),
$._builtin_func_call
),

_builtin_func_call: $ =>
seq(
field('name', choice($.identifier, $.ns_qualified_name)),
// Otherwise $.concatenating_space takes precedence
$._func_call,
token.immediate('('),
choice(
'and',
'asort',
'asorti',
'bindtextdomain',
'compl',
'cos',
'dcgettext',
'dcngettext',
'exp',
'gensub',
'gsub',
'index',
'int',
'isarray',
'length',
'log',
'lshift',
'match',
'mktime',
'or',
'patsplit',
'rand',
'rshift',
'sin',
'split',
'sprintf',
'sqrt',
'srand',
'strftime',
'strtonum',
'sub',
'substr',
'systime',
'tolower',
'toupper',
'typeof',
'xor'
),
'(',
optional($.args),
')'
),
Expand Down
229 changes: 208 additions & 21 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 595ef1c

Please sign in to comment.