I have a mysql schema like below:
data: {
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(10) DEFAULT '' COMMENT 'the name',
`content` text COMMENT 'something',
}
now I want to extract some info from it: the filed name, type and comment if any. See below:
["id" "int" "" "name" "varchar" "the name" "content" "text" "something" ]
My code is:
parse data [
any [
thru {`} copy field to {`} {`}
thru some space copy field-type to [ {(} | space]
(comm: "")
opt [ thru {COMMENT} thru some space thru {'} copy comm to {'}]
(repend temp field repend temp field-type either comm [ repend temp comm ][ repend temp ""])
]
]
but I get something like this:
["id" "int" "the name" "content" "text" "something"]
I know the line opt ..
is not right.
I want express if found COMMENT
key word first, then extract the comment info; if found lf first, then continue the next loop. But I don't know how to express it. Any one can help?
["id" "int" "the name" "name" "varchar" "the name" "content" "text" "something"]
. It seems that in the first loop, it runs the first alternative but failed, and then switch to the next. After I add some debug info like[thru {COMMENT} some space thru {'} copy comm to {'} {,} (print 1) | thru {,} (print 2)]
, only2
was output. Why this? – Reagent