473,789 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Writting a lexer program in C++

1 New Member
Hello every one..

I am planning to make a lexcial analyzer in C++, the keywords, opertators etc for the language that the lexer would take lexmes from are all given to us as a set of requirements.

I wanted to know how do i go about making this..


Thanks

Ap
Jul 10 '07 #1
6 4414
Silent1Mezzo
208 New Member
Hello every one..

I am planning to make a lexcial analyzer in C++, the keywords, opertators etc for the language that the lexer would take lexmes from are all given to us as a set of requirements.

I wanted to know how do i go about making this..


Thanks

Ap
Have you started thinking this through yet? What type of things do you need? What would the basic layout for a program be?
Jul 10 '07 #2
JosAH
11,448 Recognized Expert MVP
Hello every one..

I am planning to make a lexcial analyzer in C++, the keywords, opertators etc for the language that the lexer would take lexmes from are all given to us as a set of requirements.

I wanted to know how do i go about making this..


Thanks

Ap
The magic word is 'regular expressions'; well, ok, that makes two magic words.

kind regards,

Jos
Jul 10 '07 #3
weaknessforcats
9,208 Recognized Expert Moderator Expert
Start with a Bachus-Nauer diagram.
Jul 11 '07 #4
TRScheel
638 Recognized Expert Contributor
Start with a Bachus-Nauer diagram.
You made me look that up... started with Brachus-Nauer. Got nothing useful. Then went Brachus-Nauer diagram. Found almost nothing. Then tried Brachus Nauer diagram. A little better, though I got hints at Brachus Nauer form. Looked that up, and found this:

Brachus Nauer Form

And I hope that is what you mean.
Jul 11 '07 #5
weaknessforcats
9,208 Recognized Expert Moderator Expert
Yep. That's where you start.

All of your lexical rules and tokens will be in the form. Then you design your software
Jul 11 '07 #6
JosAH
11,448 Recognized Expert MVP
Yep. That's where you start.

All of your lexical rules and tokens will be in the form. Then you design your software
Backus-Naur (not "Nauer") form for general grammars would be overkill for simple
linear grammars. Those linear grammars are all that is needed for lexers and
they can be easily expressed by regular expressions.

Backus-Naur form notation for context free grammars comes in handy for the
parser part of compilers etc. (ref: Yacc, Bison, ANTLR etc.).

kind regards,

Jos
Jul 11 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
5511
by: Simon Foster | last post by:
Anyone have any experience or pointers to how to go about creating a parser lexer for assemble in Python. I was thinking of using PLY but wonder whether it's too heavyweight for what I want. Anyone have any thoughts? -- Simon Foster Somewhere in the West of England
1
1588
by: Thorsten Claus | last post by:
Hi, what's the environment variable for in the scite configuration file for the currently used lexer/syntax highlight? I want to have the current markup in the statusbar... Thorsten
6
1472
by: noridotjabi | last post by:
Is there any way in C to write source which would make an executable that excepted modifications. For instance say we have modable program that excepts plugins. That starts with a menu. 1)Add 2)Subtract 0)Add Mod :: When entering zero: Mod Source ::(whatever.c or maybe .o would be better) Say the mod we put in was to add a divide option to the main menu.
6
2745
by: Mike C# | last post by:
Hi all, Can anyone recommend a good and *easy to use* lexer and parser generator? Preferably one that was written specifically for VC++ and not mangled through 20 different platforms. I've had it up to here (funny hand gesture) with trying to compile the bullet-riddled code that GNU Flex and Bison keep spitting out for even the simplest of grammars (really funny hand gesture). Thanks
0
1226
by: Neil Cerutti | last post by:
I'm a royal n00b to writing translators, but you have to start someplace. In my Python project, I've decided that writing the dispatch code to sit between the Glulx virtual machine and the Glk API will be best done automatically, using the handy prototypes. Below is the prototype of the lexer, and I'd like some comments in case I'm doing something silly already.
6
9234
by: Java1963 | last post by:
Need help with writting an application that prompt for and read a double value representing a monetary amount. -------------------------------------------------------------------------------- Hello all, I am new to this Java stuff and, I need help in writting an application will prompt for and read a double value representing a monetary amount.Then determine the fewest numbers of each bill and coin needed to represent that amount,...
1
2324
by: rahulbsbs | last post by:
Sir how can i get the ip address of the remote system by writting a java code,ie i want to get ip address of the remote system that is connected to my server computer ,the ip address must be obtained by writting a java program.Is there any class for that.Please give me an example for getting this.
14
1843
by: Thomas Mlynarczyk | last post by:
Hello, I started to write a lexer in Python -- my first attempt to do something useful with Python (rather than trying out snippets from tutorials). It is not complete yet, but I would like some feedback -- I'm a Python newbie and it seems that, with Python, there is always a simpler and better way to do it than you think. ### Begin ###
3
2974
by: latif87 | last post by:
An example of how the XML file is structured: <xml> <farm name="NAME1"> <size x="INTEGER1" y="INTEGER2" /> <neighbor name="NAME2" /> <crop name="PLANT" area="INTEGER3" /> <crop … /> … </farm> <farm name="NAME2" …>
0
9663
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10404
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10193
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10136
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9979
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9016
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7525
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4089
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.