Sponsored Content
Top Forums Programming How to match n number of newline character(\n) in lex and yacc Post 302256556 by otheus on Monday 10th of November 2008 05:44:19 AM
Old 11-10-2008
The <newline> is not matched by the "period" operator. You have to specifically include it. \s Doesn't match a space in lex.
Code:
\"(.|[ \t\v\n])*\"

should work on :
Code:
1: ""
2: "blah blah"
3: "

"
4: " blah "

 

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
YACC(1) 						      General Commands Manual							   YACC(1)

NAME
yacc - yet another compiler-compiler SYNOPSIS
yacc [ option ... ] grammar DESCRIPTION
Yacc converts a context-free grammar and translation code into a set of tables for an LR(1) parser and translator. The grammar may be ambiguous; specified precedence rules are used to break ambiguities. The output file, y.tab.c, must be compiled by the C compiler to produce a program This program must be loaded with a lexical analyzer func- tion, yylex(void) (often generated by lex(1)), with a main(int argc, char *argv[]) program, and with an error handling routine, yyer- ror(char*). The options are -o output Direct output to the specified file instead of y.tab.c. -Dn Create file y.debug, containing diagnostic messages. To incorporate them in the parser, compile it with preprocessor symbol yydebug defined. The amount of diagnostic output from the parser is regulated by value n. The value 0 reports errors; 1 reports reductions; higher values (up to 4) include more information about state transitions. -v Create file y.output, containing a description of the parsing tables and of conflicts arising from ambiguities in the grammar. -d Create file y.tab.h, containing #define statements that associate yacc-assigned `token codes' with user-declared `token names'. Include it in source files other than y.tab.c to give access to the token codes. -s stem Change the prefix of the file names y.tab.c, y.tab.h, y.debug, and y.output to stem. -S Write a parser that uses Stdio instead of the print routines in libc. The specification of yacc itself is essentially the same as the UNIX version described in the references mentioned below. Besides the -D option, the main relevant differences are: The interface to the C environment is by default through <libc.h> rather than <stdio.h>; the -S option reverses this. The parser accepts UTF input text (see utf(6)), which has a couple of effects. First, the return value of yylex() no longer fits in a short; second, the starting value for non-terminals is now 0xE000 rather than 257. The generated parser can be recursive: actions can call yyparse, for example to implement a sort of #include statement in an inter- preter. Finally, some undocumented inner workings of the parser have been changed, which may affect programs that know too much about its structure. FILES
y.output y.tab.c y.tab.h y.debug y.tmp.* temporary file y.acts.* temporary file /sys/lib/yaccpar parser prototype /sys/lib/yaccpars parser prototype using stdio SOURCE
/sys/src/cmd/yacc.c SEE ALSO
lex(1) S. C. Johnson and R. Sethi, ``Yacc: A parser generator'', Unix Research System Programmer's Manual, Tenth Edition, Volume 2 B. W. Kernighan and Rob Pike, The UNIX Programming Environment, Prentice Hall, 1984 BUGS
The parser may not have full information when it writes to y.debug so that the names of the tokens returned by may be missing. YACC(1)
All times are GMT -4. The time now is 07:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy