tree-sitter-objectscript 1.9.22 → 1.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/common/scanner.h CHANGED
@@ -314,6 +314,93 @@ static bool is_statement_or_class_keyword(const int32_t *text, uint32_t len) {
314
314
  return false;
315
315
  }
316
316
 
317
+ // Consumes an ObjectScript interpolation (#(...)# or ##(...)##) embedded in
318
+ // &html/&xml text. Assumes lookahead is '#'. Inside the parens, '>' and '\''
319
+ // are ObjectScript operators, not XML syntax, so they must not be treated as
320
+ // tag ends or attribute quotes.
321
+ static void skip_cos_interpolation(TSLexer *lexer) {
322
+ advance(lexer);
323
+ if (lexer->lookahead == '#') {
324
+ advance(lexer);
325
+ }
326
+ if (lexer->lookahead != '(') {
327
+ return;
328
+ }
329
+ int depth = 0;
330
+ while (!lexer->eof(lexer) && lexer->lookahead != '\n') {
331
+ int32_t c = lexer->lookahead;
332
+ if (c == '"') {
333
+ advance(lexer);
334
+ while (!lexer->eof(lexer) && lexer->lookahead != '\n') {
335
+ if (lexer->lookahead == '"') {
336
+ advance(lexer);
337
+ if (lexer->lookahead != '"') {
338
+ break;
339
+ }
340
+ }
341
+ advance(lexer);
342
+ }
343
+ continue;
344
+ }
345
+ advance(lexer);
346
+ if (c == '(') {
347
+ depth++;
348
+ } else if (c == ')') {
349
+ depth--;
350
+ if (depth == 0) {
351
+ break;
352
+ }
353
+ }
354
+ }
355
+ // consume the closing # (or ##)
356
+ if (lexer->lookahead == '#') {
357
+ advance(lexer);
358
+ if (lexer->lookahead == '#') {
359
+ advance(lexer);
360
+ }
361
+ }
362
+ }
363
+
364
+ // Consumes the rest of an XML tag up to (not including) the closing '>'.
365
+ // A quote only opens an attribute value directly after '=', so stray quotes in
366
+ // hand-written HTML (e.g. height=24") don't swallow the rest of the file.
367
+ static void skip_xml_tag_body(TSLexer *lexer) {
368
+ int32_t prev = 0;
369
+ while (!lexer->eof(lexer) && lexer->lookahead != '>') {
370
+ int32_t c = lexer->lookahead;
371
+ if (c == '#') {
372
+ skip_cos_interpolation(lexer);
373
+ prev = '#';
374
+ continue;
375
+ }
376
+ if ((c == '"' || c == '\'') && prev == '=') {
377
+ advance(lexer);
378
+ while (!lexer->eof(lexer)) {
379
+ if (lexer->lookahead == '#') {
380
+ skip_cos_interpolation(lexer);
381
+ continue;
382
+ }
383
+ if (lexer->lookahead == c) {
384
+ advance(lexer);
385
+ if (lexer->lookahead == c) {
386
+ advance(lexer);
387
+ } else {
388
+ break;
389
+ }
390
+ } else {
391
+ advance(lexer);
392
+ }
393
+ }
394
+ prev = c;
395
+ continue;
396
+ }
397
+ if (!iswspace(c)) {
398
+ prev = c;
399
+ }
400
+ advance(lexer);
401
+ }
402
+ }
403
+
317
404
  static bool lex_fenced_text(TSLexer *lexer,
318
405
  enum ObjectScript_Core_Scanner_TokenType desired_symbol, int32_t l_delim,
319
406
  int32_t r_delim, bool is_xml, bool has_python_comment, bool is_text) {
@@ -338,6 +425,10 @@ static bool lex_fenced_text(TSLexer *lexer,
338
425
  advance(lexer);
339
426
  }
340
427
  int32_t c = lexer->lookahead;
428
+ if (c == '#' && is_xml) {
429
+ skip_cos_interpolation(lexer);
430
+ continue;
431
+ }
341
432
  if (c == '<' && is_xml) {
342
433
  bool comment = true;
343
434
  bool is_code = false;
@@ -417,27 +508,7 @@ static bool lex_fenced_text(TSLexer *lexer,
417
508
  }
418
509
  advance(lexer);
419
510
  }
420
- while (!lexer->eof(lexer) && lexer->lookahead != '>') {
421
- if (lexer->lookahead == '"' || lexer->lookahead == '\'') {
422
- int32_t quote = lexer->lookahead;
423
- advance(lexer);
424
- while (!lexer->eof(lexer)) {
425
- if (lexer->lookahead == quote) {
426
- advance(lexer);
427
- if (lexer->lookahead == quote) {
428
- advance(lexer);
429
- } else {
430
- break;
431
- }
432
- } else {
433
- advance(lexer);
434
- }
435
- }
436
- continue;
437
- }
438
- advance(lexer);
439
- continue;
440
- }
511
+ skip_xml_tag_body(lexer);
441
512
  if (lexer->lookahead == '>') {
442
513
  advance(lexer);
443
514
  }
@@ -470,27 +541,7 @@ static bool lex_fenced_text(TSLexer *lexer,
470
541
  }
471
542
 
472
543
  else {
473
- while (!lexer->eof(lexer) && lexer->lookahead != '>') {
474
- if (lexer->lookahead == '"' || lexer->lookahead == '\'') {
475
- int32_t quote = lexer->lookahead;
476
- advance(lexer);
477
- while (!lexer->eof(lexer)) {
478
- if (lexer->lookahead == quote) {
479
- advance(lexer);
480
- if (lexer->lookahead == quote) {
481
- advance(lexer);
482
- } else {
483
- break;
484
- }
485
- } else {
486
- advance(lexer);
487
- }
488
- }
489
- continue;
490
- }
491
- advance(lexer);
492
- continue;
493
- }
544
+ skip_xml_tag_body(lexer);
494
545
  // consume the >
495
546
  advance(lexer);
496
547
  continue;
package/core/grammar.js CHANGED
@@ -895,8 +895,14 @@ module.exports = grammar(objectscript_expr, {
895
895
  $.expression,
896
896
  ),
897
897
  ),
898
+ // #dim is a compile-time declaration, so IRIS allows it between the
899
+ // try block and its catch.
898
900
  command_trycatch: ($) =>
899
- seq(build_block_no_params($, $.keyword_try), $.catch_block),
901
+ seq(
902
+ build_block_no_params($, $.keyword_try),
903
+ repeat($.pound_dim),
904
+ $.catch_block,
905
+ ),
900
906
 
901
907
  catch_block: ($) =>
902
908
  build_block($, $.keyword_catch, build_arguments($._target_var_arg)),
@@ -1161,6 +1161,10 @@
1161
1161
  "type": "post_conditional",
1162
1162
  "named": true
1163
1163
  },
1164
+ {
1165
+ "type": "pound_dim",
1166
+ "named": true
1167
+ },
1164
1168
  {
1165
1169
  "type": "statement",
1166
1170
  "named": true
package/core/src/parser.c CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/core/src/parser.c
3
- size: 44871078 bytes
4
- sha256: 8423e58ee56778fbc8bc68c35bcf9655568436dacea06337fca933c829fc18b5
3
+ size: 45411547 bytes
4
+ sha256: db4d938f4fa0731c1a1a4e9b3e4e6c15467fc1f895e5dcc2071fbe0351465e6b
package/expr/grammar.js CHANGED
@@ -304,7 +304,7 @@ module.exports = grammar({
304
304
  ),
305
305
  keyword_super: (_) => /##SUPER/i,
306
306
  superclass_method_call: ($) => seq($.keyword_super, $.method_args),
307
- expression_call: ($) => seq(alias(/##expression/i, $.keyword_pound_expression), $.method_args),
307
+ expression_call: ($) => seq(alias(choice(/##expression/i, /##safeexpression/i), $.keyword_pound_expression), $.method_args),
308
308
  extrinsic_function: ($) =>
309
309
  // $$tag^rtn or $$@var
310
310
  prec.left(seq('$$', $._extrinsic_reference, optional($.method_args))),