Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Match newline character "\n" in lex Post 302419094 by code21 on Thursday 6th of May 2010 09:28:59 AM
Old 05-06-2010
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!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

deleting newline characters but not the "true" \n character

hi, i have a file that has about 4500 rows. this was an old microsoft access databse and what i am trying to do is take out the old extra \n newline characters but not take out the "true" newline character. I will explain. i was trying to write a regular expression, but that was not... (1 Reply)
Discussion started by: caddyjoe77
1 Replies

2. Programming

How to match n number of newline character(\n) in lex and yacc

Hi , I need to develop a parser which should match something like 1. text a=5 " a=20"; 2. text a=..." a=20"; 3 text a=..." a=20 b=34 c=12 "; I have used this regular expression in my Lex file to generate the tokens: \".\s*.*\s.\" (8 Replies)
Discussion started by: vishwa787
8 Replies

3. UNIX for Dummies Questions & Answers

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

4. UNIX for Advanced & Expert Users

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

5. Shell Programming and Scripting

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

Using sed to find text between a "string " and character ","

Hello everyone Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
Discussion started by: haggismn
10 Replies

8. UNIX for Advanced & Expert Users

AIX - io info get from "libperfstat" not match "iostat"

Hi, everyone. I need to write a program to get io info based on libperfstat. But the "write time" of a disk is just half of the value get from iostat. I'm confused and can't explain. Help please. How I calculate "write service time per sec": In iostat: write service... (0 Replies)
Discussion started by: jackliang
0 Replies

9. UNIX for Advanced & Expert Users

How newline character "^M" appeared in file?

I have two files. Diff and hexdump tell that they are identical. However vi shows windows newline characters "^M" in one of these files. How is this possible? (2 Replies)
Discussion started by: urello
2 Replies

10. Shell Programming and Scripting

Search file containing ps results for a match "my.cnf" and then for a second match . "ok:" and

I need to find two matches in the output from ps. I am searching with ps -ef |grep mysql for: my.cnf /bin/sh /usr/bin/mysqld_safe --defaults-file=/data/mysql/master/agis_core/etc/my.cnf after this match I want to search back and match the hostname which is x number of lines back, above the... (2 Replies)
Discussion started by: bash_in_my_head
2 Replies
yacc(1) 							   User Commands							   yacc(1)

NAME
yacc - yet another compiler-compiler SYNOPSIS
/usr/ccs/bin/yacc [-dltVv] [-b file_prefix] [ -Q [y | n] ] [-P parser] [-p sym_prefix] file DESCRIPTION
The yacc command converts a context-free grammar into a set of tables for a simple automaton that executes an LALR(1) parsing algorithm. 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 function yyparse(). This program must be loaded with the lexical analyzer program, yylex(), as well as main() and yyerror(), an error handling routine. These routines must be supplied by the user. The lex(1) command is useful for creating lexical analyzers usable by yacc. OPTIONS
The following options are supported: -b file_prefix Uses file_prefix instead of y as the prefix for all output files. The code file y.tab.c, the header file y.tab.h (created when -d is specified), and the description file y.output (created when -v is specified), will be changed to file_pre- fix.tab.c, file_prefix.tab.h, and file_prefix.output, respectively. -d Generates the file y.tab.h with the #define statements that associate the yacc user-assigned "token codes" with the user- declared "token names". This association allows source files other than y.tab.c to access the token codes. -l Specifies that the code produced in y.tab.c will not contain any #line constructs. This option should only be used after the grammar and the associated actions are fully debugged. -p sym_prefix Uses sym_prefix instead of yy as the prefix for all external names produced by yacc. The names affected include the func- tions yyparse(), yylex() and yyerror(), and the variables yylval, yychar and yydebug. (In the remainder of this section, the six symbols cited are referenced using their default names only as a notational convenience.) Local names may also be affected by the -p option. However, the -p option does not affect #define symbols generated by yacc. -P parser Allows you to specify the parser of your choice instead of /usr/ccs/bin/yaccpar. For example, you can specify: example% yacc -P ~/myparser parser.y -Q[y|n] The -Qy option puts the version stamping information in y.tab.c. This allows you to know what version of yacc built the file. The -Qn option (the default) writes no version information. -t Compiles runtime debugging code by default. Runtime debugging code is always generated in y.tab.c under conditional compi- lation control. By default, this code is not included when y.tab.c is compiled. Whether or not the -t option is used, the runtime debugging code is under the control of YYDEBUG , a preprocessor symbol. If YYDEBUG has a non-zero value, then the debugging code is included. If its value is 0, then the code will not be included. The size and execution time of a program produced without the runtime debugging code will be smaller and slightly faster. -v Prepares the file y.output, which contains a description of the parsing tables and a report on conflicts generated by ambi- guities in the grammar. -V Prints on the standard error output the version information for yacc. OPERANDS
The following operand is required: file A path name of a file containing instructions for which a parser is to be created. EXAMPLES
Example 1: Accessing the yacc library Access to the yacc library is obtained with library search operands to cc. To use the yacc library main: example% cc y.tab.c -ly Both the lex library and the yacc library contain main. To access the yacc main: example% cc y.tab.c lex.yy.c -ly -ll This ensures that the yacc library is searched first, so that its main is used. The historical yacc libraries have contained two simple functions that are normally coded by the application programmer. These library functions are similar to the following code: #include <locale.h> int main(void) { extern int yyparse(); setlocale(LC_ALL, ""); /* If the following parser is one created by lex, the application must be careful to ensure that LC_CTYPE and LC_COLLATE are set to the POSIX locale. */ (void) yyparse(); return(0); } #include <stdio.h> int yyerror(const char *msg) { (void) fprintf(stderr, "%s ", msg); return(0); } ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of yacc: LANG, LC_ALL, LC_CTYPE, LC_MES- SAGES, and NLSPATH. yacc can handle characters from EUC primary and supplementary codesets as one-token symbols. EUC codes may only be single character quoted terminal symbols. yacc expects yylex() to return a wide character (wchar_t) value for these one-token symbols. EXIT STATUS
The following exit values are returned: 0 Successful completion. >0 An error occurred. FILES
y.output state transitions of the generated parser y.tab.c source code of the generated parser y.tab.h header file for the generated parser yacc.acts temporary file yacc.debug temporary file yacc.tmp temporary file yaccpar parser prototype for C programs ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWbtool | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
cc(1B), lex(1), attributes(5), environ(5), standards(5) DIAGNOSTICS
The number of reduce-reduce and shift-reduce conflicts is reported on the standard error output. A more detailed report is found in the y.output file. Similarly, if some rules are not reachable from the start symbol, this instance is also reported. NOTES
Because file names are fixed, at most one yacc process can be active in a given directory at a given time. Users are encouraged to avoid using '$' as part of any identifier name. SunOS 5.10 20 Dec 1996 yacc(1)
All times are GMT -4. The time now is 01:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy