Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert methods to properties #266

Merged
merged 55 commits into from
Jan 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
f1b09ef
Convert IntStream.index to a property
sharwell Jan 4, 2017
469a4e3
Convert all size() methods to properties
sharwell Jan 4, 2017
3aecb11
Convert getSourceName() methods to properties
sharwell Jan 4, 2017
68b972d
Convert getTokenSource() methods to properties
sharwell Jan 4, 2017
e1fcadd
Convert TokenStream.getTextFromInterval to an overload of getText
sharwell Jan 4, 2017
fe7e9b9
Convert TokenStream.getTextFromContext to an overload of getText
sharwell Jan 4, 2017
229e683
Convert TokenSource.getTokenFactory and setTokenFactory to a property
sharwell Jan 4, 2017
4e8436e
Convert getInputStream/setInputStream to properties
sharwell Jan 4, 2017
a8280a5
Convert getCharPositionInLine/setCharPositionInLine to properties
sharwell Jan 4, 2017
a076cd2
Use === instead of ==
sharwell Jan 4, 2017
1b22a70
Convert getLine/setLine to properties
sharwell Jan 4, 2017
33bb167
Convert getChannel/setChannel to properties
sharwell Jan 4, 2017
0d57251
Convert getStopIndex/setStopIndex to properties
sharwell Jan 4, 2017
7ad6785
Convert getStartIndex/setStartIndex to properties
sharwell Jan 4, 2017
eae5ba8
Convert getTokenIndex/setTokenIndex to properties
sharwell Jan 4, 2017
158228b
Convert getType/setType to properties
sharwell Jan 4, 2017
179f175
Use !== instead of !=
sharwell Jan 4, 2017
a9a6be4
Convert getText/setText to properties
sharwell Jan 4, 2017
e2b955f
Convert getAltNumber/setAltNumber to properties
sharwell Jan 4, 2017
73ed595
Convert Tree.getPayload to a property
sharwell Jan 4, 2017
35d20bb
Convert Tree.getParent to a property
sharwell Jan 4, 2017
54d7293
Convert Tree.getChildCount to a property
sharwell Jan 4, 2017
28a7848
Convert SyntaxTree.getSourceInterval to a property
sharwell Jan 4, 2017
d31fc44
Convert RuleNode.getRuleContext to a property
sharwell Jan 4, 2017
c56687d
Convert ParseTreeMatch methods to properties
sharwell Jan 4, 2017
ca22e79
Convert ParseTreePattern methods to properties
sharwell Jan 4, 2017
9b405a6
Convert getLexer and getParser to properties
sharwell Jan 5, 2017
254ef20
Convert RuleTagToken methods to properties
sharwell Jan 5, 2017
704425e
Convert TagChunk methods to properties
sharwell Jan 5, 2017
420559b
Convert TokenTagToken methods to properties
sharwell Jan 5, 2017
95d325d
Convert TerminalNode.getSymbol to a property
sharwell Jan 5, 2017
5b81b1a
Convert Interval.length to a property
sharwell Jan 5, 2017
fde2896
Convert IntervalSet methods to properties
sharwell Jan 5, 2017
ccbd388
Convert AcceptStateInfo methods to properties
sharwell Jan 5, 2017
0dd6638
Convert DFA methods to properties
sharwell Jan 5, 2017
2842e52
Convert DFAState methods to properties
sharwell Jan 5, 2017
1d79aab
Convert Transition methods to properties
sharwell Jan 5, 2017
dc8e74e
Convert Transition-derived methods to properties
sharwell Jan 5, 2017
76c5abd
Convert LexerAction and derived methods to properties
sharwell Jan 5, 2017
19e9e26
Convert ATNState and derived methods to properties
sharwell Jan 5, 2017
fe02b0f
Convert RecognitionException and derived methods to properties
sharwell Jan 5, 2017
8902b08
Convert ATNConfig and derived methods to properties
sharwell Jan 5, 2017
1ed5ec0
Convert AmbiguityInfo methods to properties
sharwell Jan 5, 2017
47dbe86
Convert ATN methods to properties
sharwell Jan 5, 2017
c3a0eb3
Convert isEmpty methods to properties
sharwell Jan 5, 2017
c6ede0d
Convert PredictionContext methods to properties
sharwell Jan 5, 2017
fb01b59
Convert ATNConfigSet methods to properties
sharwell Jan 5, 2017
51932b6
Convert ATNDeserializationOptions methods to properties
sharwell Jan 5, 2017
6d6b440
Convert ConflictInfo methods to properties
sharwell Jan 5, 2017
555164d
Convert PredictionContextCache methods to properties
sharwell Jan 5, 2017
17f7538
Convert SemanticContext methods to properties
sharwell Jan 5, 2017
905b9da
Convert RuleContext.getRuleIndex to a property
sharwell Jan 5, 2017
a13e3fa
Convert Lexer methods to properties
sharwell Jan 5, 2017
390b6b6
Convert Recognizer methods to properties
sharwell Jan 5, 2017
46b3c78
Convert Parser methods to properties
sharwell Jan 5, 2017
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
16 changes: 8 additions & 8 deletions benchmark/Java.g4
Original file line number Diff line number Diff line change
Expand Up @@ -775,16 +775,16 @@ shiftExpression

