lex

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

对着背影说爱祢 提交于 2019-11-29 06:31:41
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 to overcome this problem. You probably just need to declare extern FILE * yyin; If that doesn't solve the problem, please give the error message you got. 来源: https://stackoverflow.com/questions/1796520/in-lex-how-to-make-yyin-point-to-a-file-with-the-main

How to create a parser(lex/yacc)?

好久不见. 提交于 2019-11-29 04:13:48
问题 I'm having the following file and which need to be parsed --TestFile Start ASDF123 Name "John" Address "#6,US" end ASDF123 The lines start with -- will be treated as comment lines. and the file starts 'Start' and ends with end . The string after Start is the UserID and then the name and address will be inside the double quots. I need to parse the file and write the parsed data into an xml file. So the resulting file will be like <ASDF123> <Name Value="John" /> <Address Value="#6,US" /> <

bison end of file

大兔子大兔子 提交于 2019-11-29 04:03:38
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 doesn't exist bison generates a syntax error because it does not finish the rule. How do I solve this? I tried making <<EOF>> return MY_EOF BUT when I do that lex crashes a horrible death. I guess there's code in its default EOF that I am not calling. I have no idea what functions they may be. Using EOF create the error symbol EOF is used, but is not defined as a token and has no rules You could use a flex EOF rule

how to install Lex and Yacc in Ubuntu? [closed]

旧巷老猫 提交于 2019-11-28 20:47:05
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 9 years ago . 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 回答1: Use the synaptic packet manager in order to install yacc / lex. If you are feeling more comfortable

Parsing, where can I learn about it

我与影子孤独终老i 提交于 2019-11-28 19:32:46
I've been given a job of 'translating' one language into another. The source is too flexible (complex) for a simple line by line approach with regex. Where can I go to learn more about lexical analysis and parsers? If you want to get "emotional" about the subject, pick up a copy of " The Dragon Book ." It is usually the text in a compiler design course. It will definitely meet your need "learn more about lexical analysis and parsers" as well as a bunch of other fun stuff! IMH(umble)O, save yourself an arm and/or leg and buy an older edition - it will fill your information desires. jfs Try

error: unknown type name ‘bool’

僤鯓⒐⒋嵵緔 提交于 2019-11-28 17:09:06
I downloaded the source code and wanted to compile the file of scanner. It produces this error: [meepo@localhost cs143-pp1]$ gcc -o lex.yy.o lex.yy.c -ll In file included from scanner.l:15:0: scanner.h:59:5: error: unknown type name ‘bool’ In file included from scanner.l:16:0: utility.h:64:38: error: unknown type name ‘bool’ utility.h:74:1: error: unknown type name ‘bool’ In file included from scanner.l:17:0: errors.h:16:18: fatal error: string: No such file or directory compilation terminated. And I tried to use different complier to compile it, but it appeared different errors. [meepo

SQL lex yacc grammar

谁说胖子不能爱 提交于 2019-11-28 08:48:29
All, Developing a validating application for embedded sql i'll use ansi c or c++ as developement language Where do i get an sql grammar for lex and yacc? Aymanadou hi there is a solution in google projects yaxx: yac file : lex file enjoy Umair There is book named "flex & bison" by John Levine (Author). in this book there is a complete chapter for sql parser. you can download this book for free here 来源: https://stackoverflow.com/questions/8656926/sql-lex-yacc-grammar

081 re正则表达式模块

老子叫甜甜 提交于 2019-11-28 08:39:34
目录 一、正则表达式 二、re模块的基本语法 ^ 元字符 $ 元字符 [] 元字符(字符集) [^] 反取 . 任意字符(换行符除外) * 对前一个字符0-无穷次扩展 + 对前一个字符1-无穷次扩展 ? 对前一个字符0或1次扩展 {m} 对前一个字符扩展m次 {m,n} 对前一个字符扩展m-n次(含n) \d 匹配单个数字(0-9) \D 匹配单个非数字(包括\n) \w 匹配 数字/字母/下划线 \W 匹配 非数字/非字母/非下划线 \s 匹配 空格/ \t/ \n \S 匹配 非空格/ 非\t/ 非\m () 只要括号内的 | 左右两边的字符都要 .* 贪婪模式 **.*? 非贪婪模式** 三、re模块中常用功能函数 3.1 正则表达式的两种书写方式 3.2 re.compile(strPattern[, flag])函数 3.2.1 re.S 3.2.2 re.I 3.2.3 re.M 3.2.4 re.sub 3.3 分组函数 3.4 re.match(pattern, string[, flags])函数(常用) 3.5 re.search(pattern, string[, flags])函数 3.6 re.findall(pattern, string[, flags])函数(常用) 3.7 re.split(pattern, string[, maxsplit]

how to parse from a string rather than a file [duplicate]

孤人 提交于 2019-11-28 06:45:20
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to make YY_INPUT point to a string rather than stdin in Lex & Yacc (Solaris) 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 回答1: I fought through this problem myself very recently. The flex documentation on the subject leaves a bit to be desired. I see two things right off the bat that might be tripping

Resources for lexing, tokenising and parsing in python

一笑奈何 提交于 2019-11-28 02:55:14
Can people point me to resources on lexing, parsing and tokenising with Python? I'm doing a little hacking on an open source project ( hotwire ) and wanted to do a few changes to the code that lexes , parses and tokenises the commands entered into it. As it is real working code it is fairly complex and a bit hard to work out. I haven't worked on code to lex/parse/tokenise before, so I was thinking one approach would be to work through a tutorial or two on this aspect. I would hope to learn enough to navigate around the code I actually want to alter. Is there anything suitable out there?