Skip to content

Commit

Permalink
More
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed Aug 7, 2018
1 parent 1b65c51 commit 7100f5b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
3 changes: 1 addition & 2 deletions grammar/slisp-grammar.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
}

file ::= element*
element ::= string | number | symbol | quotedSymbol | bracketed | braced | parenthesised
element ::= QUOTE? (string | number | symbol | bracketed | braced | parenthesised)

bracketed ::= LEFT_BRACKET element* RIGHT_BRACKET
braced ::= LEFT_BRACE element* RIGHT_BRACE
parenthesised ::= LEFT_PARENTHESE element* RIGHT_PARENTHESE

number ::= NUM
symbol ::= SYM
quotedSymbol ::= QUOTED_SYM

string ::= STR
7 changes: 1 addition & 6 deletions grammar/slisp-lexer.flex
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ WHITE_SPACE=[ \n\r\t]

INCOMPLETE_STRING=\"([^\"\\]|\\[^])*
STRING_LITERAL={INCOMPLETE_STRING}\"
INCOMPLETE_STRING2=\'([^\'\\]|\\[^])*
STRING_LITERAL2={INCOMPLETE_STRING2}\'

DIGIT=[0-9]

Expand Down Expand Up @@ -59,15 +57,12 @@ UNKNOWN_CHARACTER=[^a-zA-Z!@$\^&_:=<|>?.\\+\-~*/%#0-9\";]
\] { yybegin(YYINITIAL); return SLispTypes.RIGHT_BRACKET; }
\{ { yybegin(YYINITIAL); return SLispTypes.LEFT_BRACE; }
\} { yybegin(YYINITIAL); return SLispTypes.RIGHT_BRACE; }
\' { yybegin(YYINITIAL); return SLispTypes.QUOTE; }

{INCOMPLETE_STRING}
{ yybegin(YYINITIAL); return TokenType.BAD_CHARACTER; }
{STRING_LITERAL}
{ yybegin(YYINITIAL); return SLispTypes.STR; }
{INCOMPLETE_STRING2}
{ yybegin(YYINITIAL); return TokenType.BAD_CHARACTER; }
{STRING_LITERAL2}
{ yybegin(YYINITIAL); return SLispTypes.STR; }

{INCOMPLETE_COMMENT}
{ yybegin(YYINITIAL); return TokenType.BAD_CHARACTER; }
Expand Down
6 changes: 3 additions & 3 deletions res/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@

<!--<actions>-->
<!--<action-->
<!--id="Lice.NewLiceFile"-->
<!--id="SLisp.NewLiceFile"-->
<!--class="org.lice.lang.action.NewLiceFileAction"-->
<!--text="Lice File"-->
<!--description="Create a lice script file">-->
<!--text="S-Lisp File"-->
<!--description="Create an S-Lisp script file">-->
<!--<add-to-group-->
<!--group-id="NewGroup"-->
<!--anchor="before"-->
Expand Down
2 changes: 2 additions & 0 deletions src/org/ice1000/slisp/s-lisp-actions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package org.ice1000.slisp

5 changes: 5 additions & 0 deletions src/org/ice1000/slisp/s-lisp-highlight.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ object SLispSyntaxHighlighter : SyntaxHighlighter {
@JvmField val COMMENT_KEY = arrayOf(COMMENT)
@JvmField val STRING = TextAttributesKey.createTextAttributesKey("S_LISP_STRING", DefaultLanguageHighlighterColors.STRING)
@JvmField val STRING_KEY = arrayOf(STRING)
@JvmField val QUOTED = TextAttributesKey.createTextAttributesKey("S_LISP_QUOTED", DefaultLanguageHighlighterColors.METADATA)

override fun getHighlightingLexer() = SLispLexerAdapter()
override fun getTokenHighlights(type: IElementType?): Array<TextAttributesKey> = when (type) {
Expand All @@ -33,5 +34,9 @@ class SLispSyntaxHighlighterFactory : SyntaxHighlighterFactory() {

class SLispAnnotator : Annotator {
override fun annotate(element: PsiElement, holder: AnnotationHolder) {
if (element.firstChild?.node?.elementType == SLispTypes.QUOTE) {
holder.createInfoAnnotation(element, null)
.textAttributes = SLispSyntaxHighlighter.QUOTED
}
}
}

0 comments on commit 7100f5b

Please sign in to comment.