Revision: 5308 http://geany.svn.sourceforge.net/geany/?rev=5308&view=rev Author: ntrel Date: 2010-10-20 15:45:25 +0000 (Wed, 20 Oct 2010)
Log Message: ----------- Add Erlang filetype (patch by Taylor Venable, thanks).
Modified Paths: -------------- trunk/ChangeLog trunk/THANKS trunk/data/filetype_extensions.conf trunk/scintilla/KeyWords.cxx trunk/scintilla/Makefile.am trunk/scintilla/makefile.win32 trunk/src/about.c trunk/src/filetypes.c trunk/src/filetypes.h trunk/src/highlighting.c trunk/wscript
Added Paths: ----------- trunk/data/filetypes.erlang trunk/scintilla/LexErlang.cxx
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2010-10-20 12:29:27 UTC (rev 5307) +++ trunk/ChangeLog 2010-10-20 15:45:25 UTC (rev 5308) @@ -5,6 +5,11 @@ Don't hide the menu when only the default item is available. * data/colorschemes, data/colorschemes/alt.conf, wscript, Makefile.am: Add alternative color scheme based on Python colors. + * scintilla/LexErlang.cxx, scintilla/makefile.win32, + scintilla/KeyWords.cxx, scintilla/Makefile.am, src/highlighting.c, + src/about.c, src/filetypes.c, src/filetypes.h, THANKS, + data/filetype_extensions.conf, data/filetypes.erlang, wscript: + Add Erlang filetype (patch by Taylor Venable, thanks).
2010-10-18 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/THANKS =================================================================== --- trunk/THANKS 2010-10-20 12:29:27 UTC (rev 5307) +++ trunk/THANKS 2010-10-20 15:45:25 UTC (rev 5308) @@ -85,6 +85,7 @@ Thomas Huth <th(dot)huth(at)googlemail(dot)com> - Forth filetype Adam Ples <adamples(at)users(dot)sourceforge(dot)net> - Group encodings in open dialog Mário Silva <sharelider(at)gmail(dot)com> - Lisp filetype +Taylor Venable <taylor(at)metasyntax(dot)net> - Erlang filetype
Translators: ------------
Modified: trunk/data/filetype_extensions.conf =================================================================== --- trunk/data/filetype_extensions.conf 2010-10-20 12:29:27 UTC (rev 5307) +++ trunk/data/filetype_extensions.conf 2010-10-20 15:45:25 UTC (rev 5308) @@ -16,6 +16,7 @@ D=*.d;*.di; Diff=*.diff;*.patch;*.rej; Docbook=*.docbook; +Erlang=*.erl; F77=*.f;*.for;*.ftn;*.f77; Ferite=*.fe; Forth=*.fs;*.fth;
Added: trunk/data/filetypes.erlang =================================================================== --- trunk/data/filetypes.erlang (rev 0) +++ trunk/data/filetypes.erlang 2010-10-20 15:45:25 UTC (rev 5308) @@ -0,0 +1,71 @@ +[styling] +# Each of these (...) refers to the lexer state SCE_ERLANG_(...) +default=default +comment=comment +variable=default +number=number +keyword=word +string=string +operator=operator +atom=default +function_name=default,bold +character=default +macro=preprocessor +record=type +preproc=preprocessor +node_name=default +comment_function=comment +comment_module=comment +comment_doc=comment +comment_doc_macro=comment +atom_quoted=default +macro_quoted=default +record_quoted=default +node_name_quoted=default +bifs=word2 +modules=default +modules_att=preprocessor +unknown=default + +[keywords] +# all items must be in one line +keywords=after and andalso band begin bnot bor bsl bsr bxor case catch cond div end fun if let not of or orelse query receive rem try when xor +# Erlang built-in functions (BIFs) +bifs=erlang: abs adler32 adler32_combine erlang:append_element apply atom_to_binary atom_to_list binary_to_atom binary_to_existing_atom binary_to_list bitstring_to_list binary_to_term bit_size erlang:bump_reductions byte_size erlang:cancel_timer check_process_code concat_binary crc32 crc32_combine date decode_packet delete_module erlang:demonitor disconnect_node erlang:display element erase erlang:error exit float float_to_list erlang:fun_info erlang:fun_to_list erlang:function_exported garbage_collect get erlang:get_cookie get_keys erlang:get_stacktrace group_leader halt erlang:hash hd erlang:hibernate integer_to_list erlang:integer_to_list iolist_to_binary iolist_size is_alive is_atom is_binary is_bitstring is_boolean erlang:is_builtin is_float is_function is_integer is_list is_number is_pid is_port is_process_alive is_record is_reference is_tuple length link list_to_atom list_to_binary list_to_bitstring list_to_existing_atom list_to_float list_to_integer erlang:list_to_integer list_to_pid list_to_tuple load_module erlang:load_nif erlang:loaded erlang:localtime erlang:localtime_to_universaltime make_ref erlang:make_tuple erlang:max erlang:md5 erlang:md5_final erlang:md5_init erlang:md5_update erlang:memory erlang:min module_loaded erlang:monitor monitor_node node nodes now open_port erlang:phash erlang:phash2 pid_to_list port_close port_command erlang:port_command port_connect port_control erlang:port_call erlang:port_info erlang:port_to_list erlang:ports pre_loaded erlang:process_display process_flag process_info processes purge_module put erlang:raise erlang:read_timer erlang:ref_to_list register registered erlang:resume_process round self erlang:send erlang:send_after erlang:send_nosuspend erlang:set_cookie setelement size spawn spawn_link spawn_monitor spawn_opt split_binary erlang:start_timer statistics erlang:suspend_process erlang:system_flag erlang:system_info erlang:system_monitor erlang:system_profile term_to_binary throw time tl erlang:trace erlang:trace_delivered erlang:trace_info erlang:trace_pattern trunc tuple_size tuple_to_list erlang:universaltime erlang:universaltime_to_localtime unlink unregister whereis erlang:yield +# Erlang preprocessor instructions +preproc=-define -else -endif -ifdef -ifndef -include -include_lib -undef +# Erlang module attributes +module=-behavior -behaviour -compile -created -created_by -export -file -import -module -modified -modified_by -record -revision -spec -type -vsn +# Erlang documentation helpers +doc=@author @clear @copyright @deprecated @doc @docfile @end @equiv @headerfile @hidden @private @reference @see @since @spec @throws @title @todo @TODO @type @version +# Erlang documentation macros +doc_macro=@date @docRoot @link @module @package @section @time @type @version + +[settings] +# default extension used when saving files +extension=erl + +# the following characters are these which a "word" can contains, see documentation +#wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 + +# if only single comment char is supported like # in this file, leave comment_close blank +comment_open=% +comment_close= + +# set to false if a comment character/string should start at column 0 of a line, true uses any +# indentation of the line, e.g. setting to true causes the following on pressing CTRL+d + #command_example(); +# setting to false would generate this +# command_example(); +# This setting works only for single line comments +comment_use_indent=true + +# context action command (please see Geany's main documentation for details) +context_action_cmd= + +[build_settings] +# %f will be replaced by the complete filename +# %e will be replaced by the filename without extension +# (use only one of it at one time) +compiler=erlc "%f" +run_cmd=erl "%f"
Property changes on: trunk/data/filetypes.erlang ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native
Modified: trunk/scintilla/KeyWords.cxx =================================================================== --- trunk/scintilla/KeyWords.cxx 2010-10-20 12:29:27 UTC (rev 5307) +++ trunk/scintilla/KeyWords.cxx 2010-10-20 15:45:25 UTC (rev 5308) @@ -337,6 +337,7 @@ LINK_LEXER(lmCss); LINK_LEXER(lmD); LINK_LEXER(lmDiff); + LINK_LEXER(lmErlang); LINK_LEXER(lmF77); LINK_LEXER(lmForth); LINK_LEXER(lmFortran);
Added: trunk/scintilla/LexErlang.cxx =================================================================== --- trunk/scintilla/LexErlang.cxx (rev 0) +++ trunk/scintilla/LexErlang.cxx 2010-10-20 15:45:25 UTC (rev 5308) @@ -0,0 +1,619 @@ +// Scintilla source code edit control +// Copyright 1998-2001 by Neil Hodgson neilh@scintilla.org +// The License.txt file describes the conditions under which this software may be distributed. +/** @file LexErlang.cxx + ** Lexer for Erlang. + ** Enhanced by Etienne 'Lenain' Girondel (lenaing@gmail.com) + ** Originally wrote by Peter-Henry Mander, + ** based on Matlab lexer by Jos\xE9 Fonseca. + **/ + +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <stdio.h> +#include <stdarg.h> + +#include "Platform.h" +#include "PropSet.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "KeyWords.h" +#include "Scintilla.h" +#include "SciLexer.h" + +#ifdef SCI_NAMESPACE +using namespace Scintilla; +#endif + +static int is_radix(int radix, int ch) { + int digit; + + if (36 < radix || 2 > radix) + return 0; + + if (isdigit(ch)) { + digit = ch - '0'; + } else if (isalnum(ch)) { + digit = toupper(ch) - 'A' + 10; + } else { + return 0; + } + + return (digit < radix); +} + +typedef enum { + STATE_NULL, + COMMENT, + COMMENT_FUNCTION, + COMMENT_MODULE, + COMMENT_DOC, + COMMENT_DOC_MACRO, + ATOM_UNQUOTED, + ATOM_QUOTED, + NODE_NAME_UNQUOTED, + NODE_NAME_QUOTED, + MACRO_START, + MACRO_UNQUOTED, + MACRO_QUOTED, + RECORD_START, + RECORD_UNQUOTED, + RECORD_QUOTED, + NUMERAL_START, + NUMERAL_BASE_VALUE, + NUMERAL_FLOAT, + NUMERAL_EXPONENT, + PREPROCESSOR +} atom_parse_state_t; + +static inline bool IsAWordChar(const int ch) { + return (ch < 0x80) && (ch != ' ') && (isalnum(ch) || ch == '_'); +} + +static void ColouriseErlangDoc(unsigned int startPos, int length, int initStyle, + WordList *keywordlists[], Accessor &styler) { + + StyleContext sc(startPos, length, initStyle, styler); + WordList &reservedWords = *keywordlists[0]; + WordList &erlangBIFs = *keywordlists[1]; + WordList &erlangPreproc = *keywordlists[2]; + WordList &erlangModulesAtt = *keywordlists[3]; + WordList &erlangDoc = *keywordlists[4]; + WordList &erlangDocMacro = *keywordlists[5]; + int radix_digits = 0; + int exponent_digits = 0; + atom_parse_state_t parse_state = STATE_NULL; + atom_parse_state_t old_parse_state = STATE_NULL; + bool to_late_to_comment = false; + char cur[100]; + int old_style = SCE_ERLANG_DEFAULT; + + styler.StartAt(startPos); + + for (; sc.More(); sc.Forward()) { + int style = SCE_ERLANG_DEFAULT; + if (STATE_NULL != parse_state) { + + switch (parse_state) { + + case STATE_NULL : sc.SetState(SCE_ERLANG_DEFAULT); break; + + /* COMMENTS ------------------------------------------------------*/ + case COMMENT : { + if (sc.ch != '%') { + to_late_to_comment = true; + } else if (!to_late_to_comment && sc.ch == '%') { + // Switch to comment level 2 (Function) + sc.ChangeState(SCE_ERLANG_COMMENT_FUNCTION); + old_style = SCE_ERLANG_COMMENT_FUNCTION; + parse_state = COMMENT_FUNCTION; + sc.Forward(); + } + } + // V--- Falling through! + case COMMENT_FUNCTION : { + if (sc.ch != '%') { + to_late_to_comment = true; + } else if (!to_late_to_comment && sc.ch == '%') { + // Switch to comment level 3 (Module) + sc.ChangeState(SCE_ERLANG_COMMENT_MODULE); + old_style = SCE_ERLANG_COMMENT_MODULE; + parse_state = COMMENT_MODULE; + sc.Forward(); + } + } + // V--- Falling through! + case COMMENT_MODULE : { + if (parse_state != COMMENT) { + // Search for comment documentation + if (sc.chNext == '@') { + old_parse_state = parse_state; + parse_state = ('{' == sc.ch) + ? COMMENT_DOC_MACRO + : COMMENT_DOC; + sc.ForwardSetState(sc.state); + } + } + + // All comments types fall here. + if (sc.atLineEnd) { + to_late_to_comment = false; + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + case COMMENT_DOC : + // V--- Falling through! + case COMMENT_DOC_MACRO : { + + if (!isalnum(sc.ch)) { + // Try to match documentation comment + sc.GetCurrent(cur, sizeof(cur)); + + if (parse_state == COMMENT_DOC_MACRO + && erlangDocMacro.InList(cur)) { + sc.ChangeState(SCE_ERLANG_COMMENT_DOC_MACRO); + while (sc.ch != '}' && !sc.atLineEnd) + sc.Forward(); + } else if (erlangDoc.InList(cur)) { + sc.ChangeState(SCE_ERLANG_COMMENT_DOC); + } else { + sc.ChangeState(old_style); + } + + // Switch back to old state + sc.SetState(old_style); + parse_state = old_parse_state; + } + + if (sc.atLineEnd) { + to_late_to_comment = false; + sc.ChangeState(old_style); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* -------------------------------------------------------------- */ + /* Atoms ---------------------------------------------------------*/ + case ATOM_UNQUOTED : { + if ('@' == sc.ch){ + parse_state = NODE_NAME_UNQUOTED; + } else if (sc.ch == ':') { + // Searching for module name + if (sc.chNext == ' ') { + // error + sc.ChangeState(SCE_ERLANG_UNKNOWN); + parse_state = STATE_NULL; + } else { + sc.Forward(); + if (isalnum(sc.ch)) { + sc.GetCurrent(cur, sizeof(cur)); + sc.ChangeState(SCE_ERLANG_MODULES); + sc.SetState(SCE_ERLANG_MODULES); + } + } + } else if (!IsAWordChar(sc.ch)) { + + sc.GetCurrent(cur, sizeof(cur)); + if (reservedWords.InList(cur)) { + style = SCE_ERLANG_KEYWORD; + } else if (erlangBIFs.InList(cur) + && strcmp(cur,"erlang:")){ + style = SCE_ERLANG_BIFS; + } else if (sc.ch == '(' || '/' == sc.ch){ + style = SCE_ERLANG_FUNCTION_NAME; + } else { + style = SCE_ERLANG_ATOM; + } + + sc.ChangeState(style); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + + } break; + + case ATOM_QUOTED : { + if ( '@' == sc.ch ){ + parse_state = NODE_NAME_QUOTED; + } else if (''' == sc.ch && '\' != sc.chPrev) { + sc.ChangeState(SCE_ERLANG_ATOM); + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* -------------------------------------------------------------- */ + /* Node names ----------------------------------------------------*/ + case NODE_NAME_UNQUOTED : { + if ('@' == sc.ch) { + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else if (!IsAWordChar(sc.ch)) { + sc.ChangeState(SCE_ERLANG_NODE_NAME); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + case NODE_NAME_QUOTED : { + if ('@' == sc.ch) { + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else if (''' == sc.ch && '\' != sc.chPrev) { + sc.ChangeState(SCE_ERLANG_NODE_NAME_QUOTED); + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* -------------------------------------------------------------- */ + /* Records -------------------------------------------------------*/ + case RECORD_START : { + if (''' == sc.ch) { + parse_state = RECORD_QUOTED; + } else if (isalpha(sc.ch) && islower(sc.ch)) { + parse_state = RECORD_UNQUOTED; + } else { // error + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + case RECORD_UNQUOTED : { + if (!IsAWordChar(sc.ch)) { + sc.ChangeState(SCE_ERLANG_RECORD); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + case RECORD_QUOTED : { + if (''' == sc.ch && '\' != sc.chPrev) { + sc.ChangeState(SCE_ERLANG_RECORD_QUOTED); + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* -------------------------------------------------------------- */ + /* Macros --------------------------------------------------------*/ + case MACRO_START : { + if (''' == sc.ch) { + parse_state = MACRO_QUOTED; + } else if (isalpha(sc.ch)) { + parse_state = MACRO_UNQUOTED; + } else { // error + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + case MACRO_UNQUOTED : { + if (!IsAWordChar(sc.ch)) { + sc.ChangeState(SCE_ERLANG_MACRO); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + case MACRO_QUOTED : { + if (''' == sc.ch && '\' != sc.chPrev) { + sc.ChangeState(SCE_ERLANG_MACRO_QUOTED); + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* -------------------------------------------------------------- */ + /* Numerics ------------------------------------------------------*/ + /* Simple integer */ + case NUMERAL_START : { + if (isdigit(sc.ch)) { + radix_digits *= 10; + radix_digits += sc.ch - '0'; // Assuming ASCII here! + } else if ('#' == sc.ch) { + if (2 > radix_digits || 36 < radix_digits) { + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else { + parse_state = NUMERAL_BASE_VALUE; + } + } else if ('.' == sc.ch && isdigit(sc.chNext)) { + radix_digits = 0; + parse_state = NUMERAL_FLOAT; + } else if ('e' == sc.ch || 'E' == sc.ch) { + exponent_digits = 0; + parse_state = NUMERAL_EXPONENT; + } else { + radix_digits = 0; + sc.ChangeState(SCE_ERLANG_NUMBER); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* Integer in other base than 10 (x#yyy) */ + case NUMERAL_BASE_VALUE : { + if (!is_radix(radix_digits,sc.ch)) { + radix_digits = 0; + + if (!isalnum(sc.ch)) + sc.ChangeState(SCE_ERLANG_NUMBER); + + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* Float (x.yyy) */ + case NUMERAL_FLOAT : { + if ('e' == sc.ch || 'E' == sc.ch) { + exponent_digits = 0; + parse_state = NUMERAL_EXPONENT; + } else if (!isdigit(sc.ch)) { + sc.ChangeState(SCE_ERLANG_NUMBER); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* Exponent, either integer or float (xEyy, x.yyEzzz) */ + case NUMERAL_EXPONENT : { + if (('-' == sc.ch || '+' == sc.ch) + && (isdigit(sc.chNext))) { + sc.Forward(); + } else if (!isdigit(sc.ch)) { + if (0 < exponent_digits) + sc.ChangeState(SCE_ERLANG_NUMBER); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else { + ++exponent_digits; + } + } break; + + /* -------------------------------------------------------------- */ + /* Preprocessor --------------------------------------------------*/ + case PREPROCESSOR : { + if (!IsAWordChar(sc.ch)) { + + sc.GetCurrent(cur, sizeof(cur)); + if (erlangPreproc.InList(cur)) { + style = SCE_ERLANG_PREPROC; + } else if (erlangModulesAtt.InList(cur)) { + style = SCE_ERLANG_MODULES_ATT; + } + + sc.ChangeState(style); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + } + + } /* End of : STATE_NULL != parse_state */ + else + { + switch (sc.state) { + case SCE_ERLANG_VARIABLE : { + if (!IsAWordChar(sc.ch)) + sc.SetState(SCE_ERLANG_DEFAULT); + } break; + case SCE_ERLANG_STRING : { + if (sc.ch == '"' && sc.chPrev != '\') + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } break; + case SCE_ERLANG_COMMENT : { + if (sc.atLineEnd) + sc.SetState(SCE_ERLANG_DEFAULT); + } break; + case SCE_ERLANG_CHARACTER : { + if (sc.chPrev == '\') { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } else if (sc.ch != '\') { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } + } break; + case SCE_ERLANG_OPERATOR : { + if (sc.chPrev == '.') { + if (sc.ch == '*' || sc.ch == '/' || sc.ch == '\' + || sc.ch == '^') { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } else if (sc.ch == ''') { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } else { + sc.SetState(SCE_ERLANG_DEFAULT); + } + } else { + sc.SetState(SCE_ERLANG_DEFAULT); + } + } break; + } + } + + if (sc.state == SCE_ERLANG_DEFAULT) { + bool no_new_state = false; + + switch (sc.ch) { + case '"' : sc.SetState(SCE_ERLANG_STRING); break; + case '$' : sc.SetState(SCE_ERLANG_CHARACTER); break; + case '%' : { + parse_state = COMMENT; + sc.SetState(SCE_ERLANG_COMMENT); + } break; + case '#' : { + parse_state = RECORD_START; + sc.SetState(SCE_ERLANG_UNKNOWN); + } break; + case '?' : { + parse_state = MACRO_START; + sc.SetState(SCE_ERLANG_UNKNOWN); + } break; + case ''' : { + parse_state = ATOM_QUOTED; + sc.SetState(SCE_ERLANG_UNKNOWN); + } break; + case '+' : + case '-' : { + if (IsADigit(sc.chNext)) { + parse_state = NUMERAL_START; + radix_digits = 0; + sc.SetState(SCE_ERLANG_UNKNOWN); + } else if (sc.ch != '+') { + parse_state = PREPROCESSOR; + sc.SetState(SCE_ERLANG_UNKNOWN); + } + } break; + default : no_new_state = true; + } + + if (no_new_state) { + if (isdigit(sc.ch)) { + parse_state = NUMERAL_START; + radix_digits = sc.ch - '0'; + sc.SetState(SCE_ERLANG_UNKNOWN); + } else if (isupper(sc.ch) || '_' == sc.ch) { + sc.SetState(SCE_ERLANG_VARIABLE); + } else if (isalpha(sc.ch)) { + parse_state = ATOM_UNQUOTED; + sc.SetState(SCE_ERLANG_UNKNOWN); + } else if (isoperator(static_cast<char>(sc.ch)) + || sc.ch == '\') { + sc.SetState(SCE_ERLANG_OPERATOR); + } + } + } + + } + sc.Complete(); +} + +static int ClassifyErlangFoldPoint( + Accessor &styler, + int styleNext, + int keyword_start +) { + int lev = 0; + if (styler.Match(keyword_start,"case") + || ( + styler.Match(keyword_start,"fun") + && (SCE_ERLANG_FUNCTION_NAME != styleNext) + ) + || styler.Match(keyword_start,"if") + || styler.Match(keyword_start,"query") + || styler.Match(keyword_start,"receive") + ) { + ++lev; + } else if (styler.Match(keyword_start,"end")) { + --lev; + } + + return lev; +} + +static void FoldErlangDoc( + unsigned int startPos, int length, int initStyle, + WordList** /*keywordlists*/, Accessor &styler +) { + unsigned int endPos = startPos + length; + int currentLine = styler.GetLine(startPos); + int lev; + int previousLevel = styler.LevelAt(currentLine) & SC_FOLDLEVELNUMBERMASK; + int currentLevel = previousLevel; + int styleNext = styler.StyleAt(startPos); + int style = initStyle; + int stylePrev; + int keyword_start = 0; + char ch; + char chNext = styler.SafeGetCharAt(startPos); + bool atEOL; + + for (unsigned int i = startPos; i < endPos; i++) { + ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + + // Get styles + stylePrev = style; + style = styleNext; + styleNext = styler.StyleAt(i + 1); + atEOL = ((ch == '\r') && (chNext != '\n')) || (ch == '\n'); + + if (stylePrev != SCE_ERLANG_KEYWORD + && style == SCE_ERLANG_KEYWORD) { + keyword_start = i; + } + + // Fold on keywords + if (stylePrev == SCE_ERLANG_KEYWORD + && style != SCE_ERLANG_KEYWORD + && style != SCE_ERLANG_ATOM + ) { + currentLevel += ClassifyErlangFoldPoint(styler, + styleNext, + keyword_start); + } + + // Fold on comments + if (style == SCE_ERLANG_COMMENT + || style == SCE_ERLANG_COMMENT_MODULE + || style == SCE_ERLANG_COMMENT_FUNCTION) { + + if (ch == '%' && chNext == '{') { + currentLevel++; + } else if (ch == '%' && chNext == '}') { + currentLevel--; + } + } + + // Fold on braces + if (style == SCE_ERLANG_OPERATOR) { + if (ch == '{' || ch == '(' || ch == '[') { + currentLevel++; + } else if (ch == '}' || ch == ')' || ch == ']') { + currentLevel--; + } + } + + + if (atEOL) { + lev = previousLevel; + + if (currentLevel > previousLevel) + lev |= SC_FOLDLEVELHEADERFLAG; + + if (lev != styler.LevelAt(currentLine)) + styler.SetLevel(currentLine, lev); + + currentLine++; + previousLevel = currentLevel; + } + + } + + // Fill in the real level of the next line, keeping the current flags as they will be filled in later + styler.SetLevel(currentLine, + previousLevel + | (styler.LevelAt(currentLine) & ~SC_FOLDLEVELNUMBERMASK)); +} + +static const char * const erlangWordListDesc[] = { + "Erlang Reserved words", + "Erlang BIFs", + "Erlang Preprocessor", + "Erlang Module Attributes", + "Erlang Documentation", + "Erlang Documentation Macro", + 0 +}; + +LexerModule lmErlang( + SCLEX_ERLANG, + ColouriseErlangDoc, + "erlang", + FoldErlangDoc, + erlangWordListDesc);
Property changes on: trunk/scintilla/LexErlang.cxx ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native
Modified: trunk/scintilla/Makefile.am =================================================================== --- trunk/scintilla/Makefile.am 2010-10-20 12:29:27 UTC (rev 5307) +++ trunk/scintilla/Makefile.am 2010-10-20 15:45:25 UTC (rev 5308) @@ -15,6 +15,7 @@ LexCmake.cxx \ LexCSS.cxx \ LexD.cxx \ +LexErlang.cxx \ LexForth.cxx \ LexFortran.cxx \ LexHaskell.cxx \
Modified: trunk/scintilla/makefile.win32 =================================================================== --- trunk/scintilla/makefile.win32 2010-10-20 12:29:27 UTC (rev 5307) +++ trunk/scintilla/makefile.win32 2010-10-20 15:45:25 UTC (rev 5308) @@ -62,7 +62,7 @@ LEXOBJS=\ LexAda.o LexBash.o LexAsm.o LexCSS.o LexCPP.o LexHTML.o LexOthers.o LexPascal.o \ LexPerl.o LexPython.o LexSQL.o LexCaml.o LexTCL.o LexTxt2tags.o LexRuby.o \ -LexForth.o LexFortran.o LexVHDL.o LexVerilog.o \ +LexErlang.o LexForth.o LexFortran.o LexVHDL.o LexVerilog.o \ LexMarkdown.o LexMatlab.o \ LexD.o LexLisp.o LexLua.o LexHaskell.o LexBasic.o LexR.o LexYAML.o LexCmake.o LexNsis.o #--Autogenerated -- end of automatically generated section
Modified: trunk/src/about.c =================================================================== --- trunk/src/about.c 2010-10-20 12:29:27 UTC (rev 5307) +++ trunk/src/about.c 2010-10-20 15:45:25 UTC (rev 5308) @@ -98,7 +98,8 @@ "Mário Silva, Marko Peric, Matti Mårds, " "Moritz Barsnick, Ondrej Donek, Peter Strand, Philipp Gildein, Pierre Joye, Rob van der Linde, " "Robert McGinley, Roland Baudin, Ross McKay, S Jagannathan, Saleem Abdulrasool, " -"Sebastian Kraft, Shiv, Slava Semushin, Stefan Oltmanns, Tamim, Thomas Huth, Thomas Martitz, Tomás Vírseda, " +"Sebastian Kraft, Shiv, Slava Semushin, Stefan Oltmanns, Tamim, Taylor Venable, " +"Thomas Huth, Thomas Martitz, Tomás Vírseda, " "Tyler Mulligan, Walery Studennikov, Yura Siamashka";
Modified: trunk/src/filetypes.c =================================================================== --- trunk/src/filetypes.c 2010-10-20 12:29:27 UTC (rev 5307) +++ trunk/src/filetypes.c 2010-10-20 15:45:25 UTC (rev 5308) @@ -517,6 +517,17 @@ ft->comment_close = NULL; ft->group = GEANY_FILETYPE_GROUP_SCRIPT;
+#define ERLANG + ft = filetypes[GEANY_FILETYPES_ERLANG]; + ft->lang = -2; + ft->name = g_strdup("Erlang"); + filetype_make_title(ft, TITLE_SOURCE_FILE); + ft->extension = g_strdup("erl"); + ft->pattern = utils_strv_new("*.erl", NULL); + ft->comment_open = g_strdup("%"); + ft->comment_close = NULL; + ft->group = GEANY_FILETYPE_GROUP_SCRIPT; + #define CONF ft = filetypes[GEANY_FILETYPES_CONF]; ft->lang = 10;
Modified: trunk/src/filetypes.h =================================================================== --- trunk/src/filetypes.h 2010-10-20 12:29:27 UTC (rev 5307) +++ trunk/src/filetypes.h 2010-10-20 15:45:25 UTC (rev 5308) @@ -87,6 +87,7 @@ GEANY_FILETYPES_VERILOG, GEANY_FILETYPES_FORTH, GEANY_FILETYPES_LISP, + GEANY_FILETYPES_ERLANG, /* ^ append items here */ GEANY_MAX_BUILT_IN_FILETYPES /* Don't use this, use filetypes_array->len instead */ }
Modified: trunk/src/highlighting.c =================================================================== --- trunk/src/highlighting.c 2010-10-20 12:29:27 UTC (rev 5307) +++ trunk/src/highlighting.c 2010-10-20 15:45:25 UTC (rev 5308) @@ -1137,6 +1137,88 @@ }
+static void styleset_erlang_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) +{ + new_styleset(ft_id, 26); + get_keyfile_style(config, config_home, "default", &style_sets[ft_id].styling[0]); + get_keyfile_style(config, config_home, "comment", &style_sets[ft_id].styling[1]); + get_keyfile_style(config, config_home, "variable", &style_sets[ft_id].styling[2]); + get_keyfile_style(config, config_home, "number", &style_sets[ft_id].styling[3]); + get_keyfile_style(config, config_home, "keyword", &style_sets[ft_id].styling[4]); + get_keyfile_style(config, config_home, "string", &style_sets[ft_id].styling[5]); + get_keyfile_style(config, config_home, "operator", &style_sets[ft_id].styling[6]); + get_keyfile_style(config, config_home, "atom", &style_sets[ft_id].styling[7]); + get_keyfile_style(config, config_home, "function_name", &style_sets[ft_id].styling[8]); + get_keyfile_style(config, config_home, "character", &style_sets[ft_id].styling[9]); + get_keyfile_style(config, config_home, "macro", &style_sets[ft_id].styling[10]); + get_keyfile_style(config, config_home, "record", &style_sets[ft_id].styling[11]); + get_keyfile_style(config, config_home, "preproc", &style_sets[ft_id].styling[12]); + get_keyfile_style(config, config_home, "node_name", &style_sets[ft_id].styling[13]); + get_keyfile_style(config, config_home, "comment_function", &style_sets[ft_id].styling[14]); + get_keyfile_style(config, config_home, "comment_module", &style_sets[ft_id].styling[15]); + get_keyfile_style(config, config_home, "comment_doc", &style_sets[ft_id].styling[16]); + get_keyfile_style(config, config_home, "comment_doc_macro", &style_sets[ft_id].styling[17]); + get_keyfile_style(config, config_home, "atom_quoted", &style_sets[ft_id].styling[18]); + get_keyfile_style(config, config_home, "macro_quoted", &style_sets[ft_id].styling[19]); + get_keyfile_style(config, config_home, "record_quoted", &style_sets[ft_id].styling[20]); + get_keyfile_style(config, config_home, "node_name_quoted", &style_sets[ft_id].styling[21]); + get_keyfile_style(config, config_home, "bifs", &style_sets[ft_id].styling[22]); + get_keyfile_style(config, config_home, "modules", &style_sets[ft_id].styling[23]); + get_keyfile_style(config, config_home, "modules_att", &style_sets[ft_id].styling[24]); + get_keyfile_style(config, config_home, "unknown", &style_sets[ft_id].styling[25]); + + style_sets[ft_id].keywords = g_new(gchar*, 6); + get_keyfile_keywords(config, config_home, "keywords", ft_id, 0); + get_keyfile_keywords(config, config_home, "bifs", ft_id, 1); + get_keyfile_keywords(config, config_home, "preproc", ft_id, 2); + get_keyfile_keywords(config, config_home, "module", ft_id, 3); + get_keyfile_keywords(config, config_home, "doc", ft_id, 4); + get_keyfile_keywords(config, config_home, "doc_macro", ft_id, 5); + style_sets[ft_id].keywords[6] = NULL; +} + + +static void styleset_erlang(ScintillaObject *sci, gint ft_id) +{ + apply_filetype_properties(sci, SCLEX_ERLANG, ft_id); + + sci_set_keywords(sci, 0, style_sets[ft_id].keywords[0]); + sci_set_keywords(sci, 1, style_sets[ft_id].keywords[1]); + sci_set_keywords(sci, 2, style_sets[ft_id].keywords[2]); + sci_set_keywords(sci, 3, style_sets[ft_id].keywords[3]); + sci_set_keywords(sci, 4, style_sets[ft_id].keywords[4]); + sci_set_keywords(sci, 5, style_sets[ft_id].keywords[5]); + + set_sci_style(sci, STYLE_DEFAULT, ft_id, 0); + set_sci_style(sci, SCE_ERLANG_DEFAULT, ft_id, 0); + set_sci_style(sci, SCE_ERLANG_COMMENT, ft_id, 1); + set_sci_style(sci, SCE_ERLANG_VARIABLE, ft_id, 2); + set_sci_style(sci, SCE_ERLANG_NUMBER, ft_id, 3); + set_sci_style(sci, SCE_ERLANG_KEYWORD, ft_id, 4); + set_sci_style(sci, SCE_ERLANG_STRING, ft_id, 5); + set_sci_style(sci, SCE_ERLANG_OPERATOR, ft_id, 6); + set_sci_style(sci, SCE_ERLANG_ATOM, ft_id, 7); + set_sci_style(sci, SCE_ERLANG_FUNCTION_NAME, ft_id, 8); + set_sci_style(sci, SCE_ERLANG_CHARACTER, ft_id, 9); + set_sci_style(sci, SCE_ERLANG_MACRO, ft_id, 10); + set_sci_style(sci, SCE_ERLANG_RECORD, ft_id, 11); + set_sci_style(sci, SCE_ERLANG_PREPROC, ft_id, 12); + set_sci_style(sci, SCE_ERLANG_NODE_NAME, ft_id, 13); + set_sci_style(sci, SCE_ERLANG_COMMENT_FUNCTION, ft_id, 14); + set_sci_style(sci, SCE_ERLANG_COMMENT_MODULE, ft_id, 15); + set_sci_style(sci, SCE_ERLANG_COMMENT_DOC, ft_id, 16); + set_sci_style(sci, SCE_ERLANG_COMMENT_DOC_MACRO, ft_id, 17); + set_sci_style(sci, SCE_ERLANG_ATOM_QUOTED, ft_id, 18); + set_sci_style(sci, SCE_ERLANG_MACRO_QUOTED, ft_id, 19); + set_sci_style(sci, SCE_ERLANG_RECORD_QUOTED, ft_id, 20); + set_sci_style(sci, SCE_ERLANG_NODE_NAME_QUOTED, ft_id, 21); + set_sci_style(sci, SCE_ERLANG_BIFS, ft_id, 22); + set_sci_style(sci, SCE_ERLANG_MODULES, ft_id, 23); + set_sci_style(sci, SCE_ERLANG_MODULES_ATT, ft_id, 24); + set_sci_style(sci, SCE_ERLANG_UNKNOWN, ft_id, 25); +} + + static void styleset_latex_init(gint ft_id, GKeyFile *config, GKeyFile *config_home) { new_styleset(ft_id, 5); @@ -3326,6 +3408,7 @@ init_styleset_case(GEANY_FILETYPES_D, styleset_d_init); init_styleset_case(GEANY_FILETYPES_DIFF, styleset_diff_init); init_styleset_case(GEANY_FILETYPES_LISP, styleset_lisp_init); + init_styleset_case(GEANY_FILETYPES_ERLANG, styleset_erlang_init); init_styleset_case(GEANY_FILETYPES_DOCBOOK, styleset_docbook_init); init_styleset_case(GEANY_FILETYPES_FERITE, styleset_ferite_init); init_styleset_case(GEANY_FILETYPES_F77, styleset_f77_init); @@ -3397,6 +3480,7 @@ styleset_case(GEANY_FILETYPES_D, styleset_d); styleset_case(GEANY_FILETYPES_DIFF, styleset_diff); styleset_case(GEANY_FILETYPES_LISP, styleset_lisp); + styleset_case(GEANY_FILETYPES_ERLANG, styleset_erlang); styleset_case(GEANY_FILETYPES_DOCBOOK, styleset_docbook); styleset_case(GEANY_FILETYPES_FERITE, styleset_ferite); styleset_case(GEANY_FILETYPES_F77, styleset_f77);
Modified: trunk/wscript =================================================================== --- trunk/wscript 2010-10-20 12:29:27 UTC (rev 5307) +++ trunk/wscript 2010-10-20 15:45:25 UTC (rev 5308) @@ -87,7 +87,7 @@ 'scintilla/KeyWords.cxx', 'scintilla/LexAda.cxx', 'scintilla/LexAsm.cxx', 'scintilla/LexBash.cxx', 'scintilla/LexBasic.cxx', 'scintilla/LexCaml.cxx', 'scintilla/LexCmake.cxx', 'scintilla/LexCPP.cxx', - 'scintilla/LexCSS.cxx', 'scintilla/LexD.cxx', 'scintilla/LexForth.cxx', + 'scintilla/LexCSS.cxx', 'scintilla/LexD.cxx', 'scintilla/LexErlang.cxx', 'scintilla/LexForth.cxx', 'scintilla/LexFortran.cxx', 'scintilla/LexHaskell.cxx', 'scintilla/LexHTML.cxx', 'scintilla/LexLisp.cxx', 'scintilla/LexLua.cxx', 'scintilla/LexMarkdown.cxx', 'scintilla/LexMatlab.cxx', 'scintilla/LexNsis.cxx', 'scintilla/LexOthers.cxx',
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.