Skip to content

tree-sitter language parser issues. safecall; stdcall; and $ in identifiers, and a few others, which ever can be fixed in a low impact way (will try to fix and pr) #19

@wpostma

Description

@wpostma

Testing tree-sitter against real-world files, I find the following common lex/parse failures.

Error Categories (all valid Delphi, all parser grammar gaps)

  ┌─────┬─────────────────────────────┬───────────────────────────┬─────────────────────────────────┬──────────┐
  │  #  │           Pattern           │       Error snippet       │         Files affected          │  Error   │
  │     │                             │                           │                                 │  count   │
  ├─────┼─────────────────────────────┼───────────────────────────┼─────────────────────────────────┼──────────┤
  │ 1   │ safecall calling convention │ function Get_x: IFoo;     │ MSHTML, MSHTML_TLB, WinRT,      │ ~25,400  │
  │     │  on interface methods       │ safecall;                 │ Nst_TLB, Word_TLB, mscorlib_TLB │          │
  ├─────┼─────────────────────────────┼───────────────────────────┼─────────────────────────────────┼──────────┤
  │ 2   │ Property re-publication (no │ property BorderStyle;     │ AdvGrid, AdvToolBar             │ ~2,100   │
  │     │  type/read/write)           │                           │                                 │          │
  ├─────┼─────────────────────────────┼───────────────────────────┼─────────────────────────────────┼──────────┤
  │ 3   │ Bare raise; (re-raise       │ raise;                    │ common                          │ ~5,000   │
  │     │ current exception)          │                           │                                 │          │
  ├─────┼─────────────────────────────┼───────────────────────────┼─────────────────────────────────┼──────────┤
  │ 4   │ $ in identifiers (JNI       │ val$transformer           │ Clover.JNI.AllClasses           │ ~1,900   │
  │     │ names)                      │                           │                                 │          │
  ├─────┼─────────────────────────────┼───────────────────────────┼─────────────────────────────────┼──────────┤
  │ 5   │ Heavy {$IFDEF} altering     │ {$ifdef X}record          │ mORMot, SynCommons              │ ~5,600   │
  │     │ syntax structure            │ {$else}object{$endif}     │                                 │          │
  ├─────┼─────────────────────────────┼───────────────────────────┼─────────────────────────────────┼──────────┤
  │ 6   │ align(N) on record          │ end align(16);            │ Winapi.Windows                  │ ~141     │
  │     │ declarations                │                           │                                 │          │
  ├─────┼─────────────────────────────┼───────────────────────────┼─────────────────────────────────┼──────────┤
  │ 7   │ Subrange with               │ -1..400;,                 │ UCrpe32                         │ 5        │
  │     │ negative/expression bounds  │ bsNone..bsDialog          │                                 │          │
  ├─────┼─────────────────────────────┼───────────────────────────┼─────────────────────────────────┼──────────┤
  │ 8   │ readonly on dispinterface   │ property X: Y readonly    │ mscorlib_TLB                    │ ~590     │
  │     │ properties                  │ dispid N;                 │                                 │          │
  ├─────┼─────────────────────────────┼───────────────────────────┼─────────────────────────────────┼──────────┤
  │ 9   │ ^L control char / write(f,  │ Turbo Pascal ^L form feed │ enquiryU                        │ 4        │
  │     │ ^L)                         │  literal                  │                                 │          │
  ├─────┼─────────────────────────────┼───────────────────────────┼─────────────────────────────────┼──────────┤
  │ 10  │ stdcall on nested function  │ function X(...): Y        │ UCrpe32                         │ 2        │
  │     │                             │ stdcall;                  │                                 │          │
  └─────┴─────────────────────────────┴───────────────────────────┴─────────────────────────────────┴──────────┘

I'm willing to try to contribute fixes to them, the first three seem trivial to fix.

function Get_x: IFoo;    safecall;

sample units affected: MSHTML, MSHTML_TLB, WinRT

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions