yacc

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 ...

C grammar in GCC source code

I'm looking for the C grammar in GCC source code, more specifically for the grammar in the yacc/bison form. ...

Indentation control while developing a small python like language

Hello, I'm developing a small python like language using flex, byacc (for lexical and parsing) and C++, but i have a few questions regarding scope control. just as python it uses white spaces (or tabs) for indentation, not only that but i want to implement index breaking like for instance if you type "break 2" inside a while loop that'...

Do lex and yacc provide optimized code?

Do Lex and Yacc provide optimized code or is it required that we write our own code manually for higher performance? ...

Python PLY zero or more occurrences of a parsing item

I am using Python with PLY to parse LISP-like S-Expressions and when parsing a function call there can be zero or more arguments. How can I put this into the yacc code. This is my function so far: def p_EXPR(p): '''EXPR : NUMBER | STRING | LPAREN funcname [EXPR] RPAREN''' if len(p) == 2: p[0] = p[...

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...

Tools to build a UI markup language parser

For a school project, I need to implement a parser for a (probably XML-based) markup language for User Interfaces. Based on the input it generates a HTML document with various UI components (textareas, inputs, panels, dialogs etc.) Do you have any suggestions for tools/libraries I might use for this? (At school we use Flex and Bison, b...

Need Lex and Yacc program which does C syntax-checking

Anybody knows from where I can download a Lex and Yacc program(the source code) for complete syntax checking of a C program? Pls post the link as comment ...

On ocamlyacc, function application grammar and precedence

I'm OCaml newbie and I'm trying to write a simple OCaml-like grammar, and I can't figure this out. My grammar allows something like this: let sub = fun x -> fun y -> x - y;; However, if I want to use the function so defined, I can write: (sub 7) 3 but I can't write sub 7 3, which really bugs me. For some reason, it gets interpreted as...

Python/YACC Lexer: Token priority?

I'm trying to use reserved words in my grammar: reserved = { 'if' : 'IF', 'then' : 'THEN', 'else' : 'ELSE', 'while' : 'WHILE', } tokens = [ 'DEPT_CODE', 'COURSE_NUMBER', 'OR_CONJ', 'ID', ] + list(reserved.values()) t_DEPT_CODE = r'[A-Z]{2,}' t_COURSE_NUMBER = r'[0-9]{4}' t_OR_CONJ = r'or' t_ignore = ' \t' def t_ID(t...

Python: Trouble with YACC

I'm using PLY to parse sentences like: "CS 2310 or equivalent experience" The desired output: [[("CS", 2310)], ["equivalent experience"]] YACC tokenizer symbols: tokens = [ 'DEPT_CODE', 'COURSE_NUMBER', 'OR_CONJ', 'MISC_TEXT', ] t_DEPT_CODE = r'[A-Z]{2,}' t_COURSE_NUMBER = r'[0-9]{4}' t_OR_CONJ = r'or' t_ign...

Python/YACC: Resolving a shift/reduce conflict

I'm using PLY. Here is one of my states from parser.out: state 3 (5) course_data -> course . (6) course_data -> course . course_list_tail (3) or_phrase -> course . OR_CONJ COURSE_NUMBER (7) course_list_tail -> . , COURSE_NUMBER (8) course_list_tail -> . , COURSE_NUMBER course_list_tail ! shift/reduce conflict for...

trying to build a C# grammar for bison/wisent

I've never done Bison or Wisent before. how can I get started? My real goal is to produce a working Wisent/Semantic grammar for C#, to allow C# to be edited in emacs with code-completion, and all the other CEDET goodies. (For those who don't know, Wisent is a emacs-lisp port of GNU Bison, which is included into CEDET. The Wisent appar...

Utility to format a Bison/Yacc grammar file nicely?

Hello there: Do you folks know of any GNU/Linux utility to format a Bison grammar file, containing C code, nicely? I'm thinking of something along the lines of GNU Indent, but designed to beautify grammar files rather than C code. ...

How to create a parser which tokenizes a list of words taken from a file?

Hi, I am trying to do a sintax text corrector for my compilers' class. The idea is: I have some rules, which are inherent to the language (in my case, Portuguese), like "A valid phrase is SUBJECT VERB ADJECTIVE", as in "Ruby is great". Ok, so first I have to tokenize the input "Ruby is great". So I have a text file "verbs", with a lot ...

Recovering error tokens in parsing (Lemon).

I'm using Lemon as a parser generator, its error handling is the same as yacc's and bison's if you don't know Lemon. Lemon has an option to define the error token in a set of rules in order to catch parsing errors. The default behavior of the generated parser is to destroy the token causing the error; is there any way to override this b...

Basic problem with yacc/lex

Hello, I have some problems with a very simple yacc/lex program. I have maybe forgotten some basic steps (it's been a long time since I've used these tools). In my lex program I give some basic values like : word [a-zA-Z][a-zA-Z]* %% ":" return(PV); {word} { yylval = yytext; printf("yylval = %s\n",yylva...

Is it possible to generate a parser for a language using the Reverse Polish notation with bison/yacc?

Is it possible to generate a parser for a scripting language that uses the Reverse Polish notation (and a Postscript-like syntax) using bison/yacc? The parser should be able to parse code like /fib { dup dup 1 eq exch 0 eq or not { dup 1 sub fib exch 2 sub fib add } if } def ...

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. ...

yacc/lex or hand-coding?

I am working on new programming language, but I was always puzzled by the fact that everyone is using yaxx/lex to parse the code, but I am not. My compiler (which is already working) is handcoded in C++/STL, and I cannot say it's complex or took too much time. It has both some kind of lexer and parser, but they are not autogenerated. E...