lex

How to use Boost::Spirit::Lex to lex a file without reading the whole file into memory first?

扶醉桌前 提交于 2019-12-18 06:08:11
问题 I'm looking at writing a lexer using boost::spirit::lex, but all the examples I can find seem to assume that you've read the entire file into RAM first. I'd like to write a lexer that doesn't require the whole string to be in RAM, is that possible? Or do I need to use something else? I tried using istream_iterator, but boost gives me a compile error unless I use const char* as the iterator types. e.g. All the examples I can find basically do this: lex_functor_type< lex::lexertl::lexer<> > lex

SQL lex yacc grammar

拟墨画扇 提交于 2019-12-17 18:44:09
问题 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? 回答1: hi there is a solution in google projects yaxx: yac file: lex file enjoy 回答2: 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

Lex and Yacc in PHP [closed]

五迷三道 提交于 2019-12-17 15:36:13
问题 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 5 years ago . Is there an implementation of Lex and Yacc in PHP? If not, can anyone suggest a lexical analyser and parser generator (ie, anything like Lex and Yacc) that will create PHP code. I'm not too worried about the performance of the resulting parser. I am sick of using regex to parse things that really shouldn't be

Cannot find -ly error

China☆狼群 提交于 2019-12-16 18:03:45
问题 I am trying to run a lexx and yacc program and I got the following error: /usr/bin/ld: cannot find -ly collect2: error: ld returned 1 exit status Plz tell me which libraries am I supposed to add? 回答1: I would guess the problem is that you're using a version of yacc other than the old AT&T yacc which doesn't come with liby (the -ly you have). So you need to remove the -ly option from your command line, and provide your own implementations of main and yyerror . 回答2: What version of yacc and lex

LEX -YACC parser for infix-to-prefix translation

本小妞迷上赌 提交于 2019-12-14 03:34:08
问题 Translation schemes: expr -> {print("+")} expr + term | {print("-")} expr - term | term term -> {print("*")} term * factor | {print("/")} term / factor | factor factor -> digit {print(digit)} | (expr) Above grammar will print the expression in prefix form. For this grammar it is not possible to write the parser. how could we write the lex and yacc program to convert infix to prefix. I follow this lex and yacc program to convert infix to prefix but not getting proper output. Any idea how to

In Java compiler,The print in System.out.print can be defined as identifier or Keyword? [duplicate]

蹲街弑〆低调 提交于 2019-12-14 03:32:44
问题 This question already has answers here : In Java compiler,which type can be defined as identifier ( ID ) or Keyword (reserved word)? (2 answers) Closed 4 years ago . I have studied about java which have listed 50 Java keywords. There is a homework of Lex, the goal is to recognize the word is keywords, IDs, symbols, operators. But there is one more little problem is the code below, is print in System.out.print() an ID or keyword? public class HelloWorld { public static int add(int a, int b) {

checking unfinished comments in flex

早过忘川 提交于 2019-12-14 02:42:21
问题 I am a new to flex. I have just written a sample code to detect multi line comments using a flex program. Now I want to improve the code. I want to detect unfinished and ill formed comments in the code. for example: a comment beginning with /* without an ending */ is an unfinished comment and by ill formed comment I mean the comment is not properly formed, say, an EOF appears inside the comment etc. What I have to add in my code to check these things? My sample code is as follows: %x COMMENT

How to list lex/yacc or flex/bison patterns?

久未见 提交于 2019-12-13 23:56:41
问题 I would like to extract all patterns from a flex/bison file to look at them altogether. I am not interested in the rules applying to the patterns for now. Surely someone has written a flex/bison file for this already? :) 回答1: If you give it the -v command-line option, bison will output a nicely formatted version of the grammar (and all the states) to a file with extension .output . You can specify the precise file name to write to with --report-file=PATH and a list of things to report on with

What is a regular expression for matching numbers divisible by 4?

∥☆過路亽.° 提交于 2019-12-13 09:03:05
问题 I want to make a lexical analyzer that detects numbers divisible by 4. Sample code - %% 16(divisible by 4) {printf("divisible by 4 %s\n",yytext);} %% main() { yylex(); } 回答1: %% [0-9]+ {int number = atoi(yytext); if((number % 4) == 0) printf("Div_4 %d\n", number);} %% main() { yylex(); } As lex/flex support C, so you can save the string as integer and then check it in C. 回答2: Divisibility by 4 The single-digit numbers which are divisible by 4 are 0, 4, and 8. The two-digit numbers which are

How to recognize string in Lex file

大兔子大兔子 提交于 2019-12-13 06:11:24
问题 Hi what would be appropriate to recognize string in a lex. I have already tried enter code here import java_cup.runtime.*; %% %cup %line NUM = [0-9] ID = [a-zA-Z] Pun= [:=;#@$^~] WhiteSpace = [ \t\r\n\f] SDQuo = [\"] %% ({SDQuo}+) ({ID}|{NUM})* ({SDQuo}+) { return new Symbol(sym.STR, new String(yytext()));} but the macro fail to be recognized. The error message that I kept getting is: Processing first section -- user code. Processing second section -- JLex declarations. Processing third