Skip to content

Commit

Permalink
[EXPERIMENTAL] Vue: new parser
Browse files Browse the repository at this point in the history
Continuation of universal-ctags#1581.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed Jun 23, 2019
1 parent ff21fed commit 4049e93
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Units/simple-vue.d/args.ctags
@@ -0,0 +1,3 @@
--sort=no
--extras=+g
--fields=+ln
5 changes: 5 additions & 0 deletions Units/simple-vue.d/expected.tags
@@ -0,0 +1,5 @@
slot input.vue /^ <p id="slot">{{ greeting }} World!<\/p>$/;" I line:4 language:HTML
makeWord input.vue /^function makeWord ()$/;" f line:8 language:JavaScript
data input.vue /^ data: function () {$/;" m line:14 language:JavaScript class:module.exports
exports input.vue /^module.exports = {$/;" c line:13 language:JavaScript class:module
p input.vue /^p {$/;" s line:23 language:CSS
27 changes: 27 additions & 0 deletions Units/simple-vue.d/input.vue
@@ -0,0 +1,27 @@
<!-- Taken from https://vuejs.org/v2/guide/single-file-components.html -->

<template>
<p id="slot">{{ greeting }} World!</p>
</template>

<script>
function makeWord ()
{
return 'Hello';
}
module.exports = {
data: function () {
return {
greeting: makeWord ()
}
}
}
</script>

<style scoped>
p {
font-size: 2em;
text-align: center;
}
</style>
1 change: 1 addition & 0 deletions docs/news.rst
Expand Up @@ -93,6 +93,7 @@ The following parsers have been added:
* TTCN
* TypeScript
* Varlink *peg/packcc*
* Vue *optlib*
* WindRes
* XSLT v1.0 *libxml*
* Yacc
Expand Down
1 change: 1 addition & 0 deletions main/parsers_p.h
Expand Up @@ -139,6 +139,7 @@
UCtagsAspellParser, \
VhdlParser, \
VimParser, \
VueParser, \
WindResParser, \
YaccParser, \
YumRepoParser, \
Expand Down
52 changes: 52 additions & 0 deletions optlib/vue.c
@@ -0,0 +1,52 @@
/*
* Generated by ./misc/optlib2c from optlib/vue.ctags, Don't edit this manually.
*/
#include "general.h"
#include "parse.h"
#include "routines.h"
#include "field.h"
#include "xtag.h"


static void initializeVueParser (const langType language CTAGS_ATTR_UNUSED)
{
}

extern parserDefinition* VueParser (void)
{
static const char *const extensions [] = {
"vue",
NULL
};

static const char *const aliases [] = {
NULL
};

static const char *const patterns [] = {
NULL
};

static tagRegexTable VueTagRegexTable [] = {
{"<template>\n((.|\n){1,}\n)</template>", "",
"", "{guest=HTML,1start,1end}", NULL, true},
{"<script>\n((.|\n){1,}\n)</script>", "",
"", "{guest=JavaScript,1start,1end}", NULL, true},
{"<style([ ]{1,}[a-z]{1,})*>\n((.|\n){1,}\n)</style>", "",
"", "{guest=CSS,2start,2end}", NULL, true},
};


parserDefinition* const def = parserNew ("Vue");

def->enabled = true;
def->extensions = extensions;
def->patterns = patterns;
def->aliases = aliases;
def->method = METHOD_NOT_CRAFTED|METHOD_REGEX;
def->tagRegexTable = VueTagRegexTable;
def->tagRegexCount = ARRAY_SIZE(VueTagRegexTable);
def->initialize = initializeVueParser;

return def;
}
36 changes: 36 additions & 0 deletions optlib/vue.ctags
@@ -0,0 +1,36 @@
#
# vue.ctags --- a parser for VueJS Single File Components
#
# Copyright (c) 2019, Red Hat, Inc.
# Copyright (c) 2019, Masatake YAMATO
#
# Author: Masatake YAMATO <yamato@redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
#
#
# References:
#
# - https://vuejs.org/v2/guide/single-file-components.html
#
--langdef=Vue
--map-Vue=+.vue

--mline-regex-Vue=/<template>\n((.|\n){1,}\n)<\/template>//{guest=HTML,1start,1end}
--mline-regex-Vue=/<script>\n((.|\n){1,}\n)<\/script>//{guest=JavaScript,1start,1end}
--mline-regex-Vue=/<style([ ]{1,}[a-z]{1,})*>\n((.|\n){1,}\n)<\/style>//{guest=CSS,2start,2end}


1 change: 1 addition & 0 deletions win32/ctags_vs2013.vcxproj
Expand Up @@ -156,6 +156,7 @@
<ClCompile Include="..\optlib\puppetManifest.c" />
<ClCompile Include="..\optlib\qemuhx.c" />
<ClCompile Include="..\optlib\systemtap.c" />
<ClCompile Include="..\optlib\vue.c" />
<ClCompile Include="..\parsers\ada.c" />
<ClCompile Include="..\parsers\ant.c" />
<ClCompile Include="..\parsers\asciidoc.c" />
Expand Down
3 changes: 3 additions & 0 deletions win32/ctags_vs2013.vcxproj.filters
Expand Up @@ -222,6 +222,9 @@
<ClCompile Include="..\optlib\systemtap.c">
<Filter>Source Files\optlib</Filter>
</ClCompile>
<ClCompile Include="..\optlib\vue.c">
<Filter>Source Files\optlib</Filter>
</ClCompile>
<ClCompile Include="..\parsers\ada.c">
<Filter>Source Files\Parsers</Filter>
</ClCompile>
Expand Down

0 comments on commit 4049e93

Please sign in to comment.