472,353 Members | 1,956 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

How C and C++ are context sensitive

Can someone explain to me hoe both C and C++ are context sensitive??

Jul 23 '05 #1
10 2256
chessc4c6 wrote:
Can someone explain to me hoe both C and C++ are context sensitive??


Could it be you're confusing that with "case-sensitive"?
Jul 23 '05 #2
Yes it could be, but I'm trying to explain how they are different in
that sense and do not know myself.

Jul 23 '05 #3

"chessc4c6" <pr***********@aol.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Can someone explain to me hoe both C and C++ are context sensitive??


Are you referring to the grammar(s)? I suspect there are several parts of
the grammar(s) that make it context sensitive, but I'd say off-hand that the
fact that one needs to know if a given token is a typename or not, while
parsing, is the main reason. Both languages have the typdef keyword which
introduces context sensitivity by defining a new typname. And C++ has a lot
of other constructs that I'd guess make it so, such as templates.

Search on groups.google.com, and you're sure to get a lot of hits.

-Howard
Jul 23 '05 #4
chessc4c6 wrote:
Yes it could be, but I'm trying to explain how they are different in
that sense and do not know myself.


In the sense of case sensitivity they are not different. Context
sensitivity WRT C or C++ is something I've never heard of. Sorry.

V
Jul 23 '05 #5
chessc4c6 wrote:
Can someone explain to me hoe both C and C++ are context sensitive??


As far as I know, no programming language available has a context
sensitive grammar. Context sensitivity is extremely hard to handle, and
more appropriate to spoken languages anyway.

--
Matthias Kaeppler
Jul 23 '05 #6
Matthias Kaeppler wrote:

chessc4c6 wrote:
Can someone explain to me hoe both C and C++ are context sensitive??


As far as I know, no programming language available has a context
sensitive grammar.


Just to clearify.
What is your understanding of 'context sensitive grammer'?

C++ has lots of things in the grammer, which are interpreted differently
depending on the context they appear in. The keyword 'static' comes to my
mind.

Or are you talking about something differently and I am barking up the
wrong tree?

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 23 '05 #7
Karl Heinz Buchegger wrote:
Matthias Kaeppler wrote:
chessc4c6 wrote:
Can someone explain to me hoe both C and C++ are context sensitive??


As far as I know, no programming language available has a context
sensitive grammar.

Just to clearify.
What is your understanding of 'context sensitive grammer'?

C++ has lots of things in the grammer, which are interpreted differently
depending on the context they appear in. The keyword 'static' comes to my
mind.

Or are you talking about something differently and I am barking up the
wrong tree?


Context sensitive grammar would allow productions like:

a N c ::= a b c

whereas the non-terminal N would be reduced to token b if and only if it
appears in the context of a and c.
At least from what I know, this is not what a compiler does when parsing
a programming language. Productions of common programming languages
never appear in a context, that means, they form context-free grammars.

--
Matthias Kaeppler
Jul 23 '05 #8
Matthias Kaeppler wrote:

Karl Heinz Buchegger wrote:
Matthias Kaeppler wrote:
chessc4c6 wrote:

Can someone explain to me hoe both C and C++ are context sensitive??
As far as I know, no programming language available has a context
sensitive grammar.

Just to clearify.
What is your understanding of 'context sensitive grammer'?

C++ has lots of things in the grammer, which are interpreted differently
depending on the context they appear in. The keyword 'static' comes to my
mind.

Or are you talking about something differently and I am barking up the
wrong tree?


Context sensitive grammar would allow productions like:

a N c ::= a b c

whereas the non-terminal N would be reduced to token b if and only if it
appears in the context of a and c.
At least from what I know, this is not what a compiler does when parsing
a programming language. Productions of common programming languages
never appear in a context, that means, they form context-free grammars.


Thanks for the clearification.
A long time has gone since my compiler construction lessons :-)

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 23 '05 #9
Victor Bazarov <v.********@comAcast.net> writes:
chessc4c6 wrote:
Yes it could be, but I'm trying to explain how they are different in
that sense and do not know myself.


In the sense of case sensitivity they are not different. Context
sensitivity WRT C or C++ is something I've never heard of. Sorry.


huh?

int count= 0;

void foo()
{
++count; //in this context, the global count is incremented.
}

void bar()
{
static int count= 0;
++count; //in this context, the static count local to the function
//bar is incremented.
}

namespace baz
{
int count= 0;
void qux()
{
++count; //in this context, the count inside of namespace baz is incremented.
}
}

Above, the expression '++count' appears 3 times, each time in a
different context. Each time, because of differing context, an
otherwise textually identical expression has different
behavior. (And in other contexts, 'count' could refer to a
template ...)

C++ is filled with context sensitivity. In fact, it has few features
which are not in someway context sensitive.

The real problem with the OP's question is the enourmous number of
ways in which both C and C++ are context sensitive.

Jul 23 '05 #10
gb
Llewelly wrote:
Victor Bazarov <v.********@comAcast.net> writes:

Above, the expression '++count' appears 3 times, each time in a
different context. Each time, because of differing context, an
otherwise textually identical expression has different
behavior. (And in other contexts, 'count' could refer to a
template ...)

C++ is filled with context sensitivity. In fact, it has few features
which are not in someway context sensitive.

The real problem with the OP's question is the enourmous number of
ways in which both C and C++ are context sensitive.


Context-sensitivity is a linguistic term that has to do with the rules
of
the grammar (i.e., what is syntactically correct), not the semantics of
the
program (i.e., what the program does). Your examples don't demonstrate
context-sensitivity in the grammatical sense.

Gregg

Jul 23 '05 #11

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

Similar topics

1
by: | last post by:
When passing values from one page to another using context.items collection & server.transfer, how secure is this data? This is using the notion...
0
by: Denise L. Moss-Fritch | last post by:
Has anyone developed context sensitive help for a C# application? According to our programming staff, the development side is not able to provide...
0
by: tbatwork828 | last post by:
If you were like me trying to figure out how to launch context sensitive help topic by the context id, here is the link: ...
0
by: ctyrrell | last post by:
Does anyone know of any restrictions of controls on Access forms that makes them ineligible for Context-Sensitive help? Are some types of controls...
5
by: TD | last post by:
Hey All, I am hooking up our custom html (.chm) help file to our Access xp application, and, despite reading several posts and manuals on this, I...
0
by: Renee | last post by:
Hi there, does any one know how to create context sensitive help for Groupbox control with HelpProvider class? I can create context sensitive...
0
by: raaco | last post by:
Hi all, It seems there is some context sensitive help when writing html, however if I do something like this Dim myDoc = AxWebBrowser1.Document...
0
by: Shawn K. N. | last post by:
Hi. We were able to have context sensitive help using RoboHelp for ASP applications, but now that we are using .Net our scripting is no longer...
2
by: Keith Hutchison | last post by:
G'day Is it possible to do custom context sensitive menus within MS Access. If yes, does anyone have a sample example? Thanks in advance ...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

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.