Refactor tokenizer: remove colon, add colon as duration separator to note and create TokenType.TYPE
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
from smnp.token.tools import tokenizeChar
|
||||
from smnp.token.type import TokenType
|
||||
|
||||
def tokenizeColon(input, current, line):
|
||||
return tokenizeChar(TokenType.COLON, ':', input, current, line)
|
||||
@@ -25,7 +25,7 @@ def tokenizeNote(input, current, line):
|
||||
octave = input[current+consumedChars]
|
||||
consumedChars += 1
|
||||
|
||||
if current+consumedChars < len(input) and input[current+consumedChars] == '^':
|
||||
if current+consumedChars < len(input) and input[current+consumedChars] == ':':
|
||||
duration = ''
|
||||
consumedChars += 1
|
||||
while current+consumedChars < len(input) and re.match(r'\d', input[current+consumedChars]):
|
||||
|
||||
8
smnp/token/tokenizers/type.py
Normal file
8
smnp/token/tokenizers/type.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from smnp.token.tools import tokenizeKeywords
|
||||
from smnp.token.type import TokenType
|
||||
from smnp.type.model import Type
|
||||
|
||||
|
||||
def tokenizeType(input, current, line):
|
||||
types = [ type.name.lower() for type in Type ]
|
||||
return tokenizeKeywords(TokenType.TYPE, input, current, line, *types)
|
||||
Reference in New Issue
Block a user