Questions tagged [parse-recdescent]

Parse::RecDescent is a large, object-oriented, well-documented Perl 5 module. It incrementally generates top-down recursive-descent text parsers from simple yacc-like grammar specifications. This module is best for learning about parsing, for designing complex (context-sensitive or dynamic) grammars, or any situation where input is short or performance is no issue. For alternatives, try the "official" successor Regexp::Grammars; or Parse::Yapp or Parse::EYapp.

21 questions
4
votes
1 answer

Disable critic for an entire file - Parse::RecDescent precompiled parser & PerlCritic/Tidyall

I'm trying to remove an error from my sanity-checking [when I push code to my git repo, there's a hook that checks the code with perltidy & critic... using tidyall as the handler.] The specific issue I have is with a pre-compiled Grammar Parser....…
CodeGorilla
  • 811
  • 1
  • 6
  • 21
3
votes
1 answer

Should I use Parse::RecDescent or Regexp::Grammars to extract tables from documents?

I have lots of large plain text documents I wish to parse with perl. Each document has mostly English paragraphs in it, with a couple of plain text marked up tables in each document. I have created a grammar to describe the table structure, but am…
Matthew Lock
  • 13,144
  • 12
  • 92
  • 130
3
votes
2 answers

Parse::RecDescent : Parsing nested arithmetic expression?

Currently I use this to parse Arithmetic expressions : expr : '(' expr ')' | number op expr | variable op expr | number | variable | It works for simple expressions, but can't handle nested…
sten
  • 7,028
  • 9
  • 41
  • 63
3
votes
1 answer

Is Perl's Parse::RecDescent thread safe?

I have a web application that uses a parser created with Parse::RecDescent. A parser object is needed in several parts of the application and since the parser takes quite a bit of memory I have up to now treated the parser object as a singleton.…
oyse
  • 1,023
  • 9
  • 18
3
votes
1 answer

Parse::RecDescent grammar not working as expected

All I managed to get working is STRING, PARAMS, VARIABLE and FUNCNAME There seems to be a problem with FUNCTION, but I just can't see it. use strict; use Parse::RecDescent; $::RD_ERRORS = 1; # Make sure the parser dies when it encounters an…
AlfredoVR
  • 4,069
  • 3
  • 25
  • 33
3
votes
1 answer

Parsing string with nested parentheses using Parse::RecDescent

I'm trying to use Parse::RecDescent make a parser which can parse parenthetical expressions and the unary operator ?. What I have so far is failing when I create the parser because the rule expression is left-recursive: use strict; use warnings; use…
Nate Glenn
  • 6,455
  • 8
  • 52
  • 95
2
votes
1 answer

Interpolating variables in a Parse::RecDescent regex

I'm working on a Parse::RecDescent grammar to read a given human-readable set of rules and then spit out a file that is much easier for a computer to read. One of the tokens is a list of "keywords"; about 26 different keywords. These may change over…
Paul Nathan
  • 39,638
  • 28
  • 112
  • 212
2
votes
2 answers

parsing different files of the same grammar and calculating file to file similarities

I've got a bunch of ACPI Source Language files and I want to calculate file to file similarities between them. I thought of using something like Perl's Parse::RecDescent but I am stuck at: 1) Translating the ACPI Grammar…
719016
  • 9,922
  • 20
  • 85
  • 158
2
votes
1 answer

Whitespace-important parsing with Parse::RecDescent (eg. HAML, Python)

I'm trying to parse HAML (haml.info) with Parse::RecDescent. If you don't know haml, the problem in question is the same as parsing Python - blocks of syntax are grouped by the indentation level. Starting with a very simple subset, I've tried a few…
Mark
  • 1,304
  • 12
  • 22
2
votes
1 answer

Collecting data with Parse::RecDescent

I have a list of strings (30,000+) which are a collection of statements. Logically, Parse::RecDescent is the tool to use to parse the string to gather the data, but I just can't get my head round the construction of the grammar specification. The…
CodeGorilla
  • 811
  • 1
  • 6
  • 21
1
vote
2 answers

Parse::RecDescent - getting information from it

I'm working with the Parse::RecDescent parser in Perl, and I seem to have the most terrible time getting information from it. The information readily available online does not seem to have non-trivial examples. Here is the code: event_function:…
Paul Nathan
  • 39,638
  • 28
  • 112
  • 212
1
vote
1 answer

Why does my Parse::RecDescent give me all these warnings and errors?

Having a lot of pain with the following Perl file parsing code [last reply on PM @http://www.perlmonks.org/index.pl?node_id=754947] below: #!/usr/bin/perl -w use strict; use warnings; #use diagnostics; use Parse::RecDescent; use Data::Dumper; #…
PoorLuzer
  • 24,466
  • 7
  • 31
  • 35
1
vote
1 answer

Parse::RecDescent and operators with quotes

I have something like the following: ((x=2 or y=3 ) and (r=3 and c=3) or (x=5 and g=6)) I defined: Token : /\w \= \d/ operator or|and expression : token operator(s) quoted_expression : "("expression")" query : expression…
jsor
  • 637
  • 4
  • 10
1
vote
1 answer

Parse::RecDescent and Grammar

I defined the following grammar using Parse::RecDescent my $grammar = q{ top : operand equal value { print $item{value} } operand: /\w+/ equal : /\=/ value : { my $value = extract_quotelike($text) ;$return =$value;} }; which i wants it…
jsor
  • 637
  • 4
  • 10
1
vote
0 answers

parsing syntax with Perl

I am using Parse::RecDescent(the below code) to parse something like this this x=2 and y=2 and z=3 why the below code only print x!=2 and not all the above line (i.e x!=2 and y!=2 and z!=3) even the above line is parsed by the below code any idea…
jsor
  • 637
  • 4
  • 10
1
2