Skip to content

Commit 11bb004

Browse files
committed
Replace string:Char with string
1 parent e2dd98e commit 11bb004

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

ballerina/modules/parser/char_reader.bal

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,33 @@
1616

1717
public class CharReader {
1818
private CharIterator iterator;
19-
private string:Char?[] buffer;
19+
private string?[] buffer;
2020

2121
public isolated function init(string document) {
2222
self.iterator = document.iterator();
2323
self.buffer = [];
2424
}
2525

26-
public isolated function peek(int into = 0) returns string:Char? {
26+
public isolated function peek(int into = 0) returns string? {
2727
if self.buffer.length() > into {
2828
return self.buffer[into];
2929
}
3030
int startIndex = self.buffer.length();
3131
foreach int i in startIndex ... into {
32-
string:Char? char = self.next();
32+
string? char = self.next();
3333
self.buffer.push(char);
3434
}
3535
return self.buffer[into];
3636
}
3737

38-
public isolated function read() returns string:Char? {
38+
public isolated function read() returns string? {
3939
if self.buffer.length() > 0 {
4040
return self.buffer.shift();
4141
}
4242
return self.next();
4343
}
4444

45-
isolated function next() returns string:Char? {
45+
isolated function next() returns string? {
4646
CharIteratorNode? next = self.iterator.next();
4747
if next == () {
4848
return;

ballerina/modules/parser/lexer.bal

+18-18
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class Lexer {
5050
}
5151

5252
isolated function readNextToken() returns Token|SyntaxError {
53-
string:Char? char = self.charReader.peek();
53+
string? char = self.charReader.peek();
5454
if char == () {
5555
return {
5656
kind: T_EOF,
@@ -72,14 +72,14 @@ public class Lexer {
7272
}
7373
}
7474

75-
isolated function readSeparatorToken(string:Char char) returns Token? {
75+
isolated function readSeparatorToken(string char) returns Token? {
7676
Location location = self.currentLocation.clone();
7777
_ = self.readNextChar();
7878
TokenType kind = getTokenType(char);
7979
return getToken(char, kind, location);
8080
}
8181

82-
isolated function readSpecialCharacterToken(string:Char char) returns Token {
82+
isolated function readSpecialCharacterToken(string char) returns Token {
8383
Location location = self.currentLocation.clone();
8484
_ = self.readNextChar();
8585
TokenType kind = getTokenType(char);
@@ -99,9 +99,9 @@ public class Lexer {
9999
Location location = self.currentLocation.clone();
100100
_ = self.readNextChar(); // Consume first double quote character
101101

102-
string:Char? char = self.charReader.peek();
102+
string? char = self.charReader.peek();
103103
boolean isEscaped = false;
104-
while char is string:Char {
104+
while char is string {
105105
if char is LineTerminator {
106106
break;
107107
} else if char == DOUBLE_QUOTE && !isEscaped {
@@ -127,7 +127,7 @@ public class Lexer {
127127
string line = "";
128128
self.consumeIgnoreChars(3); // Consume first three double quote characters
129129

130-
string:Char? currentChar = self.charReader.peek();
130+
string? currentChar = self.charReader.peek();
131131
boolean isEscaped = false;
132132

133133
while currentChar != () {
@@ -209,11 +209,11 @@ public class Lexer {
209209
return i;
210210
}
211211

212-
isolated function readNumericLiteral(string:Char firstChar) returns Token|SyntaxError {
212+
isolated function readNumericLiteral(string firstChar) returns Token|SyntaxError {
213213
Location location = self.currentLocation.clone();
214214
string numeral = firstChar; // Passing first char to handle negative numbers.
215215
_ = self.readNextChar(); // Consume first char
216-
string:Char? character = self.charReader.peek();
216+
string? character = self.charReader.peek();
217217
while character != () {
218218
if character is Digit {
219219
numeral += character;
@@ -233,15 +233,15 @@ public class Lexer {
233233
return getToken(number, T_INT, location);
234234
}
235235

236-
isolated function readFloatLiteral(string initialNumber, string:Char separator, Location location)
236+
isolated function readFloatLiteral(string initialNumber, string separator, Location location)
237237
returns Token|SyntaxError {
238238
_ = self.readNextChar(); // Consume the separator character
239239
boolean isExpExpected = separator == DOT;
240240
boolean isDashExpected = !isExpExpected;
241241
boolean isDigitExpected = true;
242242

243243
string numeral = initialNumber + separator;
244-
string:Char? value = self.charReader.peek();
244+
string? value = self.charReader.peek();
245245
while value != () {
246246
if value is Digit {
247247
numeral += value;
@@ -272,7 +272,7 @@ public class Lexer {
272272
isolated function readCommentToken() returns Token|SyntaxError {
273273
Location location = self.currentLocation.clone();
274274
_ = self.readNextChar(); // Ignore first hash character
275-
string:Char? character = self.charReader.peek();
275+
string? character = self.charReader.peek();
276276
string word = "#";
277277
while character != () {
278278
if character is LineTerminator {
@@ -292,7 +292,7 @@ public class Lexer {
292292
int i = 0;
293293
while i < 3 {
294294
i += 1;
295-
string:Char? c = self.readNextChar();
295+
string? c = self.readNextChar();
296296
if c is DOT {
297297
ellipsis += c;
298298
continue;
@@ -309,12 +309,12 @@ public class Lexer {
309309
return getToken(ELLIPSIS, T_ELLIPSIS, location);
310310
}
311311

312-
isolated function readIdentifierToken(string:Char firstChar) returns Token|SyntaxError {
312+
isolated function readIdentifierToken(string firstChar) returns Token|SyntaxError {
313313
Location location = self.currentLocation.clone();
314314
_ = self.readNextChar();
315315
check validateFirstChar(firstChar, self.currentLocation);
316316
string word = firstChar;
317-
string:Char? char = self.charReader.peek();
317+
string? char = self.charReader.peek();
318318
while char != () {
319319
if char is SpecialCharacter {
320320
break;
@@ -345,7 +345,7 @@ public class Lexer {
345345
};
346346
}
347347

348-
isolated function updateLocation(string:Char? char) {
348+
isolated function updateLocation(string? char) {
349349
if char is LineTerminator {
350350
self.currentLocation.line += 1;
351351
self.currentLocation.column = 1;
@@ -354,14 +354,14 @@ public class Lexer {
354354
}
355355
}
356356

357-
isolated function readNextChar() returns string:Char? {
358-
string:Char? char = self.charReader.read();
357+
isolated function readNextChar() returns string? {
358+
string? char = self.charReader.read();
359359
self.updateLocation(char);
360360
return char;
361361
}
362362
}
363363

364-
isolated function getTokenType(string:Char? value) returns TokenType {
364+
isolated function getTokenType(string? value) returns TokenType {
365365
match value {
366366
() => {
367367
return T_EOF;

ballerina/modules/parser/tests/char_reader_tests.bal

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import ballerina/test;
2222
isolated function testCharReaderForSimpleString() {
2323
string s = "Hello";
2424
CharReader reader = new (s);
25-
string:Char? c = reader.read();
25+
string? c = reader.read();
2626
string expectedChar = "H";
2727
test:assertEquals(c, expectedChar);
2828

@@ -52,7 +52,7 @@ isolated function testCharReaderForSimpleString() {
5252
isolated function testCharReaderForEof() {
5353
string s = "";
5454
CharReader reader = new (s);
55-
string:Char? c = reader.read();
55+
string? c = reader.read();
5656
test:assertEquals(c, ());
5757
}
5858

@@ -62,7 +62,7 @@ isolated function testCharReaderForEof() {
6262
isolated function testCharReaderForNewLine() {
6363
string s = "\n\n\n";
6464
CharReader reader = new (s);
65-
string:Char? c = reader.read();
65+
string? c = reader.read();
6666
c = reader.read();
6767
string expectedChar = "\n";
6868
test:assertEquals(c, expectedChar);

ballerina/modules/parser/types.bal

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
public type Scalar int|float|decimal|string|boolean;
1818

1919
type CharIteratorNode record {
20-
string:Char value;
20+
string value;
2121
};
2222

2323
type CharIterator object {

0 commit comments

Comments
 (0)