Questions tagged [lex]

Lex is a computer program that generates lexical analyzers ("scanners" or "lexers"). Lex is commonly used with the yacc parser generator. For questions about Amazon Lex, use the tag amazon-lex instead.

Lex is a computer program that generates lexical analyzers ("scanners" or "lexers"). Lex is commonly used with the parser generator.

References:

See also:

Not to be confused with .

1809 questions
0
votes
2 answers

Linker error Yacc on Mac

I am getting this error when i try to compile. I have compiled lex files before with no problem i cant seem to get yacc to compile without error. :~ yacc project-5.y :~ lex project.l :~g++ -o $dragon project-5.tab.c lex.yy.c clang: warning:…
user1184034
  • 71
  • 3
  • 11
0
votes
1 answer

Exclude some characters from a Lex regex

I am trying to build a regex for lex that match the bold text in mardown syntax. For example: __strong text__ I thought this: __[A-Za-z0-9_ ]+__ And then replace the text by Matched text But in Lex, this rule causes the variable…
Alejandro Alcalde
  • 5,990
  • 6
  • 39
  • 79
0
votes
1 answer

Segmentation fault (core dumped) in ubuntu 12.04 yylex() call

The code below is trying to concatenate two text files and the output is written to another text file. As it's seen, I use yylex() function to get the tokens from the input files. The yywrap() function helps me to pass from the 1st text file to the…
Dani Grosu
  • 544
  • 1
  • 4
  • 22
0
votes
1 answer

Print Specific Line In Lex

I want to print only the lines that begin with the word "Hello" How can I do it? i.e Word----------Print Hello World (YES) World Hello (NO) Thanks!
user3503518
0
votes
1 answer

Validations in JISON parser

So I have generated a parser using JISON: %lex %x TEXT %% ("Project"|"project") {return 'PROJECTCOMMAND';} "-au" {return 'ADDUSER';} "-n" {this.begin('TEXT'); return 'NAMEOPTION';} "-k" {return 'KEYOPTION';} "-desc" {return…
Abhishek
  • 1,999
  • 5
  • 26
  • 52
0
votes
1 answer

JISON issues with parsing command

Hi I am a newbie to JISON and stuck in following code: For parsing a command: project -a -n My code is as follows: "project" {return 'PROJECTCOMMAND';} "-n" {return 'NAMEOPTION';} ("--add"|"-a") {return 'ADDOPTION';} …
Abhishek
  • 1,999
  • 5
  • 26
  • 52
0
votes
1 answer

How can I create the grammar definition to correctly parse a input

Lex file import ply.lex as lex # List of token names. tokens = ( "SYMBOL", "COUNT" ) t_SYMBOL = (r"Cl|Ca|Co|Os|C|H|O") def t_COUNT(t): r"\d+" t.value = int(t.value) return t def t_error(t): raise TypeError("Unknown…
Jack
  • 2,891
  • 11
  • 48
  • 65
0
votes
1 answer

Get char in the middle of the string YACC

My question is kinda simple, i suppose. Here is my code, %{ #include #include #include int yylex(void); void yyerror(char const *c); int yywarp(){ return 1; } %} %token LETTER MID %% input: {printf("Enter the…
0
votes
1 answer

Assistance With Lex/Flex Pattern

The prof. for my C/C++ class has introduced us to Flex (lexicographical analyzer), so this means I am total green-horn in the use of flex. The homework assignment I am working on currently is to remove the html tags from a simple html file, leaving…
Delete My Account
  • 745
  • 2
  • 9
  • 21
0
votes
1 answer

cant copy the yytext with strcpy

This is my code strcpy doesnt copy the yytext Any suggestion why? These are my globals char** v; /* array of variables and their values */ int i; some name definition WORD [a-zA-Z] DIGIT [0-9] These are the states "\"".+"\"" {int…
mosheovadi1
  • 73
  • 12
0
votes
1 answer

I'm receiving an error when giving my language a second input

The program generated from my bison/flex files works fine for the first input(the first run of yyparse()), but throws an error when I try and run it a second time. for example: chris@chris-Inspiron-1525:~/4850/hw$ ./calc HORN 3+4*6-11+33*2 ? = …
Chris Phillips
  • 1,997
  • 2
  • 19
  • 34
0
votes
1 answer

Yacc derivations failing to be recognized

This is a class project of sorts, and I've worked out 99% of all kinks, but now I'm stuck. The grammar is for MiniJava. I have the following lex file which works as intended: %{ #include "y.tab.h" %} delim [ \t\n] ws {delim}+ comment …
Chris Cirefice
  • 5,475
  • 7
  • 45
  • 75
0
votes
1 answer

Syntax error in lex yacc

here is my lex yacc code to parse an XML file and print the contents between and tags. LEX %{ %} %% "" {return XMLSTART;} "" {return XMLEND;} [a-z]+ {yylval=strdup(yytext); return TEXT;} "<" {yylval=strdup(yytext);return…
billyjayan
  • 27
  • 8
0
votes
3 answers

error in coding a lexer in c

#include #include #include /* this is a lexer which recognizes constants , variables ,symbols, identifiers , functions , comments and also header files . It stores the lexemes in 3 different files . One file contains all…
Hick
  • 35,524
  • 46
  • 151
  • 243
0
votes
1 answer

Why does a Flex program wait forever and not print anything?

I'm doing a translation of acronyms. That is, if it finds 'OMS' print 'Organización Mundial del trabajo', but once I compile and run the program it runs infinitely. I'm using Windows as a development environment. I have seen examples but I can't…
alfito
  • 11
  • 2
1 2 3
99
100