Skip to content

Commit dd8d414

Browse files
committed
Allowed underscore (_) to be used in identifiers.
1 parent e22cf84 commit dd8d414

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

Coco/Scanner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def scan2(self, buf: str) -> str:
185185

186186
def scan3(self, state: int, apx: int, buf: str) -> typing.Tuple[typing.Optional[int], ScannerEnum, int, str]:
187187
if state == 20:
188-
if "0" <= self.ch <= "9" or "A" <= self.ch <= "Z" or "a" <= self.ch <= "z":
188+
if "0" <= self.ch <= "9" or "A" <= self.ch <= "Z" or self.ch == "_" or "a" <= self.ch <= "z":
189189
buf += str(self.ch)
190190
self.NextCh()
191191
return 20, self.t.kind, apx, buf
@@ -199,7 +199,7 @@ def scan3(self, state: int, apx: int, buf: str) -> typing.Tuple[typing.Optional[
199199
return 21, self.t.kind, apx, buf
200200
return None, self.__class__.ENUM.number_Sym, apx, buf
201201
if state == 22:
202-
if "0" <= self.ch <= "9" or "A" <= self.ch <= "Z" or "a" <= self.ch <= "z":
202+
if "0" <= self.ch <= "9" or "A" <= self.ch <= "Z" or self.ch == "_" or "a" <= self.ch <= "z":
203203
buf += str(self.ch)
204204
self.NextCh()
205205
return 22, self.t.kind, apx, buf

sources/Coco.atg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ COMPILER Coco
4949
#-------------------------------------------------------------------------
5050

5151
CHARACTERS
52-
letter = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".
52+
letter = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_".
5353
digit = "0123456789".
5454
cr = '\r'.
5555
lf = '\n'.

0 commit comments

Comments
 (0)