antlr / antlr/antlr3

ANTLR C target runs in infinite loop with wide strings (16bit characters)

Open
#104 0 comments 0 reactions 0 assignees View on GitHub
target:c
Dominant language
Java
Stars
253
Forks
178
PR merge metrics
No merged PRs in 30d

Description

I had troubles with wide character strings when I called `pANTLR3_INPUT_STREAM input = antlr3StringStreamNew((ANTLR3_UINT8*)stringAdress, ANTLR3_ENC_UTF16, stringSizeInBytes, (ANTLR3_UINT8*)"test");
`. I think I have found the issue in the file antlr3inputstream.c, in the function antlr3UTF16Seek(). The while condition seems broken, the "smaller than"-comparison should be "greater than", so that the full line reads:

`while (is->_LA(is, 1) != ANTLR3_CHARSTREAM_EOF && seekPoint > (ANTLR3_MARKER)input->nextChar)`

Can anybody confirm that and fix the code if necessary?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in antlr3inputstream.c at antlr3UTF16Seek() and inspect the while condition against the reported UTF-16 input call. Reproduce with the wide-string example and confirm that seeking terminates correctly; done when the C target no longer loops indefinitely for that input.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.