For future reference: There was a short discussion on the instaparse list.
Summary: * The two approaches outlined earlier are the two possibilities to solve the problem at hand. * Instaparse can take a data structure representation of a grammar (combinators) which could be used for the two pass approach (while I thought I'd have to create the second grammar with string operations). * I'll stick to separating parsing and validation for now. Question answered, case closed, thanks! Cheers, stefan On Wednesday, June 25, 2014 11:31:21 PM UTC+2, Stefan Kamphausen wrote: > > Hi, > > > first of all, please excuse this cross-post. I tried to get an answer on > the instaparse list first, but it does not seem to reach so many instaparse > users. > > > Unfortunately I do not know the correct name for the problem I face, hence > the rather vague subject. > > I am trying to parse a file format with Instaparse in which the early > parts define the stuff allowed later in the file. > > E.g. here is a declaration of allowed symbols: > > # single chars or strings > symbols: a b c "str" > > Later, the file contains declarations of enumerations of the form > > enum-name: list of allowed values separated by whitespace > > Further down in the file, I will find strings which are comprised of the > symbols declared above, e.g. > > "aabcbc&str;a" > > and I will see structures that use the enumerations > > StructName(enum-name=separated) > > How would you approach this? > > * Write a very loose grammar which accepts basically all unicode chars in > the symbol strings and validate in a separate step? Similarly accept all > values in the structures and later validate against the enumerations? > * Two pass parsing which first reads the declarative stuff and then builds > a second grammar programmatically to parse the rest? > * Is there a way to fill tables of allowed symbols during the parsing? > * Something completely different? > > With that question out of the way, thanks for instaparse which is a > pleasure to use while I am converting my 1400 LOClojureCode hand-rolled > parser. > > > Kind regards, > Stefan > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
