lexical-analyser

How do i implement If statement in Flex/bison

Hallo Rudi, I dont get the error, please can you help me out, here is the .l and .y file.thanks. %{ #include "ifanw.tab.h" extern int yylval; %} %% "=" { return EQ; } "!=" { return NE; } "<" { return LT; } "<=" { return LE; } ">" { return GT; } ">=" { return GE; } "+" { return PLUS; } "-" { return MI...

How do you implement syntax highlighting?

I am embarking on some learning and I want to write my own syntax highlighting for files in C++. Can anyone give me ideas on how to go about doing this? To me it seems that when a file is opened: It would need to be parsed and decided what type of source file it is. Trusting the extension might not be fool-proof A way to know what ...

Flex/bison, error: undeclared

hallo, i have a problem, the followed program gives back an error, error:: Undeclared(first use in function), why this error appears all tokens are declared, but this error comes, can anyone help me, here are the lex and yac files.thanks lex: %{ int yylinenu= 1; int yycolno= 1; %} %x STR DIGIT [0-9] ALPHA ...

PCCTS track input column number

How can I make PCCTS track the number of the tokens columns? ...

JMP instruction in Flex/bison

Hallo everybody, Can someone help me out of my situation, im searching for a instrucior that implements the JMP (Jump) instructior like in Assembler. I've found out that it could be withe the goto function of Flex/Bison but i have no really idea how to do. Have got anyone idea. Im very grateful of yours help. Thanks. Here is an example ...

Syntactical analysis with Flex/Bison part 2

Hallo, I need help in Lex/Yacc Programming. I wrote a compiler for a syntactical analysis for inputs of many statements. Now i have a special problem. In case of an Input the compiler gives the right output, which statement is uses, constant operator or a jmp instructor to which label, now i have to write so, if now a if statement com...

Bison input analyzer - basic question on optional grammer and input interpretation

Hi All, I am very new to Flex/Bison, So it is very navie question. Pardon me if so. May look like homework question - but I need to implement project based on below concept. My question is related to two parts, Question 1 In Bison parser, How do I provide rules for optional input. Like, I need to parse the statment Example : ...

What functions a lexer needs to provide?

I am making a lexer, don't tell me to not do because I already did most of it. Currently it makes an array of tokens and that's it. I would like to know, what functions the lexer needs to provide and a brief explanation of what each function needs to do. I'll accept the most complete list. An example function would be: next: Consume ...

Are you aware of any lexical analyzer or lexer in Qt?

Are you aware of any lexical analyzer or lexer in Qt? I need it for parsing text files. ...

Regular expressions versus lexical analyzers in Haskell

I'm getting started with Haskell and I'm trying to use the Alex tool to create regular expressions and I'm a little bit lost; my first inconvenience was the compile part. How I have to do to compile a file with Alex?. Then, I think that I have to import into my code the modules that alex generates, but not sure. If someone can help me, I...

Building a lexical Analyzer in Java

I am presently learning Lexical Analysis in Compiler Design. In order to learn how really a lexical analyzer works I am trying to build one myself. I am planning to build it in Java. The input to the lexical analyzer is a .tex file which is of the following format. \begin{document} \chapter{Introduction} \section{Scope} ...

Question on lexical analysis

I am reading the dragon book. Quoting the text from the book (3.1.4 Lexical errors, Pno 114) It is hard for a lexical analyzer to tell, without the aid of other components, that there is a source-code error. For instance, if the string fi is encountered for the first time in a C program in the context: fi ( a == f(x) ) ....

Good ways to visualize a word-like document

What are some good ways to visualize a word-like document? Edit: It doesn't have to be a .doc, it could be a text file or blog post... ...

If you are forced to simplify C# looping keywords, choose only one you want to preserve.

If you are forced to simplify C# keywords that can be used for looping, choose only one you want to preserve. for do-while while goto-label-if foreach Is there any performance consideration regarding your decision? Actually I don't know the internal mechanism of them, so here I want interview those of you know the details. However...

C/C++/C#/VB based Lexical Analyzers

During the Compiler Design Lab hours, I'm using JLex as the Lexical Analyzer Generator, which produces a Java program from a lexical specification. I'd like to know if there are other tools which can help me in the same by generating C/C++/C# or VB programs instead of a Java program, and can run in Windows. ...

Javascript Compiler / Lexer

I'm looking for a free open-source Javascript/ECMAScript compiler or lexical analyzer, in order to compile javascript code to an executable that can run on Linux. I understand that I will probably need to add some objects/APIs for the javascript code to be able to perform operations within the O/S. I was hoping that some of this work h...

C Lexical analyzer in python

Hey, I'm creating a C Lexical analyzer using python as part of developing a parser.Here in my code i have written some methods for identifying keywords,numbers,operators etc. No error is shown after compiling. While executing i could input a .c file.My output should list all the keywords,identifiers etc in the input file. But it is not ...