Happy New Year + OpenSCAD syntax lexer for SynWrite

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Happy New Year + OpenSCAD syntax lexer for SynWrite

runsun
Happy New Year to all dear fellow OpenSCADists! To enjoy our journey of OpenSCAD in the new 2016 to come, allow me to present a present: an OpenSCAD syntax lexer for the editor SynWrite.

It's a lexer intended to deal with large and/or complicated scad files. Users will be able to divide large code into sections, in-function sections and in-module sections, all are blocks that can be folded and easily navigated through the syntax tree panel.

The lexer already being incorporated into the SynWrite library, so you can get right to it once the SynWrite is installed. Couple of screenshots :

1. The synwrite_syntax_demo.scad domonstrating all the features of the lexer:



2. foldable in-function sections



3. Foldable in-module sections



4. William Adam's math lib as viewed with this lexer




To load it to your SynWrite, just go to [Options]/ [Add-ons Manager] / [Install]

To use it, select it in the status bar on the bottom of editor.

The demonstrating file, synwrite_syntax_demo.scad, can be downloaded from the thing:http://www.thingiverse.com/thing:1237864. Enjoy !
$ Runsun Pan, PhD
$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); $ Tips; $ Snippets
Reply | Threaded
Open this post in threaded view
|

Re: Happy New Year + OpenSCAD syntax lexer for SynWrite

nophead
Happy New Year and thanks for the lexer.

I hadn't come across SynWrite before but it looks like a nice editor. I have never seen multi-caret editing before!

I added render to the list of actions as it seems to be missing.



On 1 January 2016 at 04:06, runsun <[hidden email]> wrote:
Happy New Year to all dear fellow OpenSCADists! To enjoy our journey of OpenSCAD in the new 2016 to come, allow me to present a present: an OpenSCAD syntax lexer for the editor SynWrite.

It's a lexer intended to deal with large and/or complicated scad files. Users will be able to divide large code into sections, in-function sections and in-module sections, all are blocks that can be folded and easily navigated through the syntax tree panel.

The lexer already being incorporated into the SynWrite library, so you can get right to it once the SynWrite is installed. Couple of screenshots :

1. The synwrite_syntax_demo.scad domonstrating all the features of the lexer:



2. foldable in-function sections



3. Foldable in-module sections



4. William Adam's math lib as viewed with this lexer




To load it to your SynWrite, just go to [Options]/ [Add-ons Manager] / [Install]

To use it, select it in the status bar on the bottom of editor.

The demonstrating file, synwrite_syntax_demo.scad, can be downloaded from the thing:http://www.thingiverse.com/thing:1237864. Enjoy !
$ Runsun Pan, PhD
$ libs: doctest, faces(git), offline doc(git), runscad.py(1,2,git);
$ tips: hash(1,2), sweep, var(1,2), lerp, animGif, precision(1,2), xl-control


View this message in context: Happy New Year + OpenSCAD syntax lexer for SynWrite
Sent from the OpenSCAD mailing list archive at Nabble.com.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Happy New Year + OpenSCAD syntax lexer for SynWrite

runsun
@nophead, Thx for the render reminding. I'll collect bugs/improvement, etc into next version.

From what I see, SynWrite has a lot of potentials. Besides the extremely flexible lexer customization that I can do almost all I want, it has other features:

-- With the external tool feature you can set it up to run OpenSCAD then capture the console output of current file without even have OpenSCAD opened. This will allows for any quick check of OpenSCAD language behaviors

-- It has the "Auto-completion" and "Function parameter hint" for common languages. It might be possible that a plugin can be written for OpenSCAD.

-- It has the capability of customizable event handlers (like, on_change or something) and python API for that. This means that it could be possible to set up key_up event and output function names and argument lists to SynWrite's output panel.
$ Runsun Pan, PhD
$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); $ Tips; $ Snippets
Reply | Threaded
Open this post in threaded view
|

Re: Happy New Year + OpenSCAD syntax lexer for SynWrite

Neon22
sounds and looks pretty good. I'm a notepad++ person and I find the openSCAD support very good.
   - http://www.thingiverse.com/thing:911342 (remix of Gary Crowell original via Fogl)
      - http://www.thingiverse.com/thing:167899

How does it compare - anyone know ?
Reply | Threaded
Open this post in threaded view
|

Re: Happy New Year + OpenSCAD syntax lexer for SynWrite

runsun
This post was updated on .
@Neon22, I'm a Notepad++ person, too, being using it for as long as I can remember.

Ever since I started learning OpenScad, I tried to make it work using npp several times but has no luck. Later on I found people seem to have done it, so I picked up and tried those (including yours). What I found is that npp only provides some commonly used features and I've tried and failed to add stuff that I want. For example, the different sections type of blocks that I described in this threads. The flexibility of syntax customization is far behind that of SynWrite.  

Another consideration is the auto-completion and function parameter hint. People WERE using Npp for that, but it seems that new version of npp doesn't allow it anymore.

I am also eyeing at the several other customizations that I mentioned. It gives me an impression that we can do a lot more to fit out needs.

