9

I noticed there is a LexCoffeeScript.cxx file in the SciTE source code; however, SciTE does not seem to have a CoffeeScript menu option in its Languages menu.

Adding the option manually doesn't help -- there still isn't any syntax coloring.

Is there any way to enable the built-in lexer (instead of resorting to an external one)?

4

3 回答 3

3

显然,CoffeeScript 词法分析器是在 Scintilla 中编译的,但 SciTE 不使用它。我的意思是没有coffeescript.properties文件或任何其他文件可以引用词法分析器。您 cat 尝试创建自己的并将您使用的文件扩展名的词法分析器设置为coffeescript

# Define SciTE settings for Coffeescript files.
file.patterns.coffeescript=*.coffee
filter.coffeescript=Coffeescript (coffee)|$(file.patterns.coffeescript)|
lexer.$(file.patterns.coffeescript)=coffeescript
...

然后,您将定义词法分析器支持的关键字、着色样式和其他内容——查看其来源。您可以在 中获得灵感cpp.properties,例如(C/C++ 和类似语言的词法分析器称为cpp。)以下是支持的词法状态:

val SCE_COFFEESCRIPT_DEFAULT=0
val SCE_COFFEESCRIPT_COMMENT=1
val SCE_COFFEESCRIPT_COMMENTLINE=2
val SCE_COFFEESCRIPT_COMMENTDOC=3
val SCE_COFFEESCRIPT_NUMBER=4
val SCE_COFFEESCRIPT_WORD=5
val SCE_COFFEESCRIPT_STRING=6
val SCE_COFFEESCRIPT_CHARACTER=7
val SCE_COFFEESCRIPT_UUID=8
val SCE_COFFEESCRIPT_PREPROCESSOR=9
val SCE_COFFEESCRIPT_OPERATOR=10
val SCE_COFFEESCRIPT_IDENTIFIER=11
val SCE_COFFEESCRIPT_STRINGEOL=12
val SCE_COFFEESCRIPT_VERBATIM=13
val SCE_COFFEESCRIPT_REGEX=14
val SCE_COFFEESCRIPT_COMMENTLINEDOC=15
val SCE_COFFEESCRIPT_WORD2=16
val SCE_COFFEESCRIPT_COMMENTDOCKEYWORD=17
val SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR=18
val SCE_COFFEESCRIPT_GLOBALCLASS=19
val SCE_COFFEESCRIPT_STRINGRAW=20
val SCE_COFFEESCRIPT_TRIPLEVERBATIM=21
val SCE_COFFEESCRIPT_HASHQUOTEDSTRING=22
val SCE_COFFEESCRIPT_COMMENTBLOCK=22
val SCE_COFFEESCRIPT_VERBOSE_REGEX=23
val SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT=24

所有.properties文件都由import *from的行自动加载SciTEGlobal.properties。您还可以添加Coffeescript|coffee||\menu.language以获取新菜单项Languages和/或*.coffeesource.files“文件打开”对话框中查看扩展名。

奇怪的是作者没有提供.properties带有词法分析器的文件。可以使用 JavaScript 词法分析器代替。你可以在SciTE 邮件列表中询问它。

--- 费尔达

于 2012-04-11T19:58:00.157 回答
1

费尔达的回答是正确的。

这是一个示例 coffeescript.properties 文件,可以帮助您入门并节省一些时间...

# Define SciTE settings for Coffeescript files.
file.patterns.coffeescript=*.coffee
filter.coffeescript=Coffeescript (coffee)|$(file.patterns.coffeescript)|
lexer.$(file.patterns.coffeescript)=coffeescript

keywordclass.coffeescript=abstract boolean break byte case catch char class \
const continue debugger default delete do double else enum export extends \
final finally float for function goto if implements import in instanceof \
int interface long native new package private protected public \
return short static super switch synchronized this throw throws \
transient try typeof var void volatile while with
keywords.$(file.patterns.coffeescript)=$(keywordclass.coffeescript)

keywordclass2.coffeescript=$
keywords2.$(file.patterns.coffeescript)=$(keywordclass2.coffeescript)

# White space 
style.coffeescript.0=fore:#808080
# Comment: ### ###
style.coffeescript.1=$(colour.code.comment.box),$(font.code.comment.box)
# Line Comment: #
style.coffeescript.2=$(colour.code.comment.line),$(font.code.comment.line)
# Doc comment: block comments beginning with /** or /*!
style.coffeescript.3=$(colour.code.comment.doc),$(font.code.comment.doc)
# Number
style.coffeescript.4=$(colour.number)
# Keyword
style.coffeescript.5=$(colour.keyword),bold
# Double quoted string
style.coffeescript.6=$(colour.string)
# Single quoted string
style.coffeescript.7=$(colour.char)
# UUIDs (only in IDL)
style.coffeescript.8=fore:#804080
# Preprocessor
style.coffeescript.9=$(colour.preproc)
# Operators
style.coffeescript.10=fore:#FF6600,bold
# Identifiers
style.coffeescript.11=fore:#FF1493
# End of line where string is not closed
style.coffeescript.12=fore:#000000,$(font.monospace),back:#E0C0E0,eolfilled
# Verbatim strings 
style.coffeescript.13=fore:#007F00,$(font.monospace),back:#E0FFE0,eolfilled
# Regular expressions for JavaScript
style.coffeescript.14=fore:#3F7F3F,$(font.monospace),back:#E0F0FF,eolfilled
# Doc Comment Line: line comments beginning with /// or //!.
style.coffeescript.15=$(colour.code.comment.doc),$(font.code.comment.doc)
# Keywords2
style.coffeescript.16=fore:#B00040
# Comment keyword
style.coffeescript.17=fore:#3060A0,$(font.code.comment.doc)
# Comment keyword error
style.coffeescript.18=fore:#804020,$(font.code.comment.doc)
# Raw strings 
style.coffeescript.20=$(colour.string),back:#FFF3FF,eolfilled
# Triple-quoted strings
style.coffeescript.21=$(font.monospace),fore:#007F00,back:#E0FFE0,eolfilled
# Hash-quoted strings for Pike
style.coffeescript.22=$(font.monospace),fore:#007F00,back:#E7FFD7,eolfilled
# Verbose Regex
style.coffeescript.23=fore:#659900
# Verbose Regex Comment
style.coffeescript.24=$(colour.code.comment.doc)
于 2014-04-03T16:17:56.950 回答
0

您需要将此行放入SciTEGlobal.properties文件中。可以通过单击在 SciTE 的选项菜单中打开Open Global Options File

import lexers/[dir]

文件在 lexers 目录中[dir]的位置在哪里。LexCoffeeScript.cxx/usr/share/scite/

更新 我自己试过这个,我安装的 SciTE 没有任何 CoffeeScript cxx 文件,所以我从这里下载了 scintillua 包,它与lua咖啡脚本词法分析器一起打包。按照上面的说明安装它,它工作正常。

于 2012-02-26T14:19:57.683 回答