lex

Recognize Identifiers in Chinese characters by using Lex/Yacc

How can I use Lex/Yacc to recognize identifiers in Chinese characters? Thanks for help. ...

Compilation error with flex file

Hello, I'm trying to build a simple lexical analyzer to go along with a simple input output library for (scientific) C programs. When compiling with autotools, including automake, libtool, and autoconf, I get the following error: simpleio_lex.l:41: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘of’ This usually mean...

segmentation fault with bison and flex

Hi, I was trying learn lex and yacc using the oreilly book. I tried following example from book, but it gives segmentation fault. %{ /** * A lexer for the basic grammar to use for recognizing English sentences. */ #include <stdio.h> extern FILE *yyin; %} %token NOUN PRONOUN VERB ADVERB ADJECTIVE PREPOSITION CONJUNCTION %% ...

FlexSDK to compile mxml file

Downloaded and installed the latest version of a FlexSDK. Unzipped it into a folder C:FlexSDK. Opened up my command prompt to C:/FlexSDK/bin. Ran a directory of the folder and my mxmlc.exe file was there. From the command prompt I issued mxmlc c:test.mxml and received a "could not find a JVM" error. This is surprising because I have co...

When is it practical to use a parser generator?

I'm writing a simple text-template language for a web application I'm writing (think google's ctemplate). When finished, it'll feature only a small number of possible actions, simple stuff like "evaluate and execute", "evaluate and print", "evaluate and escape html", "comment". I was thinking of hand writing the whole parser from scratch...

Calling lex/yacc from a separate program

I've been reading up on lex/yacc. The books and examples are not hard to follow. In fact, the whole concept is clear as a bell. With one exception. Lex/yacc seem to generate standalone programs. What if I wanted to call them as a parser function? Yacc seems to generate a main function, so how would I call from my own without conflicts. ...

Space issue with Flex/Bison

Im currently working on an HTML parser/template library using Flex/Bison. I am having some issues with my if statement. The expression parses fine ( if you > me ) but when it comes to the statement between the beginning and ending if tags, it is only getting the first word and dying on the space between them. Just wondering how I can en...

Lex : print line numbers

Hello, I have a source code and I would like to add line numbers. What I've done : %{ int lines=0; %} LINE \n %% {LINE} {ECHO;printf("%d", ++lines);} However, I don't know how to catch the first line. Can you help me ? ...

Lex : line with one character but spaces

Hello, I have sentences like : " a" "a " " a " I would like to catch all this examples (with lex), but I don't how to say the beginning of the line ...

AST for any arbitrary programming language or IR

Hi All, Is it possible to create an AST for any arbitrary programming language or IR using C or C++ alone (without the help of tools like YACC and LEX )? If so, how to implement the lexical and syntactic analysis ? If not, what are the tools that have to augmented to C or C++ to successfully create an AST ? Hope I made my doubt clear...

how to install Lex and Yacc in Ubuntu ?

Hello, I am doing project in SENSE, for that i have to install Lex and Yacc. If you can help me how to install in Ubuntu. I very new to this area. So can you help me. Any website to study the basic of Lex and Yacc ...

Ignoring errors in yacc/lex

I'm new to yacc/lex and I'm working on a parser that was written by someone else. I notice that when an undefined token is found, the parser returns an error and stops. Is there a simple way to just make it ignore completely lines that it cannot parse and just move on to the next one? ...