Javascript 语言构造
我正在编写一个 Javascript 语法荧光笔,但我并不是 100% 我拥有一切。
到目前为止,我有:
- 注释(// 和 /* */)
- 正则表达式
- 数字突出显示
- 引号(" 和 ')
我还突出显示了关键字:
- if
- else
- new
- var
- function
- for
- return
- this
- do
- while
- true
- false
我是否缺少任何构造或关键字是否有必要强调?更好的是,如果您有所有关键字和结构的列表,那就更好了。
I'm writing a Javascript syntax highlighter and I am not 100% I have everything.
So far I have:
- Comments (// and /* */)
- Regex
- Number Highlighting
- Quotes (" and ')
I also have keyword highlighting:
- if
- else
- new
- var
- function
- for
- return
- this
- do
- while
- true
- false
Am I missing any constructs or keywords that would be essential to highlight? Better yet, if you have some list of all keywords and constructs that would be even better.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您缺少一些,例如:
in
、switch
、break
、try
、catch、
finally
、throw
、void
、with
等。您可以在规范:
You are missing a few, e.g.:
in
,switch
,break
,try
,catch
,finally
,throw
,void
,with
, etc..You can find a comprehensive list in the Specification:
https://developer.mozilla.org/en/JavaScript/Reference/Reserved_Words
https://developer.mozilla.org/en/JavaScript/Reference/Reserved_Words
有关当前和未来可能的保留字的列表,请参阅此:http://javascript.about.com/库/blreserved.htm 。
另请注意,您也可以突出显示运算符。有些编辑这样做。分号和括号可能会或可能不会突出显示。这完全取决于您希望突出显示的外观。
See this for a list of present and possible future reserved words: http://javascript.about.com/library/blreserved.htm .
Also note that you can highlight operators as well. Some editors do that. Semicolons and parentheses may or may not be highlighted. It all depends on how you want you highlighting to look.