Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AutoIt syntax highlighting #1017

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c449b6c
Add AutoIt syntax highlighting
Skif-off Apr 29, 2016
8122c41
Some fix filetypes.autoit
Skif-off May 26, 2016
2ac0313
Some fix filetypes.autoit:
Skif-off Jun 1, 2016
5fadc42
Merge pull request #2 from geany/master
Skif-off Jun 7, 2017
7588791
Merge pull request #3 from geany/master
Skif-off Aug 25, 2017
d8cae9d
Merge pull request #4 from geany/master
Skif-off Sep 29, 2017
1be0295
Merge pull request #5 from geany/master
Skif-off Oct 4, 2017
f67cbf5
Merge branch 'master' into geany-autoit
Skif-off Oct 4, 2017
25dd7e4
Merge pull request #6 from geany/master
Skif-off Oct 7, 2017
ca32056
Merge pull request #7 from Skif-off/master
Skif-off Oct 7, 2017
3398e3e
Fix indentation
Skif-off Oct 8, 2017
d395266
Add line: style as all other "case"
Skif-off Oct 8, 2017
e183d71
Merge pull request #8 from geany/master
Skif-off Oct 23, 2017
d8ae983
Merge pull request #9 from Skif-off/master
Skif-off Oct 23, 2017
dc6c70b
Merge pull request #10 from geany/master
Skif-off Nov 9, 2017
7280a9f
Merge pull request #11 from Skif-off/master
Skif-off Nov 9, 2017
acf468c
Merge pull request #12 from geany/master
Skif-off Nov 17, 2017
1758d86
Merge pull request #13 from Skif-off/master
Skif-off Nov 17, 2017
5222784
Merge pull request #14 from geany/master
Skif-off Nov 19, 2017
b41c14f
Merge pull request #15 from Skif-off/master
Skif-off Nov 19, 2017
3551f53
AutoIt: Add Ctags parser
Skif-off Nov 23, 2017
8dae73a
Merge pull request #16 from geany/master
Skif-off Dec 6, 2017
75ffca2
Merge pull request #17 from Skif-off/master
Skif-off Dec 6, 2017
cac68fe
Merge pull request #18 from geany/master
Skif-off Dec 17, 2017
386cb8c
Merge pull request #19 from Skif-off/master
Skif-off Dec 17, 2017
4dbc1b0
Merge pull request #20 from geany/master
Skif-off Dec 21, 2017
2d43aa4
Merge pull request #21 from Skif-off/master
Skif-off Dec 21, 2017
c0e25e6
Merge pull request #22 from geany/master
Skif-off Dec 22, 2017
4a9ea3f
Merge pull request #23 from Skif-off/master
Skif-off Dec 22, 2017
0f76309
Merge pull request #24 from geany/master
Skif-off Jan 13, 2018
a98bb2e
Merge pull request #25 from Skif-off/master
Skif-off Jan 13, 2018
0463317
Merge pull request #26 from geany/master
Skif-off Jan 25, 2018
c7f85c1
Merge pull request #27 from Skif-off/master
Skif-off Jan 25, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions ctags/Makefile.am
Expand Up @@ -14,6 +14,7 @@ parsers = \
parsers/actionscript.c \
parsers/asciidoc.c \
parsers/asm.c \
parsers/autoit.c \
parsers/basic.c \
parsers/c.c \
parsers/cobol.c \
Expand Down
3 changes: 2 additions & 1 deletion ctags/main/parsers.h
Expand Up @@ -65,6 +65,7 @@
GoParser, \
JsonParser, \
ZephirParser, \
PowerShellParser
PowerShellParser, \
AutoItParser

#endif /* CTAGS_MAIN_PARSERS_H */
121 changes: 121 additions & 0 deletions ctags/parsers/autoit.c
@@ -0,0 +1,121 @@
/*
* Copyright (c) 2017, Alexey Olenich
*
* This source code is released for free distribution under the terms of the
* GNU General Public License version 2 or (at your option) any later version.
*
* This module contains functions for generating tags for AutoIt functions.
* Homepage https://www.autoitscript.com/site/autoit/
* Online Documentation https://www.autoitscript.com/autoit3/docs/
*
* Functions: (?i)^func[ \t]{1,}([a-z0-9_]{1,}) >> \1
* Regions: (?i)^#region[ \t]*(.*?) >> \1
*/

/*
* INCLUDE FILES
*/
#include "general.h" /* must always come first */

#include <string.h>

#include "parse.h"
#include "read.h"
#include "routines.h"
#include "vstring.h"

/*
* DATA DEFINITIONS
*/
typedef enum {
K_FUNCTION,
K_REGION
} AutoItKind;

static kindOption AutoItKinds [] = {
{ true, 'f', "func", "functions" },
{ true, 'r', "region", "regions" }
};

