Hi,
I have a case of a language that uses a line based syntax.
Here is an example: ' label1 => any kind of text on many lines label2 => more text on many lines label3 => more text'
This should get 3 key-value pairs.
My current solution goes like this: key := #newline asParser , ('=>' asParser / #newline asParser) negate star , '=>' asParser. p := (key trimBlanks, key negate star flatten) star.
However, this is quite ugly. One idea to make it simpler would be to have a parser for the beginning of the line. What do you think?
Cheers, Doru
-- www.tudorgirba.com
"When people care, great things can happen."
Hi Doru,
The package PetitRegex in PPRegexParser class>>initializeEscapeMap defines various parsers that do not consume anything but that check for certain conditions (beginning/end of input/word). In a similar way conditions for lines (whatever your definition of a line is) could be built.
Lukas
On 26 October 2010 14:53, Tudor Girba tudor.girba@gmail.com wrote:
Hi,
I have a case of a language that uses a line based syntax.
Here is an example: ' label1 => any kind of text on many lines label2 => more text on many lines label3 => more text'
This should get 3 key-value pairs.
My current solution goes like this: key := #newline asParser , ('=>' asParser / #newline asParser) negate star , '=>' asParser. p := (key trimBlanks, key negate star flatten) star.
However, this is quite ugly. One idea to make it simpler would be to have a parser for the beginning of the line. What do you think?
Cheers, Doru
-- www.tudorgirba.com
"When people care, great things can happen."
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
Ahh, the productions of PPRegexParser>>beginOfLineAtom and PPRegexParser>>endOfLineAtom return examples for parsers you are interested in.
Lukas
On 26 October 2010 17:43, Lukas Renggli renggli@gmail.com wrote:
Hi Doru,
The package PetitRegex in PPRegexParser class>>initializeEscapeMap defines various parsers that do not consume anything but that check for certain conditions (beginning/end of input/word). In a similar way conditions for lines (whatever your definition of a line is) could be built.
Lukas
On 26 October 2010 14:53, Tudor Girba tudor.girba@gmail.com wrote:
Hi,
I have a case of a language that uses a line based syntax.
Here is an example: ' label1 => any kind of text on many lines label2 => more text on many lines label3 => more text'
This should get 3 key-value pairs.
My current solution goes like this: key := #newline asParser , ('=>' asParser / #newline asParser) negate star , '=>' asParser. p := (key trimBlanks, key negate star flatten) star.
However, this is quite ugly. One idea to make it simpler would be to have a parser for the beginning of the line. What do you think?
Cheers, Doru
-- www.tudorgirba.com
"When people care, great things can happen."
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- Lukas Renggli www.lukas-renggli.ch
Thanks, that sounds good.
Doru
On 26 Oct 2010, at 17:48, Lukas Renggli wrote:
Ahh, the productions of PPRegexParser>>beginOfLineAtom and PPRegexParser>>endOfLineAtom return examples for parsers you are interested in.
Lukas
On 26 October 2010 17:43, Lukas Renggli renggli@gmail.com wrote:
Hi Doru,
The package PetitRegex in PPRegexParser class>>initializeEscapeMap defines various parsers that do not consume anything but that check for certain conditions (beginning/end of input/word). In a similar way conditions for lines (whatever your definition of a line is) could be built.
Lukas
On 26 October 2010 14:53, Tudor Girba tudor.girba@gmail.com wrote:
Hi,
I have a case of a language that uses a line based syntax.
Here is an example: ' label1 => any kind of text on many lines label2 => more text on many lines label3 => more text'
This should get 3 key-value pairs.
My current solution goes like this: key := #newline asParser , ('=>' asParser / #newline asParser) negate star , '=>' asParser. p := (key trimBlanks, key negate star flatten) star.
However, this is quite ugly. One idea to make it simpler would be to have a parser for the beginning of the line. What do you think?
Cheers, Doru
-- www.tudorgirba.com
"When people care, great things can happen."
Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- Lukas Renggli www.lukas-renggli.ch
-- Lukas Renggli www.lukas-renggli.ch _______________________________________________ Moose-dev mailing list Moose-dev@iam.unibe.ch https://www.iam.unibe.ch/mailman/listinfo/moose-dev
-- www.tudorgirba.com
"Relationships are of two kinds: those we choose and those that happen. They both matter."