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
4 answers

linux bash - Parse date in custom format

I have a date in a the %c format (could be any other) and I need to use it in the date command. %c is NOT the American format. It is the German one because it's a German server. This also did not work properly on an American server. (Locales set to…
BrainStone
  • 3,028
  • 6
  • 32
  • 59
12
votes
5 answers

Parsing and Converting TED Talks JSON Subtitles

This question is related to this other question @ SuperUser. I want to download the TED Talks and the respective subtitles for offline viewing, for instance lets take this short talk by Richard St. John, the high-resolution video download URL is the…
Alix Axel
  • 151,645
  • 95
  • 393
  • 500
12
votes
7 answers

Parsing iw wlan0 scan output

I wrote wlan manager script to handle open/ad-hoc/wep/wpa2 networks. Now im trying to parse iw wlan0 scan output to get nice scan feature to my script. My goal is to get output like this : SSID channel signal encryption wlan-ap 6…
Ari Malinen
  • 576
  • 2
  • 6
  • 20
12
votes
3 answers

parse query string with urllib in Python 2.4

Using Python2.4.5 (don't ask!) I want to parse a query string and get a dict in return. Do I have to do it "manually" like follows? >>> qs = 'first=1&second=4&third=3' >>> d = dict([x.split("=") for x in qs.split("&")]) >>> d {'second': '4',…
Johannes Charra
  • 29,455
  • 6
  • 42
  • 51
12
votes
2 answers

Python 3 How to get string between two points using regex?

How to get the string between two points using regex or any other library in Python 3? For eg: Blah blah ABC the string to be retrieved XYZ Blah Blah ABC and XYZ are variables which denote the start and end of the string which I have to retrieve.
sgp
  • 1,738
  • 6
  • 17
  • 31
12
votes
7 answers

How to parse a string and return a nested array?

I want a Python function that takes a string, and returns an array, where each item in the array is either a character, or another array of this kind. Nested arrays are marked in the input string by starting with '(' and ending with ')'. Thus, the…
Tespa42
  • 567
  • 4
  • 12
12
votes
4 answers

Converting an XML-document to a dictionary

I do not need to edit any XML-file or anything, this is only for reading and parsing. I want to be able to handle the XML-document as a dictionary, like: username = doc["username"];, but I can't find out how to "convert" the document. I've also…
Phoexo
  • 2,485
  • 4
  • 25
  • 33
12
votes
3 answers

json array parsing in c

i am trying to parse a json array,i am facing problem. My array is like this: configure: { "id": 4, "userId": 107, "deviceMacAddress": "00:06:66:30:02:3C", "medication": [{ "id": 11, "version": 18, "name": "name1", "unit":…
lenin T.mohan
  • 135
  • 1
  • 1
  • 4
12
votes
2 answers

unary minus in shunting yard expression parser

here is my expression parser using shunting-yard algorithm it work well as expected except in one situation , when I use unary minus like in -2*3 it wont work (I think it shouldn't because I didn't find anything in algorithm to handle this ) is…
PedramH
  • 123
  • 1
  • 8
12
votes
2 answers

How to write a recursive descent parser from scratch?

As a purely academic exercise, I'm writing a recursive descent parser from scratch -- without using ANTLR or lex/yacc. I'm writing a simple function which converts math expressions into their equivalent AST. I have the following: // grammar type…
Juliet
  • 80,494
  • 45
  • 196
  • 228
12
votes
4 answers

POSIX sh EBNF grammar

Is there an existing POSIX sh grammar available or do I have to figure it out from the specification directly? Note I'm not so much interested in a pure sh; an extended but conformant sh is also more than fine for my purposes.
rubenvb
  • 74,642
  • 33
  • 187
  • 332
12
votes
7 answers

What libraries are available for parsing c++ to extract type information

I'm looking for a way to parse c++ code to retrieve some basic information about classes. I don't actually need much information from the code itself, but I do need it to handle things like macros and templates. In short, I want to extract the…
Grant Peters
  • 7,691
  • 3
  • 45
  • 57
12
votes
2 answers

16 bit hex string to signed int in Java

I have a string in Java representing a signed 16-bit value in HEX. This string can by anything from "0000" to "FFFF". I use Integer.parseInt("FFFF",16) to convert it to an integer. However, this returns an unsigned value (65535). I want it to return…
dimme
  • 4,393
  • 4
  • 31
  • 51
12
votes
4 answers

how to parse http request in c++

I'm trying to write a small c++ webserver which handles GET, POST, HEAD requests. My problem is I don't know how to parse the headers, message body, etc. It's listening on the socket, I can even write stuff out to the browser just fine, but I'm…
John Smith
  • 2,291
  • 4
  • 22
  • 33
12
votes
4 answers

IP Address Parser in Javascript

Looking for a good IP address parser for Javascript. Ideally, it could take in an IP address as a string, then return an object containing all of the pieces of the IP Address, including the port. Thanks!
Chris Dutrow
  • 48,402
  • 65
  • 188
  • 258
1 2 3
99
100