I'm trying to write a grammar so I can parse a specific type of input file. I've started with the most basic grammar possible, but guile
just about melts my computer when trying to match a pattern with this grammar.
I'm wondering if there is something that is ambiguous about my grammar? Here is a sample input I'm trying to parse:
input.txt
[HELLO]
var = 123
[]
And here is my current script:
(use-modules (ice-9 peg))
(use-modules (ice-9 textual-ports))
(define *input*
(call-with-input-file
"test.txt" get-string-all))
(define-peg-string-patterns
"block <-- block_header param block_closer
block_header <-- LB text RB SP
block_closer <-- LB RB SP
param <-- text SP EQ param_v SP
param_v <-- NUM
text <-- [a-zA-Z]+
NUM <-- [0-9]+
EQ < '='
LB < '['
RB < ']'
SP < [ \t\n]*")
(peg:tree (match-pattern block *input*))
The jist is that a file is made up of blocks
that contain variables. (The next step is adding nested blocks to this grammar.)
Is there something particularly wrong with this grammar?