#619 Lexer for SQL Anywhere

Completed
closed
Neil Hodgson
Scintilla (355)
5
2009-12-12
2009-10-27
David
No

I am submitting my first two possible changes to open source code today. The first to Notepad++ that uses your project and this change to you.

My compilation and testing was based on the trunk release 553 of notepad++ (not an actual scintilla release) partially because I understand Subversion better than CVS. I did not use either recommended compiler (I used MS Visual C++ 2008 Express Edition) but it appears to be working. I could not get mingw to work and do not have other MS versions of C++ except VC++5 which by statements is too old.

TESTING IS MINIMAL based only on my work patterns. I simply replaced notepad++.exe and scintilla.dll in the already installed notepad++ directory.

commentLine="//" was also added to both langs.xml and langs.model.xml for SQL

The keywords noted below were user additions to SQL through the styler config window in notepad++. (see styler.xml file)

The three lines of code changed are in LexSQL.cxx however I believe my last change requires that this become a new lexer if it is to be generally released. I suggest LexSAny.cxx or LexSQLAny.cxx for Sybase SQL Anywhere.
see LexSQL.cxx change.gif and LexSQL.cxx

It adds support for 'endif' equivalent to 'end if' in bracketing an 'if' statement.

It also recognizes the SQL Anywhere impliments 'exists' as a function
(the deletion of code).

One thing it does not do is eliminate consideration of comments (those starting with '//' in this case)
(a sample of the comment in question is a single line containing
// UPDATE table, if required
which inappropriately appears to become a fold point - changing 'if' to 'as' eliminates the issue) in folding and from what I can see the fold.comment property is not involved in the issue as it defaults to 0, if I have interpreted the code and files appropriately. If you could assist in that change it would be appreciated.

While this list is incomplete I recommend adjusting the keywords and comment properties for SQL Anywhere

Is adding commentLine='//' appropriate based on the above considerations of it as a comment (if so I have made that change and the reported issue appears to be unaffected)? (this content is also not in App Data for notepad++ as an override either; I just checked)

VERY partial list of keyword changes
endif tinyint unsigned elseif clustered string

If the new lexer is added I would commit to attempting to create the appropriate keyword list
- a significant first pass anyway - with revisions as I find them.

Thanks for your efforts

David Shuman

Discussion

1 2 > >> (Page 1 of 2)
  • David
    David
    2009-10-27

     
  • David
    David
    2009-10-28

    space delimited list of SQL Anywhere reserved words

     
  • Neil Hodgson
    Neil Hodgson
    2009-10-28

    Adding another lexer for such a minor change is a waste. Just add another property fold.sql.exists that defaults to 1 and use that to guard the check of "exists".

     
  • David
    David
    2009-10-28

    Sounds proper on the code side -- however in order to have the appropriate reserved word list which I have already generated (and uploaded)? -- is it possible to reuse the LexSQL code module with a different set of reserved words and parameters as another "Language" -- remember I have still not successfully addressed the comment issue and your solution requires a fold.sql.exists parameter change too. -- (preferably without having to override the SQL config every time I update notepad++ which uses scintilla)? This also does not address the flexibility necessary for the users of multiple database engines who should not have to reconfigure the application every time they change database engines they are using for development. (could be multiple times a day for a consultant).

     
  • Neil Hodgson
    Neil Hodgson
    2009-10-28

    Using multiple sets of keywords with one lexer is the normal way of doing things. Java, C# and C++ all use the cpp lexer with different sets of keywords. There are already properties (sql.backslash.escapes, lexer.sql.backticks.identifier, fold.sql.only.begin) to determine SQL dialect.

     
  • David
    David
    2009-10-29

    I did modify the file you as requested.

     
  • David
    David
    2009-10-29

    LexSQL.cxx as requested

     
    Attachments
  • David
    David
    2009-10-29

    I solved my comment issue with no coding changes

    Just use comments starting with -- (dash dash) for comments not to be folded (ie. real text comments) and
    use comments starting with // (slash slash) as those where folding based on keywords is appropriate (ie. commented code).

     
  • David
    David
    2009-10-29

    add in some ISQL commands and non-reserved word operands

     
    Attachments
  • Neil Hodgson
    Neil Hodgson
    2009-11-02

    • milestone: --> Completed
    • assigned_to: nobody --> nyamatongwe
     
1 2 > >> (Page 1 of 2)