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

Inverse bracket expression is broken #7

Closed
nihei9 opened this issue Apr 17, 2022 · 1 comment
Closed

Inverse bracket expression is broken #7

nihei9 opened this issue Apr 17, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@nihei9
Copy link
Owner

nihei9 commented Apr 17, 2022

I made the following file:

{
	"name": "test",
	"entries": [
		{
			"kind": "not_paren",
			"pattern": "[^()]+"
		}
	]
}

Then I got the following result:

$ echo -n '()' | maleeni lex test.json
{"mode_id":1,"mode_name":"default","kind_id":0,"mode_kind_id":0,"kind_name":"","row":0,"col":0,"lexeme":"(","eof":false,"invalid":true}
{"mode_id":1,"mode_name":"default","kind_id":1,"mode_kind_id":1,"kind_name":"not_paren","row":0,"col":1,"lexeme":")","eof":false,"invalid":false}
{"mode_id":1,"mode_name":"default","kind_id":0,"mode_kind_id":0,"kind_name":"","row":0,"col":0,"lexeme":"","eof":true,"invalid":false}

Even though the inverse expression contains ), maleeni v0.6.0 recognizes ) as a valid token. The expectation is that ) will be a part of an invalid token.

@nihei9 nihei9 added the bug Something isn't working label Apr 17, 2022
@nihei9
Copy link
Owner Author

nihei9 commented Apr 17, 2022

Possibly this issue occurs when characters to be excluded are adjacent to each other.

Example of characters to be adjacent to each other

Lexical specification:

{
	"name": "test",
	"entries": [
		{
			"kind": "not_digit",
			"pattern": "[^0123456789]+"
		}
	]
}

Result:

$ echo -n '0123456789' | maleeni lex test.json
{"mode_id":1,"mode_name":"default","kind_id":0,"mode_kind_id":0,"kind_name":"","row":0,"col":0,"lexeme":"0","eof":false,"invalid":true}
{"mode_id":1,"mode_name":"default","kind_id":1,"mode_kind_id":1,"kind_name":"not_digit","row":0,"col":1,"lexeme":"1","eof":false,"invalid":false}
{"mode_id":1,"mode_name":"default","kind_id":0,"mode_kind_id":0,"kind_name":"","row":0,"col":2,"lexeme":"2","eof":false,"invalid":true}
{"mode_id":1,"mode_name":"default","kind_id":1,"mode_kind_id":1,"kind_name":"not_digit","row":0,"col":3,"lexeme":"3","eof":false,"invalid":false}
{"mode_id":1,"mode_name":"default","kind_id":0,"mode_kind_id":0,"kind_name":"","row":0,"col":4,"lexeme":"4","eof":false,"invalid":true}
{"mode_id":1,"mode_name":"default","kind_id":1,"mode_kind_id":1,"kind_name":"not_digit","row":0,"col":5,"lexeme":"5","eof":false,"invalid":false}
{"mode_id":1,"mode_name":"default","kind_id":0,"mode_kind_id":0,"kind_name":"","row":0,"col":6,"lexeme":"6","eof":false,"invalid":true}
{"mode_id":1,"mode_name":"default","kind_id":1,"mode_kind_id":1,"kind_name":"not_digit","row":0,"col":7,"lexeme":"7","eof":false,"invalid":false}
{"mode_id":1,"mode_name":"default","kind_id":0,"mode_kind_id":0,"kind_name":"","row":0,"col":8,"lexeme":"8","eof":false,"invalid":true}
{"mode_id":1,"mode_name":"default","kind_id":1,"mode_kind_id":1,"kind_name":"not_digit","row":0,"col":9,"lexeme":"9","eof":false,"invalid":false}
{"mode_id":1,"mode_name":"default","kind_id":0,"mode_kind_id":0,"kind_name":"","row":0,"col":0,"lexeme":"","eof":true,"invalid":false}

Example of characters not to be adjacent to each other

Lexical specification:

{
	"name": "test",
	"entries": [
		{
			"kind": "not_odd",
			"pattern": "[^13579]+"
		}
	]
}

Result:

$ echo -n '13579' | maleeni lex test.json
{"mode_id":1,"mode_name":"default","kind_id":0,"mode_kind_id":0,"kind_name":"","row":0,"col":0,"lexeme":"13579","eof":false,"invalid":true}
{"mode_id":1,"mode_name":"default","kind_id":0,"mode_kind_id":0,"kind_name":"","row":0,"col":0,"lexeme":"","eof":true,"invalid":false}
$ echo -n '02468' | maleeni lex test.json
{"mode_id":1,"mode_name":"default","kind_id":1,"mode_kind_id":1,"kind_name":"not_odd","row":0,"col":0,"lexeme":"02468","eof":false,"invalid":false}
{"mode_id":1,"mode_name":"default","kind_id":0,"mode_kind_id":0,"kind_name":"","row":0,"col":0,"lexeme":"","eof":true,"invalid":false}

@nihei9 nihei9 changed the title Inverse expression is broken Inverse bracket expression is broken Apr 19, 2022
@nihei9 nihei9 closed this as completed in bff52b5 Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant