feat(gnuplot!): update parser and queries

Breaking change: full grammar rewrite for 2.0
This commit is contained in:
Christian Clason 2026-07-02 10:12:39 +02:00 committed by Christian Clason
parent 536de0c8ae
commit fc6ad62eab
2 changed files with 28 additions and 200 deletions

View file

@ -752,7 +752,7 @@ return {
}, },
gnuplot = { gnuplot = {
install_info = { install_info = {
revision = '1d331ed21d4100637272add1ff6ff6bda55828e7', revision = '20a98295a52caa5f474839838a800d250e8fe1f4',
url = 'https://github.com/dpezto/tree-sitter-gnuplot', url = 'https://github.com/dpezto/tree-sitter-gnuplot',
}, },
maintainers = { '@dpezto' }, maintainers = { '@dpezto' },

View file

@ -25,13 +25,11 @@
; separators and range/assign operators (anonymous tokens) ; separators and range/assign operators (anonymous tokens)
[ [
"="
"," ","
":" ":"
] @operator ] @operator
; assignment = (anonymous; eventual grammar.js refactor will make it (operator))
"=" @operator
(keyword_op) @keyword.operator (keyword_op) @keyword.operator
(ternary_op) @keyword.conditional.ternary (ternary_op) @keyword.conditional.ternary
@ -54,39 +52,36 @@
] @keyword ] @keyword
[ [
"via"
"inverse" "inverse"
"sample" "sample"
"sum" "kw_fn"
"at"
"from"
"to_rto"
"by"
"smooth"
] @keyword.function ] @keyword.function
[ "kw_cond" @keyword.conditional
"if"
"else"
] @keyword.conditional
[ [
"front" "front"
"back" "back"
"behind"
"depthorder" "depthorder"
"clip" "clip"
"noclip"
"opaque"
"font" "font"
"filled" "filled"
"nofilled" "nofilled"
"parallel" "parallel"
"reverse" "coord"
"invert"
"extend"
] @keyword.directive ] @keyword.directive
; on/off toggle flags ({no}X) — alias "flag"
"flag" @keyword.modifier
; enumerated VALUES / modes (alias "mod")
"mod" @keyword.modifier
; plot/splot ELEMENT modifiers (alias "attr") — @property
; (title/notitle/with/using/index/every/axes/smooth in a plot command;
; distinct from set-option names which are @variable.member)
"attr" @property
; ----------------------------------------------------------------------- ; -----------------------------------------------------------------------
; Terminal output path ; Terminal output path
"name" @variable.member "name" @variable.member
@ -94,26 +89,18 @@
; ----------------------------------------------------------------------- ; -----------------------------------------------------------------------
; Style attribute shorthands (K constants + datafile keywords) ; Style attribute shorthands (K constants + datafile keywords)
[ [
"as" "sa"
"dl"
"dt" "dt"
"fc" "fc"
"fs" "fs"
"lc" "lc"
"ls"
"lt" "lt"
"lw"
"pi"
"pn"
"ps" "ps"
"pt" "pt"
"tc" "tc"
"skip" "skip"
"every"
"index"
"using"
"with"
"expand" "expand"
"title"
] @variable.member ] @variable.member
; set/show argument keywords (all key("...", n, "arg") aliases) ; set/show argument keywords (all key("...", n, "arg") aliases)
@ -125,8 +112,6 @@
; coordinate systems / axes ; coordinate systems / axes
"unit" "unit"
"units_opt" "units_opt"
"plane"
"viewaxis"
"axes_opts" "axes_opts"
(columnheader) (columnheader)
; time units (set xdata time / timefmt) ; time units (set xdata time / timefmt)
@ -138,48 +123,22 @@
"months" "months"
"years" "years"
; smooth subtypes ; smooth subtypes
"discrete"
"incremental"
"unique"
"frequency"
"fnormal"
"cumulative"
"cnormal"
"csplines"
"acsplines"
"mcsplines"
"bezier"
"sbezier"
"path"
"kdensity" "kdensity"
"bandwidth"
"period"
"closed" "closed"
"between" "between"
"above" "above"
"below" "below"
"unwrap"
"grid"
; plot / datafile misc ; plot / datafile misc
"pixels" "pixels"
"whiskerbars" "whiskerbars"
"beginning" "beginning"
"long" "long"
"nogrid"
; colorspace
"RGB"
"CMY"
"HSV"
; positioning / key ; positioning / key
"base" "base"
"begin" "begin"
"center" "center"
"end" "end"
"keywidth"
"samplen"
"columns"
; pm3d / 3d options ; pm3d / 3d options
"ftriangles"
"clip1in" "clip1in"
"clip4in" "clip4in"
"c2c" "c2c"
@ -204,9 +163,7 @@
"origin" "origin"
"dx" "dx"
"dy" "dy"
"dz"
"width" "width"
"height"
"level" "level"
"matrix" "matrix"
"nonuniform" "nonuniform"
@ -241,80 +198,36 @@
"numbers" "numbers"
"trim" "trim"
"full" "full"
; pixmap
"colormap"
; coordinate system prefixes (position context) ; coordinate system prefixes (position context)
"first"
"second"
"graph"
"screen"
"character"
"axis" "axis"
; position direction aliases ; position direction aliases
"bot"
"cen" "cen"
"lef" "lef"
"rig" "rig"
"top"
; geometry / arrow options ; geometry / arrow options
"angle" "angle"
"radius"
"length" "length"
"head" "head"
"inout" "inout"
"polardistance"
; offset / scale ; offset / scale
"offset" "offset"
"nooffset" "nooffset"
"scale" "scale"
"relative"
"absolute"
; orientation
"vertical"
"horizontal"
; angle units
"degrees"
"radians"
"radial"
; contour / palette / axis ; contour / palette / axis
"levels"
"range" "range"
"defined"
"missing" "missing"
"interpolate" "interpolate"
"autofreq" "autofreq"
"autojustify" "autojustify"
"overlap"
; rotation ; rotation
"rotate" "rotate"
"norotate"
; border / extend / range modifiers ; border / extend / range modifiers
"border"
"noborder"
"noextend"
"writeback"
"restore" "restore"
; pm3d scan order ; pm3d scan order
"scanorder" "scanorder"
; histogram subtypes
"clustered"
"rowstacked"
"columnstacked"
"mixed"
"order"
"nokeyseparators"
; smooth additions
"bspline"
"cubicspline"
; key/label placement
"inside"
"outside"
; fill pattern ; fill pattern
"pattern" "pattern"
; 3d / surface ; 3d / surface
"triangles"
"surface"
"nosurface"
"s" "s"
; data / fit extras ; data / fit extras
"variables" "variables"
@ -323,73 +236,31 @@
"datablocks" "datablocks"
"commentschars" "commentschars"
"functions" "functions"
; misc
"both"
"positive"
"negative"
"one"
"two"
"user"
"sorted"
"timedate"
"maxrows"
"maxcolors"
; axes aliases / coordinate planes / walls ; axes aliases / coordinate planes / walls
"xy"
"wall"
"version" "version"
; colorspec ; colorspec
"rgbcolor" "rgbcolor"
; tics
"mirror"
; set size
"equal"
"ratio"
; set fit ; set fit
"covariancevariables"
"errorvariables"
"maxiter" "maxiter"
"default" "default"
; label / style
"boxed"
; set view ; set view
"azimuth"
"map" "map"
"projection"
; set theta direction
"theta_dir"
; palette model / presets / cubehelix options ; palette model / presets / cubehelix options
"cubehelix"
"model" "model"
"start"
"gamma"
"cycles"
"saturation"
; pm3d / lighting ; pm3d / lighting
"corners2color" "corners2color"
"lighting"
"primary" "primary"
"specular" "specular"
"spec2" "spec2"
; smooth / dgrid3d subtypes ; smooth / dgrid3d subtypes
"gauss"
"splines" "splines"
; contour / cntrparam
"onecolor"
"interval"
"firstlinetype"
; tics axes / modifiers ; tics axes / modifiers
"ztics"
"cbtics"
"add" "add"
"rangelimited"
; text / font / encoding ; text / font / encoding
"fontscale" "fontscale"
"utf8" "utf8"
"noboxed"
; fill / size style ; fill / size style
"empty" "empty"
"square"
; layout / spacing / multiplot ; layout / spacing / multiplot
"layout" "layout"
"spacing" "spacing"
@ -398,27 +269,13 @@
"cb" "cb"
; filledcurves axis coordinate (x1, x2, y1, y2 etc.) ; filledcurves axis coordinate (x1, x2, y1, y2 etc.)
"coordinate" "coordinate"
; numeric format type
"numeric"
; watch-label / surface options ; watch-label / surface options
"point" "point"
"nohidden3d"
; tics keyword (grid / paxis — covers xtics, ytics, ztics contexts) ; tics keyword (grid / paxis — covers xtics, ytics, ztics contexts)
"tics" "tics"
; histogram fill style
"errorbars"
; jitter options
"spread"
"swarm"
; key command options
"box"
"auto"
; paxis label keyword (key("label",3) with default aka="label") ; paxis label keyword (key("label",3) with default aka="label")
; watchpoint style subcommand (key("labels",-1) covers singular "label" too) ; watchpoint style subcommand (key("labels",-1) covers singular "label" too)
"label" "label"
"labels"
; polar coordinate system and grid option
"polar"
; polar grid axis ranges ; polar grid axis ranges
"theta" "theta"
"r" "r"
@ -426,22 +283,18 @@
"units" "units"
; stats output prefix ; stats output prefix
"prefix" "prefix"
; palette formula option
"rgbformulae"
; pm3d z-clip ; pm3d z-clip
"z" "z"
; grid mode
"spiderplot"
; binary filetype
"png"
; datafile option
"columnheaders"
; textbox / multiplot margins (anonymous "margins" string) ; textbox / multiplot margins (anonymous "margins" string)
"margins" "margins"
; datafile lc/fc palette shorthand ; datafile lc/fc palette shorthand
"palette" "palette"
; set fit quiet / results / verbose / brief
"fit_out"
] @variable.member ] @variable.member
(columnheader) @variable.member
; ----------------------------------------------------------------------- ; -----------------------------------------------------------------------
; Presentation / style attributes ; Presentation / style attributes
[ [
@ -449,34 +302,26 @@
"monochrome" "monochrome"
"color" "color"
"transparent" "transparent"
"enhanced" ; colorspace
"RGB"
"CMY"
"HSV"
"background" "background"
"nobackground" "nobackground"
"separator" "separator"
(hull) (hull)
"title" "units_opt"
"notitle"
"rectangle"
"circle"
"ellipse"
"polygon"
; fill / line style modes ; fill / line style modes
"solid" "solid"
"dashed" "dashed"
"rounded"
; page orientation ; page orientation
"landscape" "landscape"
"portrait" "portrait"
"eps"
"pdf"
; terminal options ; terminal options
"animate" "animate"
"noanimate"
"standalone"
"input" "input"
"colortext" "colortext"
"blacktext" "blacktext"
"duplex"
; point type names (ps/tikz terminals) ; point type names (ps/tikz terminals)
"texpoints" "texpoints"
"normalpoints" "normalpoints"
@ -485,27 +330,10 @@
"tinypoints" "tinypoints"
"pspoints" "pspoints"
"nopspoints" "nopspoints"
; text formatting
"textnormal"
"defaultplex"
; key alignment (capitalised)
"Left"
"Right"
; layer / style misc
"layerdefault"
"st_opt" "st_opt"
"output" "plt_st"
] @attribute ] @attribute
"plt_st" @attribute
[
(auto)
(autotitle)
(columnheader)
(maxcols)
] @variable.member
; binary filetype= value (png/jpg/gif/bin parsed as identifier in field) ; binary filetype= value (png/jpg/gif/bin parsed as identifier in field)
(binary_options (binary_options
filetype: (identifier) @attribute) filetype: (identifier) @attribute)