• 2 Posts
  • 13 Comments
Joined 1 year ago
cake
Cake day: July 4th, 2023

help-circle



  • Here’s my opinion, a well-developed DSL could even be arguably more flexible than say Python even with existing libraries on their specific domains. So, if one is just limited to domains, they may be very well be preferable to general languages.

    I have coded in C#, Python, C++, and currently nearly everyday, G’MIC. Which one of those are a DSL? The last one. What it is? It’s a Domain-Specific Language that has been geared toward raster graphics image processing. Why do I use it? Looking at the stack-based processing, commands, built-in mathematical functions. It seems that it has a lot more things that are built-in than say Pillow library for Python and other things. And I only do create images with code, so I am happy with this, and I even did things like Python itertools combinatorics with more things like rank2list/list2rank variation of those combinatorics which aren’t image processing by themselves, but can aid to it.

    If I feel that it is way too limited for that Domain, then I wouldn’t use it. DSLs are only good if the other options are much more difficult to build with and their flexibility are often enough to entice their audience which is one with limited use cases. Of course, generic languages are usually better even than most DSL even within their domains because of wider support, and wider audience. More DSLs would be better than generics given enough time and support for their domains in my opinion.





  • So far, the most challenging part was highlighting things that counts as comment rather than pointers to image pixels or accessible variables. That’s not the end of my trouble though.

    I do want to figure out how to highlight “expr” including newlines inside expr. expr is basically any mathematical expression that is utilized on JIT compilation.

    • if expr
    • repeat expr
    • variable={expr}
    • variable:=expr <- : can be replaced with operator and it will still apply.
    • eval expr
    • eval “expr”
    • check “expr”
    • fill expr
    • fill “expr”
    • eval>expr
    • eval >“expr”
    • fill >expr
    • fill >“expr”
    • {expr}
    • for expr
    • {“expr”}
    • while expr

    Along with that to set up regex inside it to highlight section of expr.

    While still maintaining priority of regex. So, if one regex is more important, it’ll overwrite whatever highlighted.




  • Getting highlighting for regex-based selection to work. That seems confusing. I have 7 criterias which is recommended for the G’MIC language.

    Note:

    1. Strings that matches #( |$|(#)+).* gets treated as if it was a comment.
    2. Strings that matches #@cli.* are treated as if they’re a header for CLI codes.
    3. Strings that matches \$(-\d+|\w+|\d+) gets treated as if they’re accessed variables.
    4. Strings that matches \w+: are treated as if they’re commands names.
    5. Any texts under control-flow item list gets highlighted as long as they’re outside any characters between 2 quotation marks and of course, taking into account of / being used as escape character.
    6. #@gui gets bolded.
    7. Anything between 2 quotation marks gets highlighted though escape characters would be considered.





  • Feel free to delete this post if you don’t feel that this fits though I think the language I use is very similar to bash in some ways (G’MIC). Here’s a real-world example of my own code in G’MIC that’s pretty much painful to parse:

    command "out2display : skip ${""1=},${""2=},${""3=},${""4=1},${""5=1},${""6=},${""7=},${""8=},${""9=},${""10=} if narg($""1) if $""1 $__bg rv blend alpha fi fi xalp if narg($""6) if narg($""2)&&narg($""3)&&narg($""4)&&narg($""5) {$""4},{$""5},1,{s#0},i(#-1,$""2+x,$""3+y) f. begin(ww=w-1;hh=h-1;);(x<(2+narg($""7))||x>ww-2)||(y<(2+narg($""7))||y>hh-2)?(xor($""6,i)>128?0:255):i j[0] [-1],$""2,$""3 rm. if narg($""8)&&narg($""9)&&narg($""10) if $""8==0||$""8>2 {$""4},{$""5},1,{s#0},i(#0,$__nw+($__min_tile*$""9)-$""2+x-$""4,$""3+y) f. begin(ww=w-1;hh=h-1;);(x<(2+narg($""7))||x>ww-2)||(y<(2+narg($""7))||y>hh-2)?(xor($""6,i)>128?0:255):i j[0] [-1],{$__nw+($__min_tile*$""9)-$""2-$""4},$""3 rm. fi if $""8==1||$""8>2 {$""4},{$""5},1,{s#0},i(#0,$""2+x,$__nh+($__min_tile*$""10)-$""3+y-$""5) f. begin(ww=w-1;hh=h-1;);(x<(2+narg($""7))||x>ww-2)||(y<(2+narg($""7))||y>hh-2)?(xor($""6,i)>128?0:255):i j[0] [-1],$""2,{$__nh+($__min_tile*$""10)-$""3-$""5} rm. fi if $""8==2||$""8>2 {$""4},{$""5},1,{s#0},i(#0,$__nw+($__min_tile*$""9)-$""2+x-$""4,$__nh+($__min_tile*$""10)-$""3+y-$""5) f. begin(ww=w-1;hh=h-1;);(x<(2+narg($""7))||x>ww-2)||(y<(2+narg($""7))||y>hh-2)?(xor($""6,i)>128?0:255):i j[0] [-1],{$__nw+($__min_tile*$""9)-$""2-$""4},{$__nh+($__min_tile*$""10)-$""3-$""5} rm. fi fi fi fi if narg($""7) f[0] begin(ww=w-1;hh=h-1;);(x%$__min_tile==0||y%$__min_tile==0)||(x==ww||y==hh)?$""7:i fi"
    

    That was before I figured out how to properly code in local commands.