473,406 Members | 2,404 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,406 software developers and data experts.

about CSharp Parser

Hi:
I work in Csharp's parser files by LEX/YACC.Now I have only CSharp-lex.l
and CSharp.y file,but they not have CSharp'comment Parse. this is a part of
CSharp-lex.l.

.....................
/***** Comments *****/
"/*" { yy_push_state(IN_COMMENT); }
<IN_COMMENT>. { ; /* ignore */ }
<IN_COMMENT>\n { ; /* ignore */ }
<IN_COMMENT>"*/" { yy_pop_state(); }

{single_line_comment} { ; /* ignore */ }
...................

CSharp.y file not have any more comment regular.

Now I need comment parser in CSharp-lex.l. and CSharp.y files. Who give me
the files?

THS
EKEY
05.1.31

Nov 16 '05 #1
2 4527
go****@wain-sh.com wrote:
/***** Comments *****/
"/*" { yy_push_state(IN_COMMENT); }
<IN_COMMENT>. { ; /* ignore */ }
<IN_COMMENT>\n { ; /* ignore */ }
<IN_COMMENT>"*/" { yy_pop_state(); }

{single_line_comment} { ; /* ignore */ }

I'm afraid I didn't understand your question, but the above snippet is using
lex start conditions to parse C-style comments, as used in C#. You can read
more about them here:

http://www.gnu.org/software/flex/man..._11.html#SEC11

On this page you will also find a much more efficient snippet of code for
parsing the same thing:

"/*" BEGIN(comment);

<comment>[^*\n]* /* eat anything that's not a '*' */
<comment>"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */
<comment>\n ++line_num;
<comment>"*"+"/" BEGIN(INITIAL);

It's more efficient because it "eats" large strings of comment characters,
instead of eating one character at a time. You would simply add it somewhere
in your .y file. (line_num is assumed to be an integer variable tracking the
current line number). I hope this helps.
--
Derrick Coetzee, Microsoft Speech Server developer
This posting is provided "AS IS" with no warranties, and confers no rights.
Nov 16 '05 #2

If you look for a C# parser, try
http://www.c-sharpcorner.com/Code/20...CodeParser.asp

Lionel.

"news.microsoft.com" <go****@wain-sh.com> a ecrit dans le message de news:
ez**************@TK2MSFTNGP15.phx.gbl...
Hi:
I work in Csharp's parser files by LEX/YACC.Now I have only
CSharp-lex.l
and CSharp.y file,but they not have CSharp'comment Parse. this is a part
of
CSharp-lex.l.

....................
/***** Comments *****/
"/*" { yy_push_state(IN_COMMENT); }
<IN_COMMENT>. { ; /* ignore */ }
<IN_COMMENT>\n { ; /* ignore */ }
<IN_COMMENT>"*/" { yy_pop_state(); }

{single_line_comment} { ; /* ignore */ }
..................

CSharp.y file not have any more comment regular.

Now I need comment parser in CSharp-lex.l. and CSharp.y files. Who give me
the files?

THS
EKEY
05.1.31

Nov 16 '05 #3

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

Similar topics

1
by: Karalius, Joseph | last post by:
Can anyone explain what is happening here? I haven't found any useful info on Google yet. Thanks in advance. mmagnet:/home/jkaralius/src/zopeplone/Python-2.3.5 # make gcc -pthread -c...
0
by: Bekkali Hicham | last post by:
Hi, i am using WSAD 4.0.2 java perspective to devellop a XMLEditor (read only), i use the SAX api for this purpose, everything works fine, i succed to create a JTree representation of an xml...
2
by: Ken Philips | last post by:
As far as I know the Schema Object Model (SOM) is only working for the MSXML Parser together with CSharp or VisualBasic but not Java. Is there a similar Tool/Spec/Api for the Java World? Ken
6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
19
by: Gérard Talbot | last post by:
posted to: alt.html and comp.infosystems.www.authoring.html followup-to: comp.infosystems.www.authoring.html Hello all, I have 2 questions about validations. 1- What's basically the...
5
by: EMonaco | last post by:
All, I have a simple C# window app under MyApp namespace it has a class Form1. I've added another class .cs file. Now this class I want to share with many projects, so I figured I'd change this...
10
by: sp | last post by:
I create an xml file in a text editor: <?xml version="1.0" encoding="utf-8"?> <elts> <elt id="1" class="c1">content1</elt> <elt id="2" class="c1">content2</elt> </elts> Then I load the file...
5
by: Joel | last post by:
In the course of my project, I must include some custom logic and would like to integrate a small script language in my application for that purpose. In C++, I used the LUA script language and I...
3
by: Steven W. Orr | last post by:
I decided I could be more articulate. I hope this helps. I'm writing a program that needs to process options. Due to the nature of the program with its large number of commandline options, I...
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: 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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.