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

Brain**** bracket matching could be better #625

Closed
int-y1 opened this issue Feb 16, 2020 · 0 comments
Closed

Brain**** bracket matching could be better #625

int-y1 opened this issue Feb 16, 2020 · 0 comments

Comments

@int-y1
Copy link
Contributor

int-y1 commented Feb 16, 2020

The current bracket matching code only counts the number of [ and ]. An invalid BF submission can pass this check, but it will receive a weird compile error message.

For example, this BF submission: ++++++]-----[++++
will receive this compile error:

tletestc.c:23:36: error: expected identifier or ‘(’ before ‘--’ token
     ++*p;++*p;++*p;++*p;++*p;++*p;}--*p;--*p;--*p;--*p;--*p;while(*p){++*p;++*p;++*p;++*p;
                                    ^~
tletestc.c:23:41: error: expected identifier or ‘(’ before ‘--’ token
     ++*p;++*p;++*p;++*p;++*p;++*p;}--*p;--*p;--*p;--*p;--*p;while(*p){++*p;++*p;++*p;++*p;
                                         ^~
tletestc.c:23:46: error: expected identifier or ‘(’ before ‘--’ token
     ++*p;++*p;++*p;++*p;++*p;++*p;}--*p;--*p;--*p;--*p;--*p;while(*p){++*p;++*p;++*p;++*p;
                                              ^~
tletestc.c:23:51: error: expected identifier or ‘(’ before ‘--’ token
     ++*p;++*p;++*p;++*p;++*p;++*p;}--*p;--*p;--*p;--*p;--*p;while(*p){++*p;++*p;++*p;++*p;
                                                   ^~
tletestc.c:23:56: error: expected identifier or ‘(’ before ‘--’ token
     ++*p;++*p;++*p;++*p;++*p;++*p;}--*p;--*p;--*p;--*p;--*p;while(*p){++*p;++*p;++*p;++*p;
                                                        ^~
tletestc.c:23:61: error: expected identifier or ‘(’ before ‘while’
     ++*p;++*p;++*p;++*p;++*p;++*p;}--*p;--*p;--*p;--*p;--*p;while(*p){++*p;++*p;++*p;++*p;
                                                             ^~~~~

The expected error message is: Unmatched brackets

Carson-Tang added a commit to Carson-Tang/judge that referenced this issue Mar 1, 2020
Carson-Tang added a commit to Carson-Tang/judge that referenced this issue Mar 1, 2020
@Xyene Xyene closed this as completed in fb89bd7 Mar 2, 2020
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