Beaglefoot / tree-sitter-awk

GNU AWK grammar for tree-sitter
MIT License
19 stars 6 forks source link

Add support for `@variable.builtin` #10

Open lmburns opened 1 year ago

lmburns commented 1 year ago

Detect things like the following as @variable.builtin:

ARGC
ARGV
CONVFMT
ENVIRON
FILENAME
FS
NF
NR
FNR
OFMT
OFS
ORS
RLENGTH
RS
RSTART
SUBSEP
$0
$1 .. $n

Also, GNU awk specific variables like:

ARGIND
BINMODE
ERRNO
FIELDWIDTHS
IGNORECASE
LINT
PROCINFO
TEXTDOMAIN

Edit: Could also add more builtin functions for @function.builtin. Right now, the only ones that I see that are detected as builtin are getline and printf().

Arithmetic

atan2(y, x)
cos(expr)
exp(expr)
int(expr)
log(expr)
rand()
sin(expr)
sqrt(expr)
srand([expr])

String

asort(arr [, d [, how] ])
asorti(arr [, d [, how] ])
gsub(regex, sub, string)
index(str, sub)
length(str)
match(str, regex)
split(str, arr, regex)
printf(format, expr-list)
strtonum(str)
sub(regex, sub, string)
substr(str, start, l)
tolower(str)
toupper(str)

Time

systime()
mktime(datespec)
strftime([format [, timestamp[, utc-flag]]])

Bit Manipulation

and(n1, n2)
compl(n)
lshift(n1, n)
rshift(n1, n)
or(n1, n2)
xor(n1, n2)

Miscellaneous

close(expr)
fflush([out-expr])
getline
nextfile
system(fn)
Beaglefoot commented 1 year ago

Sorry I have no capacity to work on this issue. But PRs are welcome.