Parsing an indented structure
Jonathan Stott
jonathan.st... at gmail.com
Wed Sep 19 10:43:45 UTC 2007
Hi
I'm quite new to ragel, and I'm using it to parse some input files for
a program, so I can have human readable files, but still parse them
easily.
I started with a syntax like:
# some interesting conditions
ina: 2.1
ito: 0.4 #X et al, 2007
with various tokens accepted, and the double stored in an appropriate
variable. I'd now like to extend the syntax to allow some more
varaibles to be set, and so for organisations sake (and to seperate
things into logical divisions, I'd like to be able to support a syntax
like:
x: 10
y: 15
currents:
ina: 2.1
This works okay. I have the main scanner fcall the 'current' scanner
when the currents token is parsed, and it starts to parse current
tokens, which is fine until I follow the currents section with another
token, which then causes problems. So I'd like to indent the current
tokens by two spaces, like:
y: 15
currents:
ina: 1.01
ito: 1.2
But I'm unsure how how to handle the indent or snapping back from the
indented scanner to the main scanner. Advice and pointers would be
appreciated.
Regards,
Jonathan
More information about the ragel-users
mailing list