Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -54,5 +54,6 @@ x UCTAGSxpath no NONE s-- no -- xpath for
- UCTAGSparameter no SystemVerilog --b no -- parameter whose value can be overridden.
- UCTAGStarget yes Thrift s-- no -- the target language specified at "namespace"
- UCTAGSthrows yes Thrift s-- no -- throws list of function
- UCTAGSproperties no TypeScript s-- no -- properties (static)
- UCTAGSarchitecture yes VHDL s-- no -- architecture designing the entity
- UCTAGSparameter no Verilog --b no -- parameter whose value can be overridden.
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 @@ -72,6 +72,7 @@ z kind no NONE s-- no r- [tags output] prepend "kind:" to k/ (or K/) field outpu
- parameter no SystemVerilog --b no -- parameter whose value can be overridden.
- target yes Thrift s-- no -- the target language specified at "namespace"
- throws yes Thrift s-- no -- throws list of function
- properties no TypeScript s-- no -- properties (static)
- architecture yes VHDL s-- no -- architecture designing the entity
- parameter no Verilog --b no -- parameter whose value can be overridden.
#
Expand Down
1 change: 1 addition & 0 deletions Units/parser-typescript.r/ts-class.d/args.ctags
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
--sort=no
--kinds-typescript=*
--fields=+i
--fields-typescript=+{properties}
6 changes: 3 additions & 3 deletions Units/parser-typescript.r/ts-class.d/expected.tags
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ temp input.ts /^ var temp = this.next;$/;" l method:List.insertAfter
log input.ts /^ log() {$/;" m class:List
C input.ts /^class C {$/;" c
x input.ts /^ x: number;$/;" p class:C
x input.ts /^ static x: string;$/;" p class:C
x input.ts /^ static x: string;$/;" p class:C properties:static
Messenger input.ts /^class Messenger {$/;" c
message input.ts /^ message = "Hello World";$/;" p class:Messenger
start input.ts /^ start() {$/;" m class:Messenger
Expand All @@ -38,12 +38,12 @@ constructor input.ts /^ constructor(public x: number, public y: number) { }$/;"
x input.ts /^ constructor(public x: number, public y: number) { }$/;" p class:Point
y input.ts /^ constructor(public x: number, public y: number) { }$/;" p class:Point
length input.ts /^ public length() { return Math.sqrt(this.x * this.x + this.y * this.y); }$/;" m class:Point
origin input.ts /^ static origin = new Point(0, 0);$/;" p class:Point
origin input.ts /^ static origin = new Point(0, 0);$/;" p class:Point properties:static
A input.ts /^class A {$/;" c
x input.ts /^ private x: number;$/;" p class:A
y input.ts /^ protected y: number;$/;" p class:A
fun input.ts /^ public fun: (a: 22 | 30, b: CPoint) => number | string;$/;" p class:A
f input.ts /^ static f(a: A, b: B) {$/;" m class:A
f input.ts /^ static f(a: A, b: B) {$/;" m class:A properties:static
a input.ts /^ static f(a: A, b: B) {$/;" z method:A.f
b input.ts /^ static f(a: A, b: B) {$/;" z method:A.f
getXAsT input.ts /^ getXAsT<T = any>(): T {$/;" m class:A
Expand Down
4 changes: 2 additions & 2 deletions parsers/jscript.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ typedef struct sTokenInfo {
} tokenInfo;

typedef enum {
F_STATIC,
F_PROPERTIES,
} jsField;

/*
Expand Down Expand Up @@ -543,7 +543,7 @@ static int makeJsTagCommon (const tokenInfo *const token, const jsKind kind,
e.extensionFields.access = "private";

if (is_static)
attachParserField (&e, JsFields[F_STATIC].ftype, "static");
attachParserField (&e, JsFields[F_PROPERTIES].ftype, "static");

#ifdef DO_TRACING
{
Expand Down
42 changes: 42 additions & 0 deletions parsers/typescript.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ typedef enum {
TSTAG_ALIAS
} tsKind;

typedef enum {
F_PROPERTIES,
} tsField;

typedef struct sTokenInfo {
tokenType type;
keywordId keyword;
Expand All @@ -175,6 +179,7 @@ typedef struct sTokenInfo {
unsigned long lineNumber;
MIOPos filePosition;
keywordId accessKeyword;
bool isStatic;
} tokenInfo;

typedef struct sCommentState {
Expand All @@ -189,6 +194,14 @@ typedef struct sBlockState {
int curlyLevel;
} blockState;

static fieldDefinition TsFields[] = {
{
.name = "properties",
.description = "properties (static)",
.enabled = false,
},
};

static const keywordTable TsKeywordTable [] = {
/* keyword keyword ID */
{ "as" , KEYWORD_as },
Expand Down Expand Up @@ -294,6 +307,9 @@ static int emitTag(const tokenInfo *const token, const tsKind kind)
break;
}

if (token->isStatic)
attachParserField (&e, TsFields[F_PROPERTIES].ftype, "static");

return makeTagEntry (&e);
}

Expand All @@ -318,6 +334,7 @@ static void clearPoolToken (void *data)
token->scope = CORK_NIL;

token->accessKeyword = KEYWORD_NONE;
token->isStatic = false;

token->string = vStringNewOrClear (token->string);
}
Expand Down Expand Up @@ -822,6 +839,7 @@ static void parseInterfaceBody (const int scope, tokenInfo *const token)
tokenInfo *member = NULL;
bool parsingType = false;
int visibility = 0;
bool isStatic = false;

do
{
Expand Down Expand Up @@ -871,6 +889,9 @@ static void parseInterfaceBody (const int scope, tokenInfo *const token)
case KEYWORD_typeof:
parsingType = true;
break;
case KEYWORD_static:
isStatic = true;
break;
}
break;
case TOKEN_COLON:
Expand All @@ -894,6 +915,7 @@ static void parseInterfaceBody (const int scope, tokenInfo *const token)
member = newToken ();
copyToken (member, token, false);
member->scope = scope;
member->isStatic = isStatic;
if (visibility) member->accessKeyword = visibility;
else member->accessKeyword = KEYWORD_public;
}
Expand Down Expand Up @@ -1687,6 +1709,7 @@ static void parseClassBody (const int scope, tokenInfo *const token)
bool isGenerator = false;
bool parsingValue = false;
int visibility = 0;
bool isStatic = false;

do
{
Expand Down Expand Up @@ -1763,6 +1786,16 @@ static void parseClassBody (const int scope, tokenInfo *const token)
visibility = token->keyword;
parsingValue = false;
break;
case KEYWORD_static:
if (member)
{
emitTag (member, TSTAG_PROPERTY);
deleteToken (member);
member = NULL;
}
isStatic = true;
parsingValue = false;
break;
case KEYWORD_new:
case KEYWORD_typeof:
parsingValue = true;
Expand Down Expand Up @@ -1791,6 +1824,7 @@ static void parseClassBody (const int scope, tokenInfo *const token)
member = NULL;
isGenerator = false;
visibility = 0;
isStatic = false;
}
parsingValue = false;
break;
Expand Down Expand Up @@ -1831,6 +1865,7 @@ static void parseClassBody (const int scope, tokenInfo *const token)

isGenerator = false;
visibility = 0;
isStatic = false;
parsingValue = false;
break;
case TOKEN_IDENTIFIER:
Expand All @@ -1839,6 +1874,7 @@ static void parseClassBody (const int scope, tokenInfo *const token)
member = newToken ();
copyToken (member, token, false);
member->scope = scope;
member->isStatic = isStatic;
if (visibility) member->accessKeyword = visibility;
else member->accessKeyword = KEYWORD_public;
}
Expand All @@ -1849,6 +1885,7 @@ static void parseClassBody (const int scope, tokenInfo *const token)
default:
isGenerator = false;
visibility = 0;
isStatic = false;
break;
}
}
Expand Down Expand Up @@ -2122,6 +2159,8 @@ extern parserDefinition *TypeScriptParser (void)
def->extensions = extensions;
def->kindTable = TsKinds;
def->kindCount = ARRAY_SIZE (TsKinds);
def->fieldTable = TsFields;
def->fieldCount = ARRAY_SIZE (TsFields);
def->parser = findTsTags;
def->initialize = initialize;
def->finalize = finalize;
Expand All @@ -2133,5 +2172,8 @@ extern parserDefinition *TypeScriptParser (void)
def->initStats = initStats;
def->printStats = printStats;

def->versionCurrent = 1;
def->versionAge = 1;

return def;
}
Loading