/*
* FUNCTION DEFINITIONS
*/
static void findAutoItTags (void)
{
vString *name = vStringNew ();
const unsigned char *line;

while ((line = readLineFromInputFile ()) != NULL)
{
const unsigned char* p = line;
if (p [0] == '#')
{
/* min. string "#region" > 7 */
if ((p [1] == 'R' || p [1] == 'r') &&
strlen ((const char *) p) > 8 &&
(p [2] == 'E' || p [2] == 'e') &&
(p [3] == 'G' || p [3] == 'g') &&
(p [4] == 'I' || p [4] == 'i') &&
(p [5] == 'O' || p [5] == 'o') &&
(p [6] == 'N' || p [6] == 'n'))
{
p += 7;
while (isspace ((int) *p))
++p;
while (*p != '\0')
{
vStringPut (name, (int) *p);
++p;
}

if (vStringLength(name) > 0)
{
makeSimpleTag (name, AutoItKinds, K_REGION);
vStringClear (name);
}
}
}
else
{
/* skip white space */
while (isspace ((int) *p))
++p;
/* min. string "func a()" == 8 */
if ((p [0] == 'F' || p [0] == 'f') &&
strlen ((const char *) p) >= 8 &&
(p [1] == 'U' || p [1] == 'u') &&
(p [2] == 'N' || p [2] == 'n') &&
(p [3] == 'C' || p [3] == 'c') &&
isspace ((int) p [4]))
{
p += 5;
while (isspace ((int) *p))
++p;
while (isalnum ((int) *p) || *p == '_')
{
vStringPut (name, (int) *p);
++p;
}
while (isspace ((int) *p))
++p;
if (*p == '(' && (vStringLength(name) > 0))
{
makeSimpleTag (name, AutoItKinds, K_FUNCTION);
vStringClear (name);
}
}
}
}
vStringDelete (name);
}

parserDefinition *AutoItParser (void)
{
static char const *extensions[] = { "au3", "AU3", "aU3", "Au3", NULL };
parserDefinition* def = parserNew ("AutoIt");
def->kinds = AutoItKinds;
def->kindCount = ARRAY_SIZE (AutoItKinds);
def->extensions = extensions;
def->parser = findAutoItTags;
return def;
}
2 changes: 1 addition & 1 deletion src/filetypes.c
Expand Up @@ -186,7 +186,7 @@ static void init_builtin_filetypes(void)
FT_INIT( COFFEESCRIPT, NONE, "CoffeeScript", NULL, SOURCE_FILE, SCRIPT );
FT_INIT( GO, GO, "Go", NULL, SOURCE_FILE, COMPILED );
FT_INIT( ZEPHIR, ZEPHIR, "Zephir", NULL, SOURCE_FILE, COMPILED );
FT_INIT( AU3, NONE, "AutoIt", NULL, SCRIPT, SCRIPT );
FT_INIT( AU3, AUTOIT, "AutoIt", NULL, SCRIPT, SCRIPT );
}


Expand Down
8 changes: 8 additions & 0 deletions src/symbols.c
Expand Up @@ -831,6 +831,14 @@ static void add_top_level_items(GeanyDocument *doc)
&(tv_iters.tag_externvar), _("Extern Variables"), ICON_VAR,
&(tv_iters.tag_other), _("Other"), ICON_OTHER, NULL);
}
case GEANY_FILETYPES_AU3:
{
tag_list_add_groups(tag_store,
&tv_iters.tag_function, _("Functions"), ICON_METHOD,
&tv_iters.tag_other, _("Regions"), ICON_OTHER,
NULL);
break;
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/tagmanager/tm_parser.c
Expand Up @@ -488,6 +488,10 @@ static TMParserMapEntry map_POWERSHELL[] = {
{'v', tm_tag_variable_t},
};

static TMParserMapEntry map_AUTOIT[] = {
{'f', tm_tag_function_t},
{'r', tm_tag_other_t},
};

typedef struct
{
Expand Down Expand Up @@ -550,6 +554,7 @@ static TMParserMap parser_map[] = {
MAP_ENTRY(JSON),
MAP_ENTRY(ZEPHIR),
MAP_ENTRY(POWERSHELL),
MAP_ENTRY(AUTOIT),
};
/* make sure the parser map is consistent and complete */
G_STATIC_ASSERT(G_N_ELEMENTS(parser_map) == TM_PARSER_COUNT);
Expand Down
1 change: 1 addition & 0 deletions src/tagmanager/tm_parser.h
Expand Up @@ -109,6 +109,7 @@ enum
TM_PARSER_JSON,
TM_PARSER_ZEPHIR,
TM_PARSER_POWERSHELL,
TM_PARSER_AUTOIT,
TM_PARSER_COUNT
};

Expand Down
1 change: 1 addition & 0 deletions tests/ctags/Makefile.am
Expand Up @@ -268,6 +268,7 @@ test_sources = \
semicolon.f90 \
shebang.js \
signature.cpp \
simple.au3 \
simple.bas \
simple.cbl \
simple.d \
Expand Down
32 changes: 32 additions & 0 deletions tests/ctags/simple.au3
@@ -0,0 +1,32 @@
; Taken from https://www.autoitscript.com/autoit3/docs/intro/lang_functions.htm

#include <Constants.au3>
#include<GUIConstantsEx.au3>
#include "WindowsConstants.au3"

Local $iNumber = 10
Local $iDoubled = 0

For $i = 1 To 10
$iDoubled = MyDouble($iNumber)
MsgBox($MB_OK, "", $iNumber & " doubled is " & $iDoubled)
$iNumber = $iDoubled
Next
Exit

#Region All functions
Func MyDouble($iValue)
$iValue = $iValue * 2
Return $iValue
EndFunc ;==>MyDouble

func MyDouble0($iValue)
$iValue = $iValue * 2
Return $iValue
EndFunc ;==>MyDouble

FUNC MyDouble1($iValue)
$iValue = $iValue * 2
Return $iValue
EndFunc
#EndRegion All functions
5 changes: 5 additions & 0 deletions tests/ctags/simple.au3.tags
@@ -0,0 +1,5 @@
# format=tagmanager
All functions�524288�0
MyDouble�16�0
MyDouble0�16�0
MyDouble1�16�0