Sponsored Content
Full Discussion: Parsing string
Top Forums UNIX for Dummies Questions & Answers Parsing string Post 302107745 by anbu23 on Tuesday 20th of February 2007 11:59:51 AM
Old 02-20-2007
Code:
x="1212-2323"
bfr_hyphen=$( echo ${x%-*} )
aftr_hyphen=$( echo ${x#*-} )

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help on parsing string

String example: /vmfs/volumes/46000471-71d7c414-8f74-0013210cddc3/gistst/gistst.vmx What I would like to do is create a variable and save gistst in it. I thought if I could create an array and split it by '/' then I could use the 4th array element or if they was a way to do a... (13 Replies)
Discussion started by: magnacrazy
13 Replies

2. Programming

parsing string in c

how can i remove the special characters hi iam print the string variable . suppse: while(str!=NULL) printf("******* %s ********** %d ",str,strlen(str)); output as: ****srinu ******** 5 **** phani******** 63 ****srinu ******** 5 **** phani******** 63 so my problem is how can i... (3 Replies)
Discussion started by: phani_sree
3 Replies

3. Shell Programming and Scripting

parsing a string

hi i am new to Shell scripting i have a string "hostName=lpdma520_dev_ipc_us_aexp_com" now i need to parse the string as "var1=lpdma520" please help (7 Replies)
Discussion started by: satish@123
7 Replies

4. Shell Programming and Scripting

Parsing of file for Report Generation (String parsing and splitting)

Hey guys, I have this file generated by me... i want to create some HTML output from it. The problem is that i am really confused about how do I go about reading the file. The file is in the following format: TID1 Name1 ATime=xx AResult=yyy AExpected=yyy BTime=xx BResult=yyy... (8 Replies)
Discussion started by: umar.shaikh
8 Replies

5. Shell Programming and Scripting

String-parsing!

I need the perl solution for the following : $string="I LOVE INDIA" now, in a new string i need the first character of each word... that is string2 should be "ILN". (10 Replies)
Discussion started by: vijay_0209
10 Replies

6. Shell Programming and Scripting

Parsing String

Hello All, I have a case, wherein I have a string of the format "attr1=value1 attr2=value2 attr3=value3 attr4=value4" How do I extract the value associated with for a given attributename. For eg. I need to get a value of "value2" when I give an input for attribute name as "attr2". Note, each... (10 Replies)
Discussion started by: msgforsunil
10 Replies

7. Shell Programming and Scripting

String parsing

Hi, name=VDSL_TTV_ HN_SUB create coid=MA5603U phone=5678 portpolicy=APortSelectionPolicy rfu10=TTV rfu3=Dot1q sz7_portmode=VDSL2 rfu5=1234 srprofile.sy_profname=$ADSL_TTV_SubProfile1 I have a line like this. Its a single line.I need the output as name=VDSL_TTV_ HN_SUB create... (1 Reply)
Discussion started by: giri_luck
1 Replies

8. Shell Programming and Scripting

String parsing

Hi, name=VDSL_TTV_ HN_SUB create coid=MA5603U phone=5678 portpolicy=APortSelectionPolicy rfu10=TTV rfu3=Dot1q sz7_portmode=VDSL2 rfu5=1234 srprofile.sy_profname=$ADSL_TTV_SubProfile1 I have a line like this. Its a single line.I need the output as name=VDSL_TTV_ HN_SUB create... (6 Replies)
Discussion started by: giri_luck
6 Replies

9. Shell Programming and Scripting

Need help on parsing string

for i in `cat list`;do lol=`curl -m 2 -s ${i} | grep 'class=info' | cut -d '>' -f14 | cut -d '<' -f1 | sed '/^$/d'`; if ;then echo "$i,$lol" >> dirty; echo "$i,$lol";fi; done cut: you must specify a list of bytes, characters, or fields Try `cut --help' for more information. it gave me that... (0 Replies)
Discussion started by: p33plime
0 Replies

10. Shell Programming and Scripting

Parsing a long string string problem for procmail

Hi everyone, I am working on fetchmail + procmail to filter mails and I am having problem with parsing a long line in the body of the email. Could anyone help me construct a reg exp for this string below. It needs to match exactly as this string. GetRyt... (4 Replies)
Discussion started by: cwiggler
4 Replies
aycock(3tcl)					  Aycock-Horspool-Earley parser generator for Tcl				      aycock(3tcl)

__________________________________________________________________________________________________________________________________________________

NAME
aycock - Aycock-Horspool-Earley parser generator for Tcl SYNOPSIS
package require Tcl 8.5 package require grammar::aycock ?1.0? ::aycock::parser grammar ?-verbose? parserName parse symList valList ?clientData? parserName destroy parserName terminals parserName nonterminals parserName save _________________________________________________________________ DESCRIPTION
The grammar::aycock package implements a parser generator for the class of parsers described in John Aycock and R. Nigel Horspool. Practi- cal Earley Parsing. The Computer Journal, 45(6):620-630, 2002. http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.12.4254 PROCEDURES
The grammar::aycock package exports the single procedure: ::aycock::parser grammar ?-verbose? Generates a parser for the given grammar, and returns its name. If the optional -verbose flag is given, dumps verbose information relating to the generated parser to the standard output. The returned parser is an object that accepts commands as shown in OBJECT COMMAND below. OBJECT COMMAND
parserName parse symList valList ?clientData? Invokes a parser returned from ::aycock::parser. symList is a list of grammar symbols representing the terminals in an input string, and valList is a list of their semantic values. The result is the semantic value of the entire string when parsed. parserName destroy Destroys a parser constructed by ::aycock::parser. parserName terminals Returns a list of terminal symbols that may be presented in the symList argument to the parse object command. parserName nonterminals Returns a list of nonterminal symbols that were defined in the parser's grammar. parserName save Returns a Tcl script that will reconstruct the parser without needing all the mechanism of the parser generator at run time. The reconstructed parser depends on a set of commands in the package grammar::aycock::runtime, which is also automatically loaded when the grammar::aycock package is loaded. DESCRIPTION
The grammar::aycock::parser command accepts a grammar expressed as a Tcl list. The list must be structured as the concatenation of a set of rules. Each rule comprises a variable number of elements in the list: o The name of the nonterminal symbol that the rule reduces. o The literal string, ::= o Zero or more names of terminal or nonterminal symbols that comprise the right-hand-side of the rule. o Finally, a Tcl script to execute when the rule is reduced. Within the given script, a variable called _ contains a list of the semantic values of the symbols on the right-hand side. The value returned by the script is expected to be the semantic value of the left-hand side. If the clientData parameter was passed to the parse method, it is available in a variable called clientData. It is permissible for the script to be the empty string. In this case, the semantic value of the rule will be the same as the semantic value of the first symbol on the right-hand side. If the right-hand side is also empty, the semantic value will be the empty string. Parsing is done with an Earley parser, which is not terribly efficient in speed or memory consumption, but which deals effectively with ambiguous grammars. For this reason, the grammar::aycock package is perhaps best adapted to natural-language processing or the parsing of extraordinarily complex languages in which ambiguity can be tolerated. EXAMPLE
The following code demonstrates a trivial desk calculator, admitting only +, * and parentheses as its operators. It also shows the format in which the lexical analyzer is expected to present terminal symbols to the parser. set p [aycock::parser { start ::= E {} E ::= E + T {expr {[lindex $_ 0] + [lindex $_ 2]}} E ::= T {} T ::= T * F {expr {[lindex $_ 0] * [lindex $_ 2]}} T ::= F {} F ::= NUMBER {} F ::= ( E ) {lindex $_ 1} }] puts [$p parse {( NUMBER + NUMBER ) * ( NUMBER + NUMBER ) } {{} 2 {} 3 {} {} {} 7 {} 1 {}}] $p destroy The example, when run, prints 40. KEYWORDS
Aycock, Earley, Horspool, parser, compiler KEYWORDS
ambiguous, aycock, earley, grammar, horspool, parser, parsing, transducer CATEGORY
Grammars and finite automata COPYRIGHT
Copyright (c) 2006 by Kevin B. Kenny <kennykb@acm.org> Redistribution permitted under the terms of the Open Publication License <http://www.opencontent.org/openpub/> grammar_aycock 1.0 aycock(3tcl)
All times are GMT -4. The time now is 11:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy