Skip to content

Commit 4049e93

Browse files
committed
[EXPERIMENTAL] Vue: new parser
Continuation of universal-ctags#1581. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
1 parent ff21fed commit 4049e93

File tree

9 files changed

+129
-0
lines changed

9 files changed

+129
-0
lines changed

Units/simple-vue.d/args.ctags

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--sort=no
2+
--extras=+g
3+
--fields=+ln

Units/simple-vue.d/expected.tags

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
slot input.vue /^ <p id="slot">{{ greeting }} World!<\/p>$/;" I line:4 language:HTML
2+
makeWord input.vue /^function makeWord ()$/;" f line:8 language:JavaScript
3+
data input.vue /^ data: function () {$/;" m line:14 language:JavaScript class:module.exports
4+
exports input.vue /^module.exports = {$/;" c line:13 language:JavaScript class:module
5+
p input.vue /^p {$/;" s line:23 language:CSS

Units/simple-vue.d/input.vue

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!-- Taken from https://vuejs.org/v2/guide/single-file-components.html -->
2+
3+
<template>
4+
<p id="slot">{{ greeting }} World!</p>
5+
</template>
6+
7+
<script>
8+
function makeWord ()
9+
{
10+
return 'Hello';
11+
}
12+
13+
module.exports = {
14+
data: function () {
15+
return {
16+
greeting: makeWord ()
17+
}
18+
}
19+
}
20+
</script>
21+
22+
<style scoped>
23+
p {
24+
font-size: 2em;
25+
text-align: center;
26+
}
27+
</style>

docs/news.rst

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ The following parsers have been added:
9393
* TTCN
9494
* TypeScript
9595
* Varlink *peg/packcc*
96+
* Vue *optlib*
9697
* WindRes
9798
* XSLT v1.0 *libxml*
9899
* Yacc

main/parsers_p.h

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
UCtagsAspellParser, \
140140
VhdlParser, \
141141
VimParser, \
142+
VueParser, \
142143
WindResParser, \
143144
YaccParser, \
144145
YumRepoParser, \

optlib/vue.c

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Generated by ./misc/optlib2c from optlib/vue.ctags, Don't edit this manually.
3+
*/
4+
#include "general.h"
5+
#include "parse.h"
6+
#include "routines.h"
7+
#include "field.h"
8+
#include "xtag.h"
9+
10+
11+
static void initializeVueParser (const langType language CTAGS_ATTR_UNUSED)
12+
{
13+
}
14+
15+
extern parserDefinition* VueParser (void)
16+
{
17+
static const char *const extensions [] = {
18+
"vue",
19+
NULL
20+
};
21+
22+
static const char *const aliases [] = {
23+
NULL
24+
};
25+
26+
static const char *const patterns [] = {
27+
NULL
28+
};
29+
30+
static tagRegexTable VueTagRegexTable [] = {
31+
{"<template>\n((.|\n){1,}\n)</template>", "",
32+
"", "{guest=HTML,1start,1end}", NULL, true},
33+
{"<script>\n((.|\n){1,}\n)</script>", "",
34+
"", "{guest=JavaScript,1start,1end}", NULL, true},
35+
{"<style([ ]{1,}[a-z]{1,})*>\n((.|\n){1,}\n)</style>", "",
36+
"", "{guest=CSS,2start,2end}", NULL, true},
37+
};
38+
39+
40+
parserDefinition* const def = parserNew ("Vue");
41+
42+
def->enabled = true;
43+
def->extensions = extensions;
44+
def->patterns = patterns;
45+
def->aliases = aliases;
46+
def->method = METHOD_NOT_CRAFTED|METHOD_REGEX;
47+
def->tagRegexTable = VueTagRegexTable;
48+
def->tagRegexCount = ARRAY_SIZE(VueTagRegexTable);
49+
def->initialize = initializeVueParser;
50+
51+
return def;
52+
}

optlib/vue.ctags

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#
2+
# vue.ctags --- a parser for VueJS Single File Components
3+
#
4+
# Copyright (c) 2019, Red Hat, Inc.
5+
# Copyright (c) 2019, Masatake YAMATO
6+
#
7+
# Author: Masatake YAMATO <yamato@redhat.com>
8+
#
9+
# This program is free software; you can redistribute it and/or
10+
# modify it under the terms of the GNU General Public License
11+
# as published by the Free Software Foundation; either version 2
12+
# of the License, or (at your option) any later version.
13+
#
14+
# This program is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU General Public License for more details.
18+
#
19+
# You should have received a copy of the GNU General Public License
20+
# along with this program; if not, write to the Free Software
21+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22+
# USA.
23+
#
24+
#
25+
# References:
26+
#
27+
# - https://vuejs.org/v2/guide/single-file-components.html
28+
#
29+
--langdef=Vue
30+
--map-Vue=+.vue
31+
32+
--mline-regex-Vue=/<template>\n((.|\n){1,}\n)<\/template>//{guest=HTML,1start,1end}
33+
--mline-regex-Vue=/<script>\n((.|\n){1,}\n)<\/script>//{guest=JavaScript,1start,1end}
34+
--mline-regex-Vue=/<style([ ]{1,}[a-z]{1,})*>\n((.|\n){1,}\n)<\/style>//{guest=CSS,2start,2end}
35+
36+

win32/ctags_vs2013.vcxproj

+1
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
<ClCompile Include="..\optlib\puppetManifest.c" />
157157
<ClCompile Include="..\optlib\qemuhx.c" />
158158
<ClCompile Include="..\optlib\systemtap.c" />
159+
<ClCompile Include="..\optlib\vue.c" />
159160
<ClCompile Include="..\parsers\ada.c" />
160161
<ClCompile Include="..\parsers\ant.c" />
161162
<ClCompile Include="..\parsers\asciidoc.c" />

win32/ctags_vs2013.vcxproj.filters

+3
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@
222222
<ClCompile Include="..\optlib\systemtap.c">
223223
<Filter>Source Files\optlib</Filter>
224224
</ClCompile>
225+
<ClCompile Include="..\optlib\vue.c">
226+
<Filter>Source Files\optlib</Filter>
227+
</ClCompile>
225228
<ClCompile Include="..\parsers\ada.c">
226229
<Filter>Source Files\Parsers</Filter>
227230
</ClCompile>

0 commit comments

Comments
 (0)