Questions tagged [regexp-grammars]

Regexp::Grammars is module to add grammatical parsing features to Perl regexes.

Regexp::Grammars is module to add grammatical parsing features to Perl regexes.

It adds a small number of new regex constructs that can be used within Perl patterns to implement complete recursive-descent parsing.

25 questions
2
votes
1 answer

Using perl's Regexp::Grammars, how do I make a capture dependent on $MATCH?

I've got a token like such: and what I want to happen is for delim2 to capture and be set to the value of delim. When I run this, delim2 is set, but the capture is never done. I think this is an error in my…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
2
votes
2 answers

How do I best do balanced quoting with Perl's Regexp::Grammars?

Using Damian Conway's Regexp::Grammars, I'm trying to match different balanced quoting ('foo', "foo", but not 'foo") mechanisms -- such as parens, quotes, double quotes, and double dollars. This is the code I'm currently using.
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
1
vote
0 answers

How can I define a Regexp::Grammar rule that ignores leading whitespaces?

From the Regexp::Grammars documentation: The difference between a token and a rule is that a token treats any whitespace within it exactly as a normal Perl regular expression would. That is, a sequence of whitespace in a token is ignored if the /x…
Zaid
  • 36,680
  • 16
  • 86
  • 155
1
vote
1 answer

How to Draw a Parse tree contains multiple statements in if condition?

I want to draw a parse tree have multiple statements if the condition is true, and multiple statements if the condition is false. I know how to draw for 1 statement.
1
vote
2 answers

How to echo input text in YACC Grammar?

I am trying to display the whole arithmetic expression from text file and its result, I tried it with file handling option but it is not working. YACC : %{ #include #include #define YYSTYPE int /* the attribute type for…
Nikul Vyas
  • 363
  • 3
  • 7
  • 30
0
votes
0 answers

Log4net highlightjs language grammar

How can I create and use a new syntax highlighter in highlightjs library? I want to define such a grammar for log file in format of log4net c# library but I found no samples. Any help is very welcomed, thanks.
0
votes
1 answer

Second Noun in Python NLTK Grammar RegExParser Not Recognized

I have created the following code to recognize a grammar consisting of a verb folowed by one or more determiners and then one or more nouns. The grammar will not recognize a second noun as being in the grammar (example phrase: "monitoring a parking…
0
votes
1 answer

How to save matching order in %/?

Consider the following rule ( <[token1]> | <[token2]> ) + the output (%/) will be the same for the following inputs input1: input2: This is because the 2nd is appended to the…
Dan
  • 1
  • 1
0
votes
2 answers

Unambiguous grammar for arithmetic expressions with no redundant parenthesis

I am looking for an unambiguous grammar for arithmetic expressions with no redundant parentheses. For example, parentheses are redundant in id+(id*id), but not in (id+id)*id.
Moonwild
  • 171
  • 1
  • 2
  • 9
0
votes
3 answers

Yacc not parsing second expression in txt file

I am trying to parse the set of arithmetic expressions from a .txt file. (one in each line.) I am able to get the proper logic for first line but the parser gives 0 for second expression. Moreover, I want to print the whole string in the output but…
Nikul Vyas
  • 363
  • 3
  • 7
  • 30
1
2