Q: how to parse embedded sections in a different syntax
Thomas Beale <thomas-JBqMug/[email protected]>
| Newsgroups | gmane.comp.lang.eiffel.gobo.general |
|---|---|
| Message-ID | <[email protected]> |
Hi, In the ADL archetype syntax (see http://www.openehr.org/drafts/t_drafts.htm) there are certain times when a piece of a second syntax occurs within the first; it may be at any level of the block structure. Both syntaxes normally occur separately however. An example of embedded sections is visible in the attached archetype - the C_QUANTITY sections with <> delimiters are in the dADL syntax, inside the archetype definition, which is in the cADL syntax - a curly bracket syntax which expresses constraints. I have two separate gobo-based parsers, one for each language. To deal with embedded sections of dADL inside cADL, I wrote rules in the cADL scanner which attempt to match to the end of the embedded block, call the dADL parser, then give the resulting object with a token representing it, to the cADL parse process currently executing. The problem is that it is nearly impossible to correctly match such inline sections properly within the cADL parser, due to the fact that dADL can contain strings whcih can contain any symbols. The proper way to do this would be something like, in the cADL scanner: - match the initial few characters which indicate the beginning of an embedded dADL section - initialise a dADL parser with the string from the cADL buffer at 'position+1' to the end - the dADL parser would scan to the end of the block, which would be somewhere further along in the buffer, and then finish, producing the desired object - the cADL scanner would take the object, generate a token, and 'fast-forward' the scanner to the position in the buffer where the dADL scanner left off, +1. It appears to me that what is needed is a way to tell a scanner to act as if it had matched the next N characters, i.e. just to move up N positions, no questions asked. can this be supported? - thomas beale -- ___________________________________________________________________________________ CTO Ocean Informatics (http://www.OceanInformatics.biz) Hon. Research Fellow, University College London openEHR (http://www.openEHR.org) Archetypes (http://www.oceaninformatics.biz/adl.html) Community Informatics (http://www.deepthought.com.au/ci/rii/Output/mainTOC.html) ---------- archetype adl-test-SOME_TYPE.c_quantity.draft concept [at0000] description author = <"Thomas Beale <t.beale-iKIwAYpEHG/[email protected]>"> submission = < organisation = <"Ocean Informatics"> date = <2003-06-10> > version = <"draft"> status = <"draft"> revision = <"1.1"> description("en") = < purpose = <"Illustrates the use of inline dADL representing C_QUANTITY, including with no magnitude"> use = <""> misuse = <""> > adl_version = <"1.2"> rights = <""> definition SOME_TYPE[at0000] matches { standard_quantity_attr matches { QUANTITY matches { property matches {"temperature"} unit matches {"C"} magnitude matches {|>= 4.0|} } QUANTITY matches { property matches {"temperature"} unit matches {"F"} magnitude matches {|>= 40.0|} } } clinical_quantity_attr_1 matches { C_QUANTITY < property = <"temperature"> list(1) = < units = <"C"> magnitude = <|>=4.0|> > list(2) = < units = <"F"> magnitude = <|>=40.0|> > > } clinical_quantity_attr_2 matches { C_QUANTITY < property = <"temperature"> list(1) = < units = <"C"> > list(2) = < units = <"F"> > > } clinical_quantity_attr_3 matches { C_QUANTITY < > } clinical_quantity_attr_4 cardinality matches {0..*; ordered} matches { C_QUANTITY < > COUNT matches { magnitude matches {|>= 0|} } } clinical_quantity_attr_5 matches { COUNT matches { magnitude matches {|>= 0|} } C_QUANTITY < > } } ontology primary_language = <"en"> languages_available = <"en", ...> term_definitions("en") = < items("at0000") = <text = <"root item">; description = <"xxxx">> > [Non-text portions of this message have been removed] ------------------------ Yahoo! Groups Sponsor --------------------~--> $9.95 domain names from Yahoo!. Register anything. http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/saFolB/TM --------------------------------------------------------------------~-> To Post a message, send it to: [email protected] To Unsubscribe, send a blank message to: [email protected] Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/gobo-eiffel/ <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/