lex

Statement with no effect warning with GCC and Flex/Bison

When compiling my project with gcc and the -Wall option, I get a warning about a statement with no effect in the non-existant last line of my flex file: Warning: gcc -Wall -O0 -ggdb3 -DNOSUDO -DJOBC -DDEBUG -c lex.yy.c tokenizer.l: In function ‘yylex’: tokenizer.l:179: warning: statement with no effect Shell Command: $ wc -l tokeniz...

flex/lex yacc/bison multithreaded environment

Can I use the code generated by flex/bison|lex/yacc in a multithreaded environment ? I'm afraid there are a lot of global variables. How can it be fixed ? ...

Error in lex program?

I was making this very simple lex program (just an introductory program). But on compiling lex.yy.c, I am getting this error as: inToPostfix.l:26: error: ‘struct stackoperand’ has no member named ‘top’ inToPostfix.l:32: error: ‘struct stackoperator’ has no member named ‘top’.... I could not make any reason for this error as I already...

flex, defining char

Hello I want to define char (ie 'a AND 'a') but I am having issues in checking errors. Here how I write the rule and check: char " ' " {letter} code {char} { int x =input() ; //printf("%d",'a'); if(x == 10) { return(tCharunterm); } ...

Lexical Analysis of Python Programming Language

Does anyone know where a FLEX or LEX specification file for Python exists? For example, this is a lex specification for the ANSI C programming language: http://www.quut.com/c/ANSI-C-grammar-l-1998.html FYI, I am trying to write code highlighting into a Cocoa application. Regex won't do it because I also want grammar parsing to fold code...

bison end of file

If i forget to put an empty line at the end of any of my files my program gets a syntax error. The problem is my grammar expects a newline to end the current line. Since a newline doesnt exist bison generates a syntax error bc it does not finish the rule. How do i solve this? I tried making <> return MY_EOF BUT when i do that lex crashe...

How to call a flex parser in c

How to call a flex parser in c ? ...

Can I define flex tokens during runtime?

I'd like to use lex/yacc to read in a delimited text file. This would be pretty trivial stuff for a parser, but different text files have different delimiters, so I'd like to let the user specify whether the text is separated by tabs, spaces, commas, pipes, unicode snowmen, et cetera. The normal means of using these tools is to write a ...

in lex how to make yyin point to a file with the main function in yacc?

I am storing the arguments passed to main in yacc in a file. Now I want the lex to read its input from this file rather than the terminal. I know I can point yyin to a file like yyin = fopen("fn","r"); but this works only when main is in lex. When I use this yyin declaration in main in yacc, it shows an error so please suggest something...

how to pass an array from lex to yacc..?

guyz i need to pass an integer array from lex to yacc.i know v can pass an integer using union of yylval but how to pass an array ...pls help me ...

Is Good To Know Regular Expressions To Build a Language?

I'm reading Flex & Bison from O'Reilly, and would like to know if learning Regular Expressions beforehand will help in developing a programming language? ...

Insert text in the input file in Lex (with C)

Hey! I'm trying to help a friend in a college assignment, but i kind of forgot a lot of C an Lex. The thing is, we are trying to parse a HTML and a correspondent CSS file and add to a tag it's style. Eg: HTML <body> </body> CSS body{color:black;} modified HTML <body style="color:black;"> </body> All the regex are done and ...

How can I learn about compiler theory - online/free resources

I'm interested in learning - at depth - about compiler theory... parsing EBNF LALR? Are all terms I'm familiar with but don't really understand how to actually implement/use.. I'm looking for links, tutorials, and other resources; all online, preferably all free... I'm more interested in simple / complete implementations, than comp...

Parse command line arguments in Lex

Suppose I want my Lex and Yacc program to parse the command line arguments like: ./a.out show memory I want lex to parse the string "show memory". How do I accomplish this? ...

how to use yy_scan_string in lex

i want to parse a string which i give in the main function iin yacc . i know tat this could be done by using yy_scan_string but i don't know how to use it. i even searched net and man pages but it is not clearly given so pls help me ...

how to parse from a string rather than a file

i want to parse from a string rather than a file. i know that v can use yy_scan_string fn to do it.but for me it's not working properly so pls help me ...

how to make YY_INPUT to point to a string rather than stdout in lex & yacc (solaris)

i want my yylex to parse a string rather than a file or stdout.how can v do it in solaris ...

what libraries should be linked in lex & yacc (solaris) to include YY_BUFFER_STATE

what libraries should be linked in lex & yacc (solaris) to include YY_BUFFER_STATE. when i use YY_BUFFER_STATE in lex and compile it .i get an error saying tat it is undeclared.but when i do it in unix i am getting the output so pls help me. ...

Should I use Lex or a home-brewed solution to parse a formula?

I'm in the process of writing a small, rule-based 'math' engine. I realize this is unclear, so I'll provide a small example. Let's say you have some variable a, that holds an integer. You also have some functions you can apply to the number, i.e. sqr - square the number flp - flip the bits of the number dec - decrement the number inc ...

Javascript lexer / tokenizer (in Python?)

Does anyone know of a Javascript lexical analyzer or tokenizer (preferably in Python?) Basically, given an arbitrary Javascript file, I want to grab the tokens. e.g. foo = 1 becomes something like: variable name : "foo" whitespace operator : equals whitespace integer : 1 ...