Sponsored Content
Top Forums Programming How to match n number of newline character(\n) in lex and yacc Post 302258167 by vishwa787 on Friday 14th of November 2008 12:41:35 AM
Old 11-14-2008
Hi,

Yes it matches strings such as "this is a long string" .

Dont know how it is able to parse even though i have not included a space character in the expression [a-zA-Z0-9_$?\.=~<>{}#@`!$]

I have even used another condition as :

[ \t]+ /* ignore whitespace */;

in my lex file .

Does this interfere with the expression used i.e \"([a-zA-Z0-9_$?\.=~<>{}#@`!$]*|[ \t\v\n])*\"


Thanks
Vishwa
 

10 More Discussions You Might Find Interesting

1. Linux

lex for Chinese character

Hi, I need to read one chinese char using lex. I tried using "." ( period ) for pattern matching but in vain. Could anyone suggest me how do i proceeed. Sample pgm: to read a chinese char in single quotes. %{ #include <locale.h> %} %% \'.\' printf("SUCCESS\n"); . ... (0 Replies)
Discussion started by: suman_jakkula
0 Replies

2. UNIX for Dummies Questions & Answers

newline character

hi, I want to print the below lines "Message from bac logistics The Confirmation File has not been received." When i give like this in the code "Message from bac logistics\n The Confirmation File has not been received." It is giving only Message from bac logistics\n The... (9 Replies)
Discussion started by: trichyselva
9 Replies

3. UNIX for Dummies Questions & Answers

echo without newline character

hi, I have a for loop where in I write some file name to another file. I want to write all the filenames to another without any newlines. how can i avoid getting new lines with echo? Thanks, Srilaxmi (2 Replies)
Discussion started by: srilaxmi
2 Replies

4. Programming

actions before parsing rules in lex n yacc

Hi , We have developed a grammer for our domain language using lex n yacc. I want to know is there any pre defined lex-yacc function which gets call before executing any rule (or rules). Oue requirement is, before processing any rule ,we want to perform some specific actions ? is there... (0 Replies)
Discussion started by: supritjain
0 Replies

5. UNIX for Dummies Questions & Answers

Match newline character "\n" in lex

Hi everyone! This is my very first post, sorry if I'm not posting in the right category. I'm trying to match a newline "/n" using lex/yacc. For example, print(9,'\n',8) should print 9 8 now do I write a regular expression to match exactly " '\n' " Thanks! (1 Reply)
Discussion started by: code21
1 Replies

6. UNIX for Dummies Questions & Answers

newline character in a variable

variable="unix\nlinux" echo $variable expected output: unix linux :wall: can i do that ?? thanks in advance!! (3 Replies)
Discussion started by: sathish92
3 Replies

7. UNIX for Dummies Questions & Answers

Match EOF on newline in a file

Hi, i have a file where the end-of-file might be at the end of of a valid text line or on a new line case a) p q r s t u <eof> case b) p q r s t u <eof> case c) p q r s t u <no data, only carriage return> <eof> I have a requirement where <eof> line should not be read if it's... (3 Replies)
Discussion started by: ysrini
3 Replies

8. UNIX for Dummies Questions & Answers

Print a newline after first match in line

Hi everyone I have a file where CP occurs both within each line and at the very end: dwer 17 knsdask= * CP hwla 17 h'wopie un CP I would like to separate the line on the first CP to get: dwer 17 knsdask= * CP hwla 17 h'wopie un CP What I have so far is: awk '{for (x=1; x<NF; x++) ... (5 Replies)
Discussion started by: meet77
5 Replies

9. Shell Programming and Scripting

Remove last newline character..

Hi all.. I have a text file which looks like below: abcd efgh ijkl (blank space) I need to remove only the last (blank space) from the file. When I try wc -l the file name,the number of lines coming is 3 only, however blank space is there in the file. I have tried options like... (14 Replies)
Discussion started by: Sathya83aa
14 Replies

10. Shell Programming and Scripting

How to remove newline character if it is the only character in the entire file.?

I have a file which comes every day and the file data look's as below. Vi abc.txt a|b|c|d\n a|g|h|j\n Some times we receive the file with only a new line character in the file like vi abc.txt \n (8 Replies)
Discussion started by: rak Kundra
8 Replies
LEX(1)							      General Commands Manual							    LEX(1)

NAME
lex - generator of lexical analysis programs SYNOPSIS
lex [ -tvn ] [ file ... ] DESCRIPTION
Lex generates programs to be used in simple lexical analysis of text. The input files (standard input default) contain regular expressions to be searched for and actions written in C to be executed when expressions are found. A C source program, lex.yy.c is generated. This program, when run, copies unrecognized portions of the input to the output, and executes the associated C action for each regular expression that is recognized. The options have the following meanings. -t Place the result on the standard output instead of in file lex.yy.c. -v Print a one-line summary of statistics of the generated analyzer. -n Opposite of -v; -n is default. EXAMPLES
This program converts upper case to lower, removes blanks at the end of lines, and replaces multiple blanks by single blanks. %% [A-Z] putchar(yytext[0]+'a'-'A'); [ ]+$ [ ]+ putchar(' '); FILES
lex.yy.c output /sys/lib/lex/ncform template SEE ALSO
yacc(1), sed(1) M. E. Lesk and E. Schmidt, `LEX--Lexical Analyzer Generator', Unix Research System Programmer's Manual, Tenth Edition, Volume 2. SOURCE
/sys/src/cmd/lex BUGS
Cannot handle UTF. The asteroid to kill this dinosaur is still in orbit. LEX(1)
All times are GMT -4. The time now is 06:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy