Questions tagged [parsing]

Parsing refers to breaking an artifact into its constituent elements and capturing the relationship between those elements. This tag isn't for questions about the self hosted Parse Platform (use the [parse-platform] tag) or parse errors in a particular programming language (use the appropriate language tag instead).

Parsing refers to the action by software of breaking an artifact into its constituent elements and capturing the relationship between those elements.

When the artifact is a stream of arbitrary text, parsing is often used to mean breaking the stream into constituent atoms (called words, tokens or lexemes).

When the artifact is a stream of natural language text, parsing is used to mean breaking the stream into natural language elements (words and punctuation) and discovering the structure of the text as phrases or sentences.

When the artifact is a stream of text corresponding to a computer language (or other formal language), parsing consists of applying any of a variety of parsing algorithms (ad hoc, recursive descent, LL, LR, Packrat, Earley or other) to the source text (often broken into lexemes by another lower level parser called a "lexer") to verify the validity of the source language, and often to construct a parse tree representing the grammar productions used to tile the text.

The term can be applied more generally to analyzing any complex structure such as a binary data file or a graph.

57220 questions
12
votes
3 answers

Java - Parsing strings - String.split() versus Pattern & Matcher

Given a String containing a comma delimited list representing a proper noun & category/description pair, what are the pros & cons of using String.split() versus Pattern & Matcher approach to find a particular proper noun and extract the associated…
IdusOrtus
  • 1,005
  • 1
  • 16
  • 24
12
votes
8 answers

Validate if a string in NSTextField is a valid IP address OR domain name

I have an NSTextField where I am asking a user to input a string that is either in IPv4 format, or a domain name such as www.example.com. Currently, my code is: @IBAction func verifyTarget(sender: NSTextFieldCell) { var txtTarget:…
Matt
  • 2,576
  • 6
  • 34
  • 52
12
votes
5 answers

Any python libs for parsing apache config files?

Any python libs for parsing apache config files or if not python anyone aware of such thing in other languages (perl, php, java, c#)? As i'll be able to rewrite them in python.
daniels
  • 18,416
  • 31
  • 103
  • 173
12
votes
3 answers

Memory leak when using package XML on Windows

Having read Memory leaks parsing XML in r (including linked posts) and this post on R Help and given that some time has passed again, I still think this is an unresolved issue that deserves attention as the XML package is widely used throughout the…
Rappster
  • 12,762
  • 7
  • 71
  • 120
12
votes
3 answers

ANTLR Parse tree modification

I'm using ANTLR4 to create a parse tree for my grammar, what I want to do is modify certain nodes in the tree. This will include removing certain nodes and inserting new ones. The purpose behind this is optimization for the language I am writing. I…
Marc Deleuran
  • 344
  • 2
  • 6
12
votes
2 answers

Python lxml.etree - Is it more effective to parse XML from string or directly from link?

With the lxml.etree python framework, is it more efficient to parse xml directly from a link to an online xml file or is it better to say, use a different framework (such as urllib2), to return a string and then parse from that? Or does it make no…
Isaac
  • 1,371
  • 3
  • 14
  • 36
12
votes
6 answers

Parse Phone Number into component parts

I need a well tested Regular Expression (.net style preferred), or some other simple bit of code that will parse a USA/CA phone number into component parts, so: 3035551234122 1-303-555-1234x122 (303)555-1234-122 1 (303) 555 -1234-122 etc... all…
Tristan Havelick
  • 67,400
  • 20
  • 54
  • 64
12
votes
2 answers

How can I implement #include constructs with Flex and YACC?

During parsing, if I encounter a include token I want to instruct YACC to open the file specified as input and to begin parsing this. Once this parsing is finished, I want to instruct YACC to return to the file and continue parsing directly after…
Gozzy
  • 121
  • 1
  • 3
12
votes
3 answers

Exception to Number Format Exception with "D" and "F"?

I have run into a very strange problem in my code. I have a simple temperature converter where the user enters the temperature in Celsius and, after pressing "Convert", the temperature in Fahrenheit is shown. If the user does not enter something…
ninge
  • 1,592
  • 1
  • 20
  • 40
12
votes
5 answers

Convert from JSONArray to ArrayList - Android

I converted an ArrayList to an JSONArray. How can I convert it back? The final result must be an ArrayList. Thank you in advance. EDIT: This is how I convert the ArrayList to JSONArray: String string_object= new…
stanete
  • 4,062
  • 9
  • 21
  • 30
12
votes
3 answers

Trying to use HTML DOM parser to get main image on Amazon page

I'm trying to use HTML DOM Parser to get the image source of the "main" product image no matter what product page the parser is being pointed to. On every page it seems that that image has the id "landingImage". You would think that this should do…
user3312242
  • 161
  • 5
12
votes
1 answer

boost::spirit composing grammars from grammars

I have figured out how to use spirit -- i.e., I have written a moderately complex grammar. I always take the approach of growing a program -- one subsystem at a time. I've written the data structures for a complex model which has 4 types at the…
Hassan Syed
  • 20,075
  • 11
  • 87
  • 171
12
votes
2 answers

extract class name from tag beautifulsoup python

I have the following HTML code: target img
kegewe
  • 291
  • 1
  • 4
  • 14
12
votes
2 answers

Make Gson throw exception on parsing JSON with duplicated key

I'm parsing simple JSON object with Gson. I want it to throw some error when key name is duplicated. E.g. { a: 2, a: 3 } In my case, Gson parses such JSON and sets a to 3. I want it to throw some exception. I know I can parse JSON as map, and…
amorfis
  • 15,390
  • 15
  • 77
  • 125
12
votes
2 answers

Fast ordered list matching algorithm in Java

I have a list of rules in the form L1 -> (A, B, C) L2 -> (D, E), L3 -> (F, G, A), L4 -> (C, A) ..... This list contains ~30k such rules. I have an input in the form (X, Y, Z) This creates a method List matchRules(input) Which belongs to a…
user498001
  • 244
  • 1
  • 6