lexer for Asymptote

View: New views
14 Messages — Rating Filter:   Alert me  

lexer for Asymptote

by instanton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Asymptote (http://asymptote.sourceforge.net/) is a lovely picture drawing language used for producing high quality graphics. Asymptote sources can be incorporated into LaTeX documents and so labels with standard TeX/LaTeX symbols can be used without problem.
 
The language grammer of Asymptote is very similar to C++, so I adapted the C++ lexer code and made a new lexer for Asymptote. Attached is the Lexer code LexASY.cxx together with a preliminary test properties file asymptote.properties.
LexASY.cxxasymptote.properties

Re: lexer for Asymptote

by Neil Hodgson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

instanton:

> The language grammer of Asymptote is very similar to C++, so I adapted the
> C++ lexer code and made a new lexer for Asymptote.

   A problem with starting from the C++ lexer is that it contains
several pieces of weirdness that are not applicable to most languages.
lexer.cpp.allow.dollars is there because allowing '$' in identifiers
is a non-standard extension to the C/C++ languages. SCE_C_UUID is for
various forms of IDL which use UUIDs. There is regular expression
support for JavaScript. None of these should be present if your target
language doesn't need them. Its unlikely it uses verbatim strings
(from C#) either.

   Neil
_______________________________________________
Scintilla-interest mailing list
Scintilla-interest@...
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Re: lexer for Asymptote

by instanton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Neil Hodgson wrote:
   A problem with starting from the C++ lexer is that it contains
several pieces of weirdness that are not applicable to most languages.
lexer.cpp.allow.dollars is there because allowing '$' in identifiers
is a non-standard extension to the C/C++ languages. SCE_C_UUID is for
various forms of IDL which use UUIDs. There is regular expression
support for JavaScript. None of these should be present if your target
language doesn't need them. Its unlikely it uses verbatim strings
(from C#) either.

   Neil
_______________________________________________
Thanks Neil. Indeed, a lot of C++ specific settings are not necessary. Now comes a cleaner version. See atachments.
LexASY.cxx   
asymptote.properties

Re: lexer for Asymptote

by Neil Hodgson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

instanton:

> Thanks Neil. Indeed, a lot of C++ specific settings are not necessary. Now
> comes a cleaner version. See atachments.
> http://www.nabble.com/file/p11601182/LexASY.cxx LexASY.cxx

   The chPrevNonWhite, continuationLine and lineEndChar variables are
never read so can be eliminated which removes the "look back" block
and the SCE_ASY_PREPROCESSOR block.

   Neil
_______________________________________________
Scintilla-interest mailing list
Scintilla-interest@...
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Re: lexer for Asymptote

by instanton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Neil,

I was out of reach to the net during my holidays. Now I've got a more cleaner version as seen in the attachment.

instanton

Neil Hodgson wrote:
   The chPrevNonWhite, continuationLine and lineEndChar variables are
never read so can be eliminated which removes the "look back" block
and the SCE_ASY_PREPROCESSOR block.

   Neil
LexASY.cxx

Re: lexer for Asymptote

by Neil Hodgson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

instanton:

> http://www.nabble.com/file/p12289272/LexASY.cxx LexASY.cxx

   Is there a Scintilla.iface file for this?

   Neil
_______________________________________________
Scintilla-interest mailing list
Scintilla-interest@...
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Re: Re: lexer for Asymptote

by instanton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Sure. I forgotto upload it. Now attached.
 
 
2007-08-26

Instanton

发件人: Neil Hodgson
发送时间: 2007-08-26  20:48:06
收件人: Discussion of the Scintilla editing component
抄送:
主题: Re: [scintilla] lexer for Asymptote
instanton:
 
 
   Is there a Scintilla.iface file for this?
 
   Neil
_______________________________________________
Scintilla-interest mailing list


_______________________________________________
Scintilla-interest mailing list
Scintilla-interest@...
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Scintilla.iface (134K) Download Attachment

Re: Re: lexer for Asymptote

by Neil Hodgson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Instanton:

> Sure. I forgotto upload it. Now attached.

   Did you intend this to contain definitions of SCE_ASY_* ?

   Neil
_______________________________________________
Scintilla-interest mailing list
Scintilla-interest@...
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Re: Re: Re: lexer for Asymptote

by instanton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Not really. I suppose these goes in SciLexer.h.
 
 
2007-08-27

Instanton

发件人: Neil Hodgson
发送时间: 2007-08-27  19:24:06
收件人: Discussion of the Scintilla editing component
抄送:
主题: Re: Re: [scintilla] lexer for Asymptote
Instanton:
 
> Sure. I forgotto upload it. Now attached.
 
   Did you intend this to contain definitions of SCE_ASY_* ?
 
   Neil
_______________________________________________
Scintilla-interest mailing list

_______________________________________________
Scintilla-interest mailing list
Scintilla-interest@...
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Re: Re: Re: lexer for Asymptote

by Neil Hodgson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Instanton:

> Not really. I suppose these goes in SciLexer.h.

   SciLexer.h is generated from Scintilla.iface. All symbol
definitions should be defined in Scintilla.iface.

   Neil
_______________________________________________
Scintilla-interest mailing list
Scintilla-interest@...
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Re: Re: Re: lexer for Asymptote

by instanton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
OK. Then just add the following after line 3220 of Scintilla.iface. It doesn't make any difference here after compilation.
 
 
#--------------------
 
# Lical states for Asymptote
 
val SCE_ASY_DEFAULT=0
val SCE_ASY_COMMENT=1
val SCE_ASY_COMMENTLINE=2
val SCE_ASY_NUMBER=3
val SCE_ASY_WORD=4
val SCE_ASY_STRING=5
val SCE_ASY_CHARACTER=6
val SCE_ASY_OPERATOR=7
val SCE_ASY_IDENTIFIER=8
val SCE_ASY_STRINGEOL=9
val SCE_ASY_COMMENTLINEDOC=10
val SCE_ASY_WORD2=11
#--------------------
 
2007-08-27

Instanton

发件人: Neil Hodgson
发送时间: 2007-08-27  21:31:53
收件人: Discussion of the Scintilla editing component
抄送:
主题: Re: Re: Re: [scintilla] lexer for Asymptote
Instanton:
 
> Not really. I suppose these goes in SciLexer.h.
 
   SciLexer.h is generated from Scintilla.iface. All symbol
definitions should be defined in Scintilla.iface.
 
   Neil
_______________________________________________
Scintilla-interest mailing list

_______________________________________________
Scintilla-interest mailing list
Scintilla-interest@...
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Re: Re: Re: lexer for Asymptote

by Neil Hodgson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

   Can you include the standard:
// The License.txt file describes the conditions under which this
software may be distributed.

   Otherwise I receive boring license questions. Current widespread
belief is that you get copyright whether you want it or not so saying
"No Copyright" has no effect. You should be aware that including your
email address in the code will publish this widely and is likely to
result in receiving spam.

   Neil
_______________________________________________
Scintilla-interest mailing list
Scintilla-interest@...
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Re: Re: Re: lexer for Asymptote

by instanton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Neil:
 
Yes of course. Just done it in the attached file LexASY.cxx.
I'll appreciate if you'ld include this piece of code in the next release. Thank you.
 
2007-08-28

Instanton

发件人: Neil Hodgson
发送时间: 2007-08-28  21:03:32
收件人: Discussion of the Scintilla editing component
抄送:
主题: Re: Re: Re: [scintilla] lexer for Asymptote
   Can you include the standard:
// The License.txt file describes the conditions under which this
software may be distributed.
 
   Otherwise I receive boring license questions. Current widespread
belief is that you get copyright whether you want it or not so saying
"No Copyright" has no effect. You should be aware that including your
email address in the code will publish this widely and is likely to
result in receiving spam.
 
   Neil
_______________________________________________
Scintilla-interest mailing list


_______________________________________________
Scintilla-interest mailing list
Scintilla-interest@...
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

LexASY.cxx (10K) Download Attachment

Re: Re: Re: lexer for Asymptote

by instanton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Neil,

It look like my reply to you made on 28 August has somehow disappeared. Of course I agree to add this line

// The License.txt file describes the conditions under which this software may be distributed.

in LexASY.cxx. Now I upload a version with this line included. I'll appreciate if you'ld include this piece of code in the next release. Thank you.

instanton
 


Neil Hodgson wrote:
   Can you include the standard:
// The License.txt file describes the conditions under which this
software may be distributed.

   Otherwise I receive boring license questions. Current widespread
belief is that you get copyright whether you want it or not so saying
"No Copyright" has no effect. You should be aware that including your
email address in the code will publish this widely and is likely to
result in receiving spam.

   Neil
LexASY.cxx