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

Why is my string being split into individual characters? #59

Closed
1Blademaster opened this issue Aug 19, 2020 · 0 comments
Closed

Why is my string being split into individual characters? #59

1Blademaster opened this issue Aug 19, 2020 · 0 comments

Comments

@1Blademaster
Copy link

1Blademaster commented Aug 19, 2020

So I have this regex expression STRING = r'[^\[\][^\n"]+' to get capture text to save into a variable, but I also have another part of my program which uses literals of ( and ) to do math, such as 5 add ( 5 minus 2 ) = 8. However my issue is that when I run my test and I actually type in the same thing into the interpreter, it causes an error and I'm not sure why? It should show that instead of ( 5 add 5 ) is a STRING, it will be made up of a ( NUMBER ADD NUMBER ), but individual tokens.

WARNING: 5 reduce/reduce conflicts
Token(type='DQUOTE', value='"', lineno=2, index=5)
Token(type='STRING', value='hello', lineno=2, index=6)
Token(type='DQUOTE', value='"', lineno=2, index=11)
Token(type='STRING', value='( 5 add 5 )', lineno=3, index=17)
engpy > (5 add 5)
sly: Syntax error at line 1, token=STRING
engpy > ( 5 add 5 )
sly: Syntax error at line 1, token=STRING
test = '''
    "hello"
    ( 5 add 5 )'''

for t in lexer.tokenize(test):
    print(t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant