In C, strings do not magically expand like they do in other languages. (Or, better said, there really is no string object.) You cannot call strcat(a, b) unless you have already ensured that the char array a has enough space following the NUL terminator to append b. You can't strcat to a string literal, because not only is there not enough space, but also the string literal may be in read-only memory.
![Lex And Yacc Program For Infix To Prefix Lex And Yacc Program For Infix To Prefix](/uploads/1/2/5/6/125639149/327677197.jpg)
And you can't strcpy to an unassigned variable and expect sufficient memory to be allocated automatically. (Although $$ is not actually an uninitialised variable, since it is initialised to the value of $1.) So your code is full of buffer overruns, which is undefined behaviour.
Yacc is a LALR(1) parser generator. LALR refers to a class of grammars. A grammar is a math tool to reason about parsing. Here are my lex and yacc file to recognise palindrome strings but it is giving 'INVALID 'for both valid as well as invalid string. Please help me to find the problem, I am new to lex. Output: nn@linuxmint ~ $ lex ip.l nn@linuxmint ~ $ yacc ip.y nn@linuxmint ~ $ gcc y.tab.c -ll -ly nn@linuxmint ~ $./a.out Enter infix expression: (3+5)*(6-2) 35+62-* nn@linuxmint ~ $. Labels: Compiler Design, Compiler Lab, Infix to Postfix Expression, Parser, Semester 6, YACC.