shiftOp
: t1='<' t2='<'
// { $t1.getLine() == $t2.getLine() &&
// $t1.getCharPositionInLine() + 1 == $t2.getCharPositionInLine() }?
// { $t1.line == $t2.line &&
// $t1.charPositionInLine + 1 == $t2.charPositionInLine }?
| t1='>' t2='>' t3='>'
// { $t1.getLine() == $t2.getLine() &&
// $t1.getCharPositionInLine() + 1 == $t2.getCharPositionInLine() &&
// $t2.getLine() == $t3.getLine() &&
// $t2.getCharPositionInLine() + 1 == $t3.getCharPositionInLine() }?
// { $t1.line == $t2.line &&
// $t1.charPositionInLine + 1 == $t2.charPositionInLine &&
// $t2.line == $t3.line &&
// $t2.charPositionInLine + 1 == $t3.charPositionInLine }?
| t1='>' t2='>'
// { $t1.getLine() == $t2.getLine() &&
// $t1.getCharPositionInLine() + 1 == $t2.getCharPositionInLine() }?
// { $t1.line == $t2.line &&
// $t1.charPositionInLine + 1 == $t2.charPositionInLine }?
;


Expand Down
46 changes: 23 additions & 23 deletions benchmark/JavaUnicodeInputStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ export class JavaUnicodeInputStream implements CharStream {
}

