ecode icon indicating copy to clipboard operation
ecode copied to clipboard

Please add support for Curv

Open yh15kla9 opened this issue 8 months ago • 5 comments

Website: https://curv3d.org/

Notepad++ UDL:

https://codeberg.org/doug-moen/curv/src/branch/master/lib/Curv_notepad_plusplus.xml

yh15kla9 avatar Mar 21 '25 21:03 yh15kla9

Extracted from this XML:

Keywords1: show_ifield i_linear i_radial i_concentric i_gyroid i_animate

Keywords2: complement union difference intersection symmetric_difference row smooth chamfer

Keywords3: move rotate reflect scale at stretch shear local_taper_x local_taper_xy twist bend colour extrude revolve repeat offset shell pancake morph loft perimeter_extrude make_texture texture swirl

Keywords4: circle ellipse square rect regular_polygon polygon vertices stroke polyline half_plane slice sphere ellipsoid cylinder cone capped_cone torus box prism tetrahedron cube octahedron dodecahedron icosahedron capsule half_space gyroid make_shape dist nothing everything

Keywords5: if else for let in do local until while by exec select parametric

Keywords6: pi tau phi e abs sign floor ceil trunc round frac max min sum product sort mod rem sqrt log clamp lerp smoothstep deg sin cos tan cis asin acos atan phase sec csc cot sinh cosh tanh asinh acosh atanh mag cmul csqr not and or xor bit mag normalize dot cis perp cross idmatrix transpose count concat reverse map filter reduce contains defined fields merge match call compose id

Keywords7: file include lipschitz show_axes show_bbox set_bbox show_dist show_gradient

Keywords8: is_bool is_num is_symbol is_string is_list is_record is_vec2 is_vec3 is_func is_primitive_func ensure test print warning error assert assert_error

@SpartanJ This language has so many keywords. As I know, ecode only supports up to keyword2. What will happen if I specify it to be keyword3, keyword4,...? They will have the same color? Or no color at all because they are invalid?

Curculigo avatar Mar 29 '25 03:03 Curculigo

"keywords" are just used to identify each set of symbols between a group, in a highlighter case it's just a reference for a color in a set. In this case there was a coincidence that they use also "keyword[number]" to refer for these group sets, but it's not necessary to match 1 to 1 or anything like that, you'll just need to pick a color for each group.

Current colors are (i'll add this to the documentation after this post):

"normal": non highlighted words this is the default color
"comment": code comments color
"keyword": mostly used for language reserved words (if, else, class, struct, then, enum, etc)
"keyword2": mostly used for type names
"keyword3": currently used for coloring parameters but can be used for anything
"number": number colors
"literal": word literals colors (usually things like NULL, true, false, undefined, etc). Can be used also for any particular symbol
"string": string colors
"operator": operators colors (+, -, =, <, >, etc)
"function": function name color
"link": any link color
"link_hover"; any link that's being hovered color

So you can basically use any of these for coloring Curv keywords groups. It's possible adding more keywords for coloring very very easily but I didn't want to make it too complex (since in order to this work properly you'll need to add the color in each color scheme, although some of these keywords fallback to other keywords if they're not declared, for example keyword3 is one of those because it was added later), maybe it's time for keyword4 haha.

SpartanJ avatar Mar 29 '25 15:03 SpartanJ

It's up to the OP who is the user of this language and is assumed to understand this language to categorize these keywords into keyword and keyword2. The problem with this kind of languages is they consider functions as keywords (think about BASIC).

Curculigo avatar Mar 30 '25 02:03 Curculigo

@SpartanJ Is symbol the same as normal?

m3makefile avatar Mar 30 '25 05:03 m3makefile

"symbol" fallbacks the word captured into the "symbols" list and matches against any word in that list, if not word is found it will be the same as "normal", but "symbol" is used with the intention of searching the word in a list.

Example: What you'll usually see is something like: { "pattern": "[%a_][%w_]*", "type": "symbol" }

captures that pattern as a symbol and searches the symbol into the "symbols" list, let's say symbol was "then", so then in that list uses the type name "keyword" as a color, if captured word isn't on that list, we will fallback to type "normal".

"symbols": [
    { "in": "keyword" },
    { "then": "keyword" },
    { "exit": "keyword" },
    { "alias": "keyword" },
    { "continue": "keyword" },
    { "getopts": "keyword" },
    { "set": "keyword" },
    { "return": "keyword" },
    { "unalias": "keyword" },
}

Updated documentation is here.

SpartanJ avatar Mar 30 '25 14:03 SpartanJ