'[^']*\'
I use this rule to make lex match strings, it works fine when the string length is less than 9000, so how do I get lex to match strings longer than 9,000
Whether I should change the rules? Or do I have to set something up? I wish someone could help me
You can change states from the predefined
INITIALstate to some other state,SQSTR, when you encounter'. Within theSQSTRstate, you switch back toINITIALwhen you encounter an unescaped'. Otherwise, you stay inSQSTRand append characters to the token. How you optimally manage errors and string growth wrt memory allocation is an exercise left to the reader. Multi-line strings are also straightforward. And, of course, you should recognize an obvious refactoring opportunity which should be glaring red if you try to add multi-line string support.Edit #1 In the original post, I mistakenly placed the more general
.rule before the'rule. Silly me.Edit #2 Add main and debugging