@Override
size(): number {
return this.source.size();
get size(): number {
return this.source.size;
}

@Override
index(): number {
return this.source.index();
get index(): number {
return this.source.index;
}

@Override
getSourceName(): string {
return this.source.getSourceName();
get sourceName(): string {
return this.source.sourceName;
}

@Override
Expand All @@ -73,15 +73,15 @@ export class JavaUnicodeInputStream implements CharStream {
if (this.la1 !== BACKSLASH) {
this.source.consume();
this.la1 = this.source.LA(1);
this.range = Math.max(this.range, this.source.index());
this.range = Math.max(this.range, this.source.index);
this.slashCount = 0;
return;
}

// make sure the next character has been processed
this.LA(1);

if (this.escapeListIndex >= this.escapeIndexes.size() || this.escapeIndexes.get(this.escapeListIndex) !== this.index()) {
if (this.escapeListIndex >= this.escapeIndexes.size || this.escapeIndexes.get(this.escapeListIndex) !== this.index) {
this.source.consume();
this.slashCount++;
}
Expand All @@ -96,7 +96,7 @@ export class JavaUnicodeInputStream implements CharStream {
}

this.la1 = this.source.LA(1);
assert(this.range >= this.index());
assert(this.range >= this.index);
}

@Override
Expand All @@ -106,7 +106,7 @@ export class JavaUnicodeInputStream implements CharStream {
}

if (i <= 0) {
let desiredIndex: number = this.index() + i;
let desiredIndex: number = this.index + i;
for (let j = this.escapeListIndex - 1; j >= 0; j--) {
if (this.escapeIndexes.get(j) + 6 + this.escapeIndirectionLevels.get(j) > desiredIndex) {
desiredIndex -= 5 + this.escapeIndirectionLevels.get(j);
Expand All @@ -117,23 +117,23 @@ export class JavaUnicodeInputStream implements CharStream {
}
}

return this.source.LA(desiredIndex - this.index());
return this.source.LA(desiredIndex - this.index);
}
else {
let desiredIndex: number = this.index() + i - 1;
for (let j = this.escapeListIndex; j < this.escapeIndexes.size(); j++) {
let desiredIndex: number = this.index + i - 1;
for (let j = this.escapeListIndex; j < this.escapeIndexes.size; j++) {
if (this.escapeIndexes.get(j) === desiredIndex) {
return this.escapeCharacters.get(j);
}
else if (this.escapeIndexes.get(j) < desiredIndex) {
desiredIndex += 5 + this.escapeIndirectionLevels.get(j);
}
else {
return this.source.LA(desiredIndex - this.index() + 1);
return this.source.LA(desiredIndex - this.index + 1);
}
}

let currentIndex: number[] = [this.index()];
let currentIndex: number[] = [this.index];
let slashCountPtr: number[] = [this.slashCount];
let indirectionLevelPtr: number[] = [0];
for (let j = 0; j < i; j++) {
Expand Down Expand Up @@ -182,7 +182,7 @@ export class JavaUnicodeInputStream implements CharStream {
this.slashCount++;
}

this.escapeListIndex = this.escapeIndexes.binarySearch(this.source.index());
this.escapeListIndex = this.escapeIndexes.binarySearch(this.source.index);
if (this.escapeListIndex < 0) {
this.escapeListIndex = -this.escapeListIndex - 1;
}
Expand Down Expand Up @@ -217,23 +217,23 @@ export class JavaUnicodeInputStream implements CharStream {

let blockUnicodeEscape: boolean = (slashCountPtr[0] % 2) !== 0;

let c0: number = this.source.LA(nextIndexPtr[0] - this.index() + 1);
let c0: number = this.source.LA(nextIndexPtr[0] - this.index + 1);
if (c0 === BACKSLASH) {
slashCountPtr[0]++;

if (!blockUnicodeEscape) {
let c1: number = this.source.LA(nextIndexPtr[0] - this.index() + 2);
let c1: number = this.source.LA(nextIndexPtr[0] - this.index + 2);
if (c1 === LOWER_U) {
let c2: number = this.source.LA(nextIndexPtr[0] - this.index() + 3);
let c2: number = this.source.LA(nextIndexPtr[0] - this.index + 3);
indirectionLevelPtr[0] = 0;
while (c2 === LOWER_U) {
indirectionLevelPtr[0]++;
c2 = this.source.LA(nextIndexPtr[0] - this.index() + 3 + indirectionLevelPtr[0]);
c2 = this.source.LA(nextIndexPtr[0] - this.index + 3 + indirectionLevelPtr[0]);
}

let c3: number = this.source.LA(nextIndexPtr[0] - this.index() + 4 + indirectionLevelPtr[0]);
let c4: number = this.source.LA(nextIndexPtr[0] - this.index() + 5 + indirectionLevelPtr[0]);
let c5: number = this.source.LA(nextIndexPtr[0] - this.index() + 6 + indirectionLevelPtr[0]);
let c3: number = this.source.LA(nextIndexPtr[0] - this.index + 4 + indirectionLevelPtr[0]);
let c4: number = this.source.LA(nextIndexPtr[0] - this.index + 5 + indirectionLevelPtr[0]);
let c5: number = this.source.LA(nextIndexPtr[0] - this.index + 6 + indirectionLevelPtr[0]);
if (JavaUnicodeInputStream.isHexDigit(c2) && JavaUnicodeInputStream.isHexDigit(c3) && JavaUnicodeInputStream.isHexDigit(c4) && JavaUnicodeInputStream.isHexDigit(c5)) {
let value: number = JavaUnicodeInputStream.hexValue(c2);
value = (value << 4) + JavaUnicodeInputStream.hexValue(c3);
Expand Down
Loading