JavaCC multiline comment in custom NetBeans plugin -
i having problem comments in creating custom file in netbeans. got 2 types of multiline comment types:
- starting
/*
, ending*/
- starting
<!--
, ending-->
more : { "/*": xscript_comment | "<!--": xml_comment }
<xscript_comment> token : { <x_script_comment_end: "*/" > : default }
<xml_comment> token : { <xml_comment_end: "-->" > : default }
<xscript_comment,xml_comment> more : { < ~[] > }
the problem is, both multiline comments throws tokenmgrerror
when write initial part of comment (/*
or <!--
). error occurs when there no ending part , lexer reaches end of file.
my goal create multiline comments works similar other comment types (when initial part written, rest of document comment type text).
please excuse english, not native language.
one way use single regular expression match comments. example /* .. */ multiline comment can matched by
"/*" (("*")* ~["*"])* ("*" ("*")* "/"?)?
here made final "*/" optional. (the best way come sort of regular expression, in experience, convert ndfa re, if know how that.)
another way allow empty string end comment. add these 2 rules.
<xml_comment> token : { <xml_comment_end: "" > : default } <xscript_comment> token : { <x_script_comment_end: "" > : default }
Comments
Post a Comment