Skip to content

Commit

Permalink
Merge pull request #2094 from YorickPeterse/master
Browse files Browse the repository at this point in the history
Added new parser for Inko
  • Loading branch information
masatake committed May 14, 2019
2 parents 91c73c5 + ccdaccd commit 4584fa7
Show file tree
Hide file tree
Showing 30 changed files with 387 additions and 1 deletion.
1 change: 1 addition & 0 deletions Tmain/list-fields-with-prefix.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ x UCTAGSxpath no NONE s-- no xpath for the
- UCTAGShowImported no Go s-- no how the package is imported ("inline" for `.' or "init" for `_')
- UCTAGSpackage yes Go s-- no the real package specified by the package name
- UCTAGSpackageName yes Go s-- no the name for referring the package
- UCTAGSimplements yes Inko s-- no Trait being implemented
- UCTAGSassignment yes LdScript s-- no how a value is assigned to the symbol
- UCTAGSsectionMarker no Markdown s-- no character used for declaring section(#, ##, =, or -)
- UCTAGScategory yes ObjectiveC s-- no category attached to the class
Expand Down
1 change: 1 addition & 0 deletions Tmain/list-fields.d/stdout-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ z kind no NONE s-- no Include the "kind:" key in kind field (use k or K) in tags
- howImported no Go s-- no how the package is imported ("inline" for `.' or "init" for `_')
- package yes Go s-- no the real package specified by the package name
- packageName yes Go s-- no the name for referring the package
- implements yes Inko s-- no Trait being implemented
- assignment yes LdScript s-- no how a value is assigned to the symbol
- sectionMarker no Markdown s-- no character used for declaring section(#, ##, =, or -)
- category yes ObjectiveC s-- no category attached to the class
Expand Down
1 change: 1 addition & 0 deletions Units/parser-inko.r/comments.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sort=no
1 change: 1 addition & 0 deletions Units/parser-inko.r/comments.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this_method_should_be_tagged input.inko /^def this_method_should_be_tagged {}$/;" m
3 changes: 3 additions & 0 deletions Units/parser-inko.r/comments.d/input.inko
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# def this_should_be_ignored {}

def this_method_should_be_tagged {}
1 change: 1 addition & 0 deletions Units/parser-inko.r/everything.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sort=no
18 changes: 18 additions & 0 deletions Units/parser-inko.r/everything.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
A input.inko /^object A$/;" o
in_a input.inko /^ def in_a {$/;" m object:A
another input.inko /^ def another {}$/;" m object:A
foo input.inko /^def foo {}$/;" m
B input.inko /^object B {$/;" o
in_b input.inko /^ def in_b {$/;" m object:B
C input.inko /^ object C {$/;" o object:B
nested_method input.inko /^ def nested_method {}$/;" m object:B.C
global input.inko /^def global {}$/;" m
SomeTrait input.inko /^trait SomeTrait {$/;" t
Socket input.inko /^object Socket impl Foo {$/;" o
quack input.inko /^ def quack {}$/;" m object:Socket
Socket input.inko /^impl Bar for Socket {$/;" r implements:Bar
moo input.inko /^ def moo !! Integer {}$/;" m reopen:Socket
Chickens input.inko /^impl Chickens {$/;" r
bok_bok input.inko /^ def bok_bok {}$/;" m reopen:Chickens
NUMBER input.inko /^let NUMBER = 10$/;" c
@number input.inko /^let @number = 20$/;" a
43 changes: 43 additions & 0 deletions Units/parser-inko.r/everything.d/input.inko
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{ 20 }

object A
{
def in_a {
{ 20 }
}

def another {}
}

def foo {}

object B {
def in_b {
{ 10 }
}

object C {
def nested_method {}
}
}

def global {}

trait SomeTrait {
# def this_should_be_ignored {}
}

object Socket impl Foo {
def quack {}
}

impl Bar for Socket {
def moo !! Integer {}
}

impl Chickens {
def bok_bok {}
}

let NUMBER = 10
let @number = 20
1 change: 1 addition & 0 deletions Units/parser-inko.r/implementations.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sort=no
4 changes: 4 additions & 0 deletions Units/parser-inko.r/implementations.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SomeObject input.inko /^impl SomeObject {$/;" r
foo input.inko /^ def foo {}$/;" m reopen:SomeObject
SomeObject input.inko /^impl SomeTrait for SomeObject {$/;" r implements:SomeTrait
bar input.inko /^ def bar {}$/;" m reopen:SomeObject
7 changes: 7 additions & 0 deletions Units/parser-inko.r/implementations.d/input.inko
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
impl SomeObject {
def foo {}
}

impl SomeTrait for SomeObject {
def bar {}
}
1 change: 1 addition & 0 deletions Units/parser-inko.r/let.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sort=no
4 changes: 4 additions & 0 deletions Units/parser-inko.r/let.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CONSTANT input.inko /^let CONSTANT = 10$/;" c
Person input.inko /^object Person {$/;" o
init input.inko /^ def init(name: String) {$/;" m object:Person
@name input.inko /^ let @name = name$/;" a method:Person.init
7 changes: 7 additions & 0 deletions Units/parser-inko.r/let.d/input.inko
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let CONSTANT = 10

object Person {
def init(name: String) {
let @name = name
}
}
1 change: 1 addition & 0 deletions Units/parser-inko.r/methods.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sort=no
8 changes: 8 additions & 0 deletions Units/parser-inko.r/methods.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
A input.inko /^object A {$/;" o
method_a input.inko /^ def method_a {}$/;" m object:A
B input.inko /^object B {$/;" o
method_b input.inko /^ def method_b {}$/;" m object:B
C input.inko /^object C {$/;" o
D input.inko /^ object D {$/;" o object:C
E input.inko /^ object E {$/;" o object:C.D
method_e input.inko /^ def method_e {}$/;" m object:C.D.E
15 changes: 15 additions & 0 deletions Units/parser-inko.r/methods.d/input.inko
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
object A {
def method_a {}
}

object B {
def method_b {}
}

object C {
object D {
object E {
def method_e {}
}
}
}
1 change: 1 addition & 0 deletions Units/parser-inko.r/objects.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sort=no
5 changes: 5 additions & 0 deletions Units/parser-inko.r/objects.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
A input.inko /^object A {}$/;" o
B input.inko /^object B {}$/;" o
C input.inko /^object C {$/;" o
D input.inko /^ object D {$/;" o object:C
E input.inko /^ object E {}$/;" o object:C.D
8 changes: 8 additions & 0 deletions Units/parser-inko.r/objects.d/input.inko
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
object A {}
object B {}

object C {
object D {
object E {}
}
}
1 change: 1 addition & 0 deletions Units/parser-inko.r/traits.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sort=no
2 changes: 2 additions & 0 deletions Units/parser-inko.r/traits.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
A input.inko /^trait A {}$/;" t
B input.inko /^trait B: SomeRequiredTrait {}$/;" t
2 changes: 2 additions & 0 deletions Units/parser-inko.r/traits.d/input.inko
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
trait A {}
trait B: SomeRequiredTrait {}
1 change: 1 addition & 0 deletions docs/news.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ The following parsers have been added:
* Gdbinit script *optlib*
* Glade *libxml*
* Go
* Inko *optlib*
* JavaProperties
* JSON
* GNU linker script(LdScript)
Expand Down
1 change: 1 addition & 0 deletions main/parsers_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
GoParser, \
HtmlParser, \
IniconfParser, \
InkoParser, \
ITclParser, \
JavaParser, \
JavaPropertiesParser, \
Expand Down
1 change: 1 addition & 0 deletions makefiles/optlib2c_input.mak
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ OPTLIB2C_INPUT = \
optlib/qemuhx.ctags \
optlib/puppetManifest.ctags \
optlib/systemtap.ctags \
optlib/inko.ctags \
\
$(NULL)
166 changes: 166 additions & 0 deletions optlib/inko.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
/*
* Generated by ./misc/optlib2c from optlib/inko.ctags, Don't edit this manually.
*/
#include "general.h"
#include "parse.h"
#include "routines.h"
#include "field.h"
#include "xtag.h"


static void initializeInkoParser (const langType language)
{

addLanguageRegexTable (language, "toplevel");
addLanguageRegexTable (language, "object");
addLanguageRegexTable (language, "trait");
addLanguageRegexTable (language, "method");
addLanguageRegexTable (language, "comment");
addLanguageRegexTable (language, "impl");
addLanguageRegexTable (language, "let");

addLanguageTagMultiTableRegex (language, "toplevel",
"^#",
"", "", "{tenter=comment}", NULL);
addLanguageTagMultiTableRegex (language, "toplevel",
"^[[:blank:]]*object[[:blank:]]+",
"", "", "{tenter=object}", NULL);
addLanguageTagMultiTableRegex (language, "toplevel",
"^[[:blank:]]*trait[[:blank:]]+",
"", "", "{tenter=trait}", NULL);
addLanguageTagMultiTableRegex (language, "toplevel",
"^[[:blank:]]*def[[:blank:]]+",
"", "", "{tenter=method}", NULL);
addLanguageTagMultiTableRegex (language, "toplevel",
"^[[:blank:]]*impl[[:blank:]]+",
"", "", "{tenter=impl}", NULL);
addLanguageTagMultiTableRegex (language, "toplevel",
"^[[:blank:]]*let[[:blank:]]+",
"", "", "{tenter=let}", NULL);
addLanguageTagMultiTableRegex (language, "toplevel",
"^\\{",
"", "", "{placeholder}{scope=push}", NULL);
addLanguageTagMultiTableRegex (language, "toplevel",
"^\\}",
"", "", "{scope=pop}", NULL);
addLanguageTagMultiTableRegex (language, "toplevel",
"^.",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "object",
"^([A-Z][a-zA-Z0-9_?]*)[^{]*",
"\\1", "o", "{scope=push}", NULL);
addLanguageTagMultiTableRegex (language, "object",
"^\\{",
"", "", "{tleave}", NULL);
addLanguageTagMultiTableRegex (language, "object",
"^.",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "trait",
"^([A-Z][a-zA-Z0-9_?]*)[^{]*",
"\\1", "t", "{scope=push}", NULL);
addLanguageTagMultiTableRegex (language, "trait",
"^\\{",
"", "", "{tleave}", NULL);
addLanguageTagMultiTableRegex (language, "trait",
"^.",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "method",
"^([a-zA-Z0-9_?]+)[^{]*",
"\\1", "m", "{scope=push}", NULL);
addLanguageTagMultiTableRegex (language, "method",
"^\\{",
"", "", "{tleave}", NULL);
addLanguageTagMultiTableRegex (language, "method",
"^.",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "comment",
"^\n",
"", "", "{tleave}", NULL);
addLanguageTagMultiTableRegex (language, "comment",
"^.",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "impl",
"^([A-Z][a-zA-Z0-9_?]*)[[:blank:]]+for[[:blank:]]+([A-Z][a-zA-Z0-9_?]*)[^{]*",
"\\2", "r", "{scope=push}{_field=implements:\\1}", NULL);
addLanguageTagMultiTableRegex (language, "impl",
"^([A-Z][a-zA-Z0-9_?]*)[^{]*",
"\\1", "r", "{scope=push}", NULL);
addLanguageTagMultiTableRegex (language, "impl",
"^\\{",
"", "", "{tleave}", NULL);
addLanguageTagMultiTableRegex (language, "impl",
"^.",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "let",
"^(@[a-zA-Z0-9_]+)",
"\\1", "a", "{scope=ref}", NULL);
addLanguageTagMultiTableRegex (language, "let",
"^([A-Z][a-zA-Z0-9_]+)",
"\\1", "c", "{scope=ref}", NULL);
addLanguageTagMultiTableRegex (language, "let",
"^=",
"", "", "{tleave}", NULL);
addLanguageTagMultiTableRegex (language, "let",
"^.",
"", "", "", NULL);
}

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

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

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

static kindDefinition InkoKindTable [] = {
{
true, 'o', "object", "Object definition",
},
{
true, 'm', "method", "Method definition",
},
{
true, 't', "trait", "Trait definition",
},
{
true, 'a', "attribute", "Attribute definition",
},
{
true, 'c', "constant", "Constant definition",
},
{
true, 'r', "reopen", "Reopen object",
},
};
static fieldDefinition InkoFieldTable [] = {
{
.enabled = true,
.name = "implements",
.description = "Trait being implemented",
},
};

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

def->enabled = true;
def->extensions = extensions;
def->patterns = patterns;
def->aliases = aliases;
def->method = METHOD_NOT_CRAFTED|METHOD_REGEX;
def->useCork = 1;
def->kindTable = InkoKindTable;
def->kindCount = ARRAY_SIZE(InkoKindTable);
def->fieldTable = InkoFieldTable;
def->fieldCount = ARRAY_SIZE(InkoFieldTable);
def->initialize = initializeInkoParser;

return def;
}

0 comments on commit 4584fa7

Please sign in to comment.