So far I only see stuff like '<' ,but never see 'abc' nor "abc" in a yacc file.
a:
b '<' c;
Are the later two valid at all?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
‘abc’ = is valid character since whenever you specify char like this compiler/preprocessor
simply remove last character , sometimes you would get “character constants must be one or two character long” compile time error in ANSI C.If it is not given by your compiler then
it has removed last ‘c’ from ‘abc’ should be assumed.
so
char ch='abc' ; // is actually equi. to ch = 'ab'but while binding it will only use
ch='a',that’s why ‘abc’ is syntaxically correct but symantically wrong characher.(I wrote C coz. we use c89 tool i.e. POSIX C for compiling yacc and lex inputs)Again yylex() works on characters as basic functional unit and not string (anything inside double quotes). So “abc” is not valid character not even character to match with yylex()’s
input.
(yylex() accepts string of token
exam.
"10+20"having grammer
[[:DIGIT:]]+ [-+*/%] [[:DIGIT:]]+and having tokens
1,0,+,2,0The tokens lex can identify by default w/o specifying grammer are
10 as number
+ as char and
20 as number again
so it will match with grammer specified before )
you can also specify string in rules section for matching with , like
^["I am"]means match with any input line starting with “I am”"I am"match with only input having string as"I am"only , It wont match with"I am Swapnil @ vikas.ghode@gmail.com"