From 7100f5ba558ae643f02a834d180d3dde45fb93f7 Mon Sep 17 00:00:00 2001 From: ice1000 Date: Tue, 7 Aug 2018 08:22:56 -0400 Subject: [PATCH] More --- grammar/slisp-grammar.bnf | 3 +-- grammar/slisp-lexer.flex | 7 +------ res/META-INF/plugin.xml | 6 +++--- src/org/ice1000/slisp/s-lisp-actions.kt | 2 ++ src/org/ice1000/slisp/s-lisp-highlight.kt | 5 +++++ 5 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 src/org/ice1000/slisp/s-lisp-actions.kt diff --git a/grammar/slisp-grammar.bnf b/grammar/slisp-grammar.bnf index 8d44d61..80fccc4 100644 --- a/grammar/slisp-grammar.bnf +++ b/grammar/slisp-grammar.bnf @@ -13,7 +13,7 @@ } 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 @@ -21,6 +21,5 @@ parenthesised ::= LEFT_PARENTHESE element* RIGHT_PARENTHESE number ::= NUM symbol ::= SYM -quotedSymbol ::= QUOTED_SYM string ::= STR diff --git a/grammar/slisp-lexer.flex b/grammar/slisp-lexer.flex index 283ade8..2589fd2 100644 --- a/grammar/slisp-lexer.flex +++ b/grammar/slisp-lexer.flex @@ -26,8 +26,6 @@ WHITE_SPACE=[ \n\r\t] INCOMPLETE_STRING=\"([^\"\\]|\\[^])* STRING_LITERAL={INCOMPLETE_STRING}\" -INCOMPLETE_STRING2=\'([^\'\\]|\\[^])* -STRING_LITERAL2={INCOMPLETE_STRING2}\' DIGIT=[0-9] @@ -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; } diff --git a/res/META-INF/plugin.xml b/res/META-INF/plugin.xml index 30007cc..db98787 100644 --- a/res/META-INF/plugin.xml +++ b/res/META-INF/plugin.xml @@ -34,10 +34,10 @@ - + - - + + diff --git a/src/org/ice1000/slisp/s-lisp-actions.kt b/src/org/ice1000/slisp/s-lisp-actions.kt new file mode 100644 index 0000000..5c06d51 --- /dev/null +++ b/src/org/ice1000/slisp/s-lisp-actions.kt @@ -0,0 +1,2 @@ +package org.ice1000.slisp + diff --git a/src/org/ice1000/slisp/s-lisp-highlight.kt b/src/org/ice1000/slisp/s-lisp-highlight.kt index 3536afa..749d5dd 100644 --- a/src/org/ice1000/slisp/s-lisp-highlight.kt +++ b/src/org/ice1000/slisp/s-lisp-highlight.kt @@ -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 = when (type) { @@ -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 + } } }