473,756 Members | 7,293 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Flex / Yacc sources for C parser

I'm currently working on a laguange similair in concept to Vala
(google for it on the Gnome project site). A (very) high level
language is translated into intermediary C, which is then
compiled to target.

I want to be able to "include" C headers, so that I don't have to
write bindings. That however means, that I have to parse them. I
could now of course write my own Flex / Yacc code, but I
presume, that there are ready to use C parser frameworks, which
can be filled with own code. Mostly it's about to get the
symbols. Preprocessor macros will be handed down into the
generated C code, but my compiler shall understand them to
enable compile time static type checking.

Wolfgang Draxinger
--
E-Mail address works, Jabber: he******@jabber .org, ICQ: 134682867

Dec 25 '07 #1
2 4020
Wolfgang Draxinger wrote:
I'm currently working on a laguange similair in concept to Vala
(google for it on the Gnome project site). A (very) high level
language is translated into intermediary C, which is then
compiled to target.

I want to be able to "include" C headers, so that I don't have to
write bindings. That however means, that I have to parse them. I
could now of course write my own Flex / Yacc code, but I
presume, that there are ready to use C parser frameworks, which
can be filled with own code. Mostly it's about to get the
symbols. Preprocessor macros will be handed down into the
generated C code, but my compiler shall understand them to
enable compile time static type checking.
Try lcc, which is touted as a re-targetable C compiler. It's often
praised for code clarity and modularity, so you may be able to rip out
the relevant pieces for your use.

<http://www.cs.princeto n.edu/software/lcc/>
<http://www.kernel.org/pub/software/devel/sparse/>

Dec 25 '07 #2
Wolfgang Draxinger wrote:
I'm currently working on a laguange similair in concept to Vala
(google for it on the Gnome project site). A (very) high level
language is translated into intermediary C, which is then
compiled to target.

I want to be able to "include" C headers, so that I don't have to
write bindings. That however means, that I have to parse them. I
could now of course write my own Flex / Yacc code, but I
presume, that there are ready to use C parser frameworks, which
can be filled with own code. Mostly it's about to get the
symbols. Preprocessor macros will be handed down into the
generated C code, but my compiler shall understand them to
enable compile time static type checking.

Wolfgang Draxinger
I managed to produce a C99 (mostly GNUC compatible) grammar via some C89
samples on the net.

http://c-faq.com/resources/grammars.html

See also:
http://www.lysator.liu.se/c/ANSI-C-grammar-y.html

That page has a lexer for C, and CPP.

GNUC is difficult to parse entirely and properly with Yacc-based
parsers. GNU's C compiler doesn't seem to use Yacc as much as the
typical compiler (lots of hand written parsing from what I saw).

George
Dec 25 '07 #3

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

Similar topics

4
3615
by: Peter Kleiweg | last post by:
Hi, I am looking for a Python equivalent of Flex. After some browsing, it seems that Plex is my best bet, but I would like to hear suggestions before I dive in. I have been using Flex a lot in combination with C programming. I never use Yacc (or Bison), though Flex and Yacc are supposed to be used together. But I found Yacc too cumbersome, and unnecessary. Yacc is about context-free grammars, nice if you
8
16847
by: pavel.orehov | last post by:
Hi, I am using flex and bizon to write HTTP parser. I am passing well flex and bison tools but can't compile their output. ================= Flex file (http_parser.lpp) ============== %{ #include <iostream> #include "http_parser.tab.hpp"
4
6340
by: Profetas | last post by:
Hi. I was wondering how can I access the yacc functions? because when use a normal yacc function such as qstring { yylval.string = strdup(yytext+1); if(yylval.string !='"') warning("Undeterminated Character strig",(char *)0); else
6
15485
by: Volker Hetzer | last post by:
Hi! We are finding ourselves in a situation where we have to parse several more or less free format text files. In the past, on linux, we had flex and bison for generating very fast parsers for these files. Is there any equivalent in the visual studio world? Lots of Greetings! Volker --
13
4381
by: jc | last post by:
I have written a parser using bison and flex to read ASAP2 file for CAN communications. entire development was done in an unix environment and now the code is ready to be integrated to an existing CAN communication software that i wrote earlier in windows environment(as we get drivers for these CAN cards only for the windows). my problem started when i started to move the code from linux to the visual studio. after many compilation and...
1
4283
by: deepusrp | last post by:
Helo everyone, i am doing a project on some graphic tool using qt as the front end. i am using lex and yacc as parser. now i am facing a problem since yacc generates only c code as i want to bring c++ features. so my request is " is there any way that we can create parser in qt itself or is there any method by which i can make a c++ (yacc) Parser... "
1
1841
by: c/c++ÐÂÎÅ×é | last post by:
I just compile flex and yacc file then add to VC it said: precompiled header file is from a previous version of the compiler, or the precompiled header is C++ and you are using it from C (or vice versa) How to solve this problem
5
2173
by: Benny the Guard | last post by:
I am writing a parser to handle input commands and process them. There are some builtin in commands that it will recognize one of which is TOK_CMD with another keyword after it (all tokenized based on supported commands). The processing is working great for real commands, so moving on to error detection. I have the rule: | TOK_CMD error TOK_EOL { printf ("illegal command dummy\n"); } | error TOK_EOL {
3
3341
by: Tinkertim | last post by:
Hello to all, I've been using C for a long time however I'm about to take my first splash into making a parser. I have some interesting things to accomplish and I'm hoping to get some recommended links to tutorials that might help me jump in. I will be parsing a configuration file, like this: vars {
0
9894
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
9679
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
9676
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
9541
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...
1
7078
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
6390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4955
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...
0
5156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3141
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.