do you want the source for the parser that goes with the lexer I posted earlier too

LL

in that case I’d recommend a recusrive descent parser

but i’m not really sure because i haven’t written much anyway

after having struggled with table driven parsers for years (in a former life) I returned to writing all my parsers by hand as recursive descent (if the grammar allows me to)

okay, will google it

the first thing you should do is write your grammar down
and check if it is really LL(1)
if it isn’t, in some cases you can restructure the productions so that it becomes LL(1)
once you have your grammar, you jot down the list of terminal symbols
those are the ones your lexer needs to identify from the plain text stream and spit out as tokens for the parser
for example in C, “typedef”, “struct”, “if”, “else”, “{“, “;” are terminal symbols, they can not be further resolved into other symbols
typcially your lexer will have an enum which contains all the terminal symbols and that is what it should return when you call its getsym() function

can you suggest what kind of parser is better for my on-disk format?

on disk format doesn’t concern a parser
the lexer reads from the file
turns whatever is in the file into those symbol tokens
for example in a C lexer “if” might have 1, “else” might have 2, “{” might have 3, “}” might have 5, “;” might have 5 as a token
the parser only gets those tokens, it doesn’t care how they were read from the file
the parser only gets those tokens, it doesn’t care how they were read from the file
you may want to get yourself some books on compiler construction first
even if you only understand half or a third of whats in the book, you’ll gain enough to be able to write your own lexer and parser

i’m designing a much simpler thing than a compiler

doesn’t matter
the front end is the same as for a compiler
lexers and parsers are the same whether it is a configuration language, a protocol, or a programming language
generating code from the input afterwards is what makes compilers more complex (this is called the back end)
anyway, check out the Dragon book
its the classic compile writers’ bible
also there is a new one now which might replace the Dragon book as the new bible and its easier to read
let me get the title for you
Programming Language Pragmatics, by Michael L.Scott

info bison

bison is a bunch of crap for anything but prototyping grammars

thanks, will try to get my hands on it (in electronic form because i live in a banana republic)

not sure if there are electronic editions of those, can;t help you with that
a table driven parser can never match a handwritten one, not even come anywhere close
the only benefit of using a table driven parser is that you can very easily change your grammar and do so frequently without having to do major rework

[aotuomi@goblin models]$ cat calc.tab.c |wc -l
1620
../calc 1 + 2 * 3
only 1620 lines

hmm, i think one should make a language with more types of control flow

lines mean nothing, its the algorihtm

loops with exit handling conditions and stuff
hrnt, i think i can do that in less…

being able to change your grammar a lot is a benefit if you are developing a new protocol or language and you are not sure about the final grammar yet

benjk, what grammar ?

but if you have a given grammar which is unlikely to change significantly, you are always better off with a hand written parser
a parser needs a grammar

nah
well, not none, but not a significant amount

you don’t know what you are talking about then, read Knuth and shut up before you haven’t done so

four #defines ought to be enough for everyone

ignore set

i think i won’t need that because there is a spec for what i’m implementing

precisely my point
if you are implementing some protocol or configuration parser, then you already have a given grammar which is unlikely to change significantly if it will change at all
so the benefit of table driven parsers is not of any benefit to you
but you get all the downsides if you use one anyway
do you want the source for the parser that goes with the lexer I posted earlier, too?
its a recursive descent parser

would be great

http://www.sunrise-tel.com/software/plist/cw_master_config_parser.h
http://www.sunrise-tel.com/software/plist/cw_master_config_parser.c
also needs http://www.sunrise-tel.com/software/plist/cw_master_config_keywords.h

it’s almost always a complete waste of time to worry about complex grammars.

hi guys…i need a little help… i want to give colored output on terminal..can u suggest something

start with the simplest possible grammar, and then you can write a translation from whatever stupid ideas you get later into that.
e.g., start with an AST.

Hello! Does anyone know how compile example from libnet package?

yes.

gcc -o d.c d

no.

twkm, please give a hint

what does -o mean?

hi guys…i need a little help… i want to give colored output on terminal..can u suggest something

gcc -o d d.c i mean

read the spec for the terminal and see what makes it colour output.
also check out ncurses.

twkm, do I need link lib directly?

and while you’re at it — learn how to spell “you”.

learn how terminals work, decide how many you want to support, determine how to differentiate between them, then output whatever is appropriate.
you must usually name it somewhere, gcc won’t guess.

no i am asking about using c functions to output in color

there are none.

system calls related?

none.

Sanrag, VT100 works in many terminals, so you may look in to that to begin (“^]]22;21m” type stuff, where ^] is escape) but for something more portable, look in to smoething like ncurses

if you’ll make use of a non-standard library, such as the one Zhivago suggested, provided it is portable to all the environments you want, then you will find functions available to you such as has_colors and init_color and COLOR_PAIR.
typically ^] is not an escape.

twkm:why you have a star before your nickname

i don’t.

http://local.wasp.uwa.edu.au/~pbourke/dataformats/vt100/ for VT100 http://www.gnu.org/software/ncurses/ for ncurses

a @ indicates i am “op’d”, i.e., have channel operator abilities here.
a * would indicate that i am an oper, i.e., have network operator abilities, though freenode supresses that indicator.

twkm, Sorry but I can’t compile host nano /usr/share/doc/libnet1-dev/examples/dhcp_discover.c.gz
Please help with it.

hi
does anyone know the GUN C support any 64bit double type in IA32 machine?
I only know about ULL (unsigned long long)…
Does exits unsigned double double?

unsigned double doesn’t exist.
so some lame extension to unsigned double double is unlikely.
i would expect double to handle the 64 bit floating point type available, but if it does not try long double.

You have joined #C

i would never have guessed.

sorry, bad script
its not suppose to say that, its suppose to echo it localy

sadly network staff without the request of any of #c’s staff or contact has forwarded it here.

anyways, i have a question
im writing a plugin in C. and i need it to extract a sentance from a source of a web page
im writing a plugin in C. and i need it to extract a sentance from a source of a web page

*
To prove that you're not a bot, enter this code
Anti-Spam Image

Comments are closed.