-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2094 from YorickPeterse/master
Added new parser for Inko
- Loading branch information
Showing
30 changed files
with
387 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--sort=no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--sort=no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--sort=no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
impl SomeObject { | ||
def foo {} | ||
} | ||
|
||
impl SomeTrait for SomeObject { | ||
def bar {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--sort=no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--sort=no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--sort=no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
object A {} | ||
object B {} | ||
|
||
object C { | ||
object D { | ||
object E {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--sort=no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
trait A {} | ||
trait B: SomeRequiredTrait {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
Oops, something went wrong.