It doesn't mean that npp is not good tool for OpenSCAD. I think it is still good for many. But to deal with large and complicated files, which I often have, npp is just not enough.
$ Runsun Pan, PhD
$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); $ Tips; $ Snippets
Reply | Threaded
Open this post in threaded view
|

Re: Happy New Year + OpenSCAD syntax lexer for SynWrite

jpmendes
Hello,

Tnx runsun for the lexer.
It seems to exist a problem with some rules because some modules do not appear in the tree list.
A construct like this:

module foo() color("SlateGray") render(convexity=2) // or other any "operator" before the curly bracket
{
...
}

doesn't appear in the tree list.

Btw, is there a reason for the boolean operators to have the same style as operators like translation and rotation?
I already defined a new style for the boolean by editing directly the file Lexlib.lxl for my own use. Made some other minor changes to suit my taste also.

jpmendes


Reply | Threaded
Open this post in threaded view
|

Re: Happy New Year + OpenSCAD syntax lexer for SynWrite

runsun
@ jpmendes,

1) The lexer wasn't designed to handle the coding style as module xx() <operations> {...}.  The <operations> could be a lot of different things with undetermined length. It'd be too complicated to consider that (note that comparing to other lexers comes with SynWrite, this lexer is already on the "very complicated" side).

So at this moment the best bet is to rewrite it to module xx() { <operations> ... }

2) boolean shouldn't have the same style as operations. See below:



It's likely that something was changed during your modification. I personally never edit Lexlib.lxl directly but going:

    [Options]/[Customize lexer]   --- modify the current lexer
    or
    [Options]/[Customize lexer library]   --- pick a lexer from a list

You can go [Customize lexer library], pick a lexer, make a copy using the icon on the menu. This will give you a new lexer like "OpenSCAD (copy)". You then edit it, hit [Apply] on the button to see if it fits your need, or add your own code to the example panel of "OpenSCAD (copy)" .

$ Runsun Pan, PhD
$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); $ Tips; $ Snippets
Reply | Threaded
Open this post in threaded view
|

Re: Happy New Year + OpenSCAD syntax lexer for SynWrite

runsun
runsun wrote
1) The lexer wasn't designed to handle the coding style as module xx() <operations> {...}.  
FYI, the tech side of this is that it uses "module xx() {" to identify module blocks (see the module block rule named: "r_module<id>(...){"

Inserting <operations> breaks the rule.
$ Runsun Pan, PhD
$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); $ Tips; $ Snippets
Reply | Threaded
Open this post in threaded view
|

Re: Happy New Year + OpenSCAD syntax lexer for SynWrite

jpmendes
Ok, understood.
However when I mentioned the boolean operations I meant intersection, difference  and union, that have the same style as non boolean translation, rotation etc
My personal modification was to put intersection difference and union bold italic,  creating:

       item
        DisplayName = 's_id_openscad_builtin_boolean'
        Font.Charset = DEFAULT_CHARSET
        Font.Color = clTeal
        Font.Height = -13
        Font.Name = 'Courier New'
        Font.Style = [fsBold, fsItalic]
      end


and

       item
        DisplayName = 'r_id_openscad_builtin_boolean'
        StyleName = 's_id_openscad_builtin_boolean'
        BlockType = btTagDetect
        ConditionList = <
          item
            TagList.Strings = (
              'difference'
              'intersection'
              'union')
            TokenTypes = 4
          end>
        HighlightPos = cpAny
        IgnoreAsParent = False
      end

jpmendes
Reply | Threaded
Open this post in threaded view
|

Re: Happy New Year + OpenSCAD syntax lexer for SynWrite

runsun
I c. I misunderstood.

During the design of the lexer, I kept in mind not to make the colors too complicated, because the structure is already complicated. For example, all symbols are of same style. I recalled in other version of lexer for Notepad++, for example, symbols are separated into different several subgroups and styled differently.

I also consider leaving some space for users to work on when they want to add styles for their own libraries.

So in terms of "operations", I simple put everything that is applied to an object to same style.

No matter what, good to see you have it worked.

jpmendes wrote
Ok, understood.
However when I mentioned the boolean operations I meant intersection, difference  and union, that have the same style as non boolean translation, rotation etc
My personal modification was to put intersection difference and union bold italic,  creating:

       item
        DisplayName = 's_id_openscad_builtin_boolean'
        Font.Charset = DEFAULT_CHARSET
        Font.Color = clTeal
        Font.Height = -13
        Font.Name = 'Courier New'
        Font.Style = [fsBold, fsItalic]
      end


and

       item
        DisplayName = 'r_id_openscad_builtin_boolean'
        StyleName = 's_id_openscad_builtin_boolean'
        BlockType = btTagDetect
        ConditionList = <
          item
            TagList.Strings = (
              'difference'
              'intersection'
              'union')
            TokenTypes = 4
          end>
        HighlightPos = cpAny
        IgnoreAsParent = False
      end

jpmendes
$ Runsun Pan, PhD
$ libs: scadx, doctest, faces(git), offline doc(git), runscad.py(2,git), editor of choice: CudaText ( OpenSCAD lexer); $ Tips; $ Snippets