473,385 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

String literal

Hi!
during my search on tokens in ANSI C I have found following
specification for string literals based on regular expression in
site http://www.lysator.liu.se/c/ANSI-C-grammar-l.html :
L?\"(\\.|[^\\"])*\" which L stands for [a-zA-Z_] . can anyone explain
what does it mean ? I know regex but I can't understand this
specification. why L? . does it mean following input is correct:
s"\a" for string literals. or what's exactly (\\.|[^\\"]) means. and
so on...
Thanks!
Jan 20 '08 #1
2 2759
In article <58**********************************@d4g2000prg.g ooglegroups.com>,
h03Ein <ho************@gmail.comwrote:
during my search on tokens in ANSI C I have found following
specification for string literals based on regular expression in
site http://www.lysator.liu.se/c/ANSI-C-grammar-l.html :
L?\"(\\.|[^\\"])*\" which L stands for [a-zA-Z_] . can anyone explain
what does it mean ? I know regex but I can't understand this
specification. why L? . does it mean following input is correct:
s"\a" for string literals. or what's exactly (\\.|[^\\"]) means. and
so on...
Notice that the L is not {L} like on the line

{D}+{IS}? { count(); return(CONSTANT); }

The L on the line is therefore not the meta variable standing
for [a-zA-Z_] -- instead, in that location, it is a literal L. And the
? after the L indicates that the L is optional.

\\ is the way that a literal backslash is specified. The . after
that stands for any one character, so in a literal string, you can have
\ followed by any character (including a double-quote that would normally
end the string.)

[^\\"] means any character except a backslash or a double-quote
--
"Any sufficiently advanced bug is indistinguishable from a feature."
-- Rich Kulawiec
Jan 20 '08 #2
On Sun, 20 Jan 2008 09:12:37 -0800, h03Ein wrote:
Hi!
during my search on tokens in ANSI C I have found following
specification for string literals based on regular expression in site
http://www.lysator.liu.se/c/ANSI-C-grammar-l.html :
L?\"(\\.|[^\\"])*\" which L stands for [a-zA-Z_] .
No, that's not what L stands for. I'm not sure why you thought that, but
L just stands for the letter L.
can anyone explain
what does it mean ? I know regex but I can't understand this
specification. why L? . does it mean following input is correct: s"\a"
Since s is not L, no, it does not mean that is correct.
for string literals. or what's exactly (\\.|[^\\"]) means. and so on...
Thanks!
Try describing the syntax of string literals in words. For example, for
an integer literal, I might write "a zero optionally followed by other
octal digits, or a decimal non-zero digit optionally followed by other
decimal digits, or 0x followed by hexadecimal digits, in any case
optionally followed by a suffix which can be U, UL, ULL, L, or LL". (This
is incomplete and so does not match the actual definition.) When you have
done that, what do you get? Does it look a bit similar to the regex, or
do you get something completely different?
Jan 20 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Don Starr | last post by:
When applied to a string literal, is the sizeof operator supposed to return the size of the string (including nul), or the size of a pointer? For example, assuming a char is 1 byte and a char *...
17
by: Olivier Bellemare | last post by:
I've tried to make a function that returns the middle of a string. For example: strmid("this is a text",6,4); would return "is a". Here is my code: char *strmid(char *texte, int depart,...
7
by: al | last post by:
char s = "This string literal"; or char *s= "This string literal"; Both define a string literal. Both suppose to be read-only and not to be modified according to Standard. And both have...
4
by: songkv | last post by:
Hi, I am trying to reassign an array of char to a string literal by calling a function. In the function I use pointer-to-pointer since I want to reassign the "string array pointer" to the string...
8
by: junky_fellow | last post by:
what would be the output for the following piece of code ? if ( "hello" == "hello" ) printf("True\n"); else printf("False\n"); What is the reason for that ?
5
by: John Baro | last post by:
I have a richtextbox which I want the "literal" rtf of. richtextbox.rtf returns {\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033\\uc1 }\r\n\0 when i put this into a string I get...
20
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just...
10
by: william | last post by:
#include <stdio.h> int main() { char *str=NULL; char x="today is good!"; printf("%s", str); str=strtok(x," "); if (str=="today") //<==here is line that confuses me printf("they equals!\n");
5
by: polas | last post by:
Good morning, I have a quick question to clear up some confusion in my mind. I understand that using a string literal in a declaration such as char *p = "string literal" declares a pointer to...
4
by: zaimoni | last post by:
I've already calculated that the following are valid and should not error, as both just end up with the character literal 'A' being their control expression. The unspecified value of the char*...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.