-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
75 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
from app.token import IntWrapper, IntToken | ||
# from app.token import Token, IntWrapper, IntToken | ||
import app.token as token | ||
|
||
def token_factory(char: str) -> token.Token: | ||
if char.isdigit(): | ||
return token.IntToken(char) | ||
elif char == '+': | ||
return token.AddToken() | ||
elif char == '-': | ||
return token.SubtractToken() | ||
elif char == '*': | ||
return token.MultiplyToken() | ||
elif char == '/': | ||
return token.DivideToken() | ||
elif char == ' ': | ||
return token.SpaceToken() | ||
|
||
def int_wrapper_factory(int_str: str): | ||
int_tokens = [IntToken(char) for char in int_str] | ||
return IntWrapper(int_tokens) | ||
int_tokens = [token.IntToken(char) for char in int_str] | ||
return token.IntWrapper(int_tokens) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters