Comments on: Using JFlex http://hackerdan.com/programing/using-jflex/ Dan's Blog Sat, 21 Oct 2017 18:35:44 +0000 http://wordpress.org/?v=2.2.1 By: George http://hackerdan.com/programing/using-jflex/#comment-285 George Wed, 07 Mar 2012 16:33:27 +0000 http://hackerdan.com/programing/using-jflex/#comment-285 Hey, I had a doubt with jflex. I am trying to develop a scanner for java, using jflex. The scanner is working fine. But the problem is when I see comments jflex does not leave as many lines as the comment took, instead it leaves just a single line on seeing a comment. But I need jflex to see the comments and leave as many lines as the comments took. The code I used to identify comments is - LineTerminator = \r|\n|\r\n Comment = {TraditionalComment} | {EndOfLineComment} | {DocumentationComment} TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/" EndOfLineComment = "//" {InputCharacter}* {LineTerminator} DocumentationComment = "/**" {CommentContent} "*"+ "/" CommentContent = ( [^*] | \*+ [^/*] )* and then when i see a white space I just ignore it. {Comment} { /*Ignore */ } But then the output is not like what I expect for eg - If i give the input int main() { /* * * Have a pleasant day * * */ } I get the output int main() { } I dont get the 6 lines in between. Thanks Hey,
I had a doubt with jflex.
I am trying to develop a scanner for java, using jflex. The scanner is working fine. But the problem is when I see comments jflex does not leave as many lines as the comment took, instead it leaves just a single line on seeing a comment. But I need jflex to see the comments and leave as many lines as the comments took. The code I used to identify comments is -

LineTerminator = \r|\n|\r\n
Comment = {TraditionalComment} | {EndOfLineComment} | {DocumentationComment}

TraditionalComment = “/*” [^*] ~”*/” | “/*” “*”+ “/”
EndOfLineComment = “//” {InputCharacter}* {LineTerminator}
DocumentationComment = “/**” {CommentContent} “*”+ “/”
CommentContent = ( [^*] | \*+ [^/*] )*

and then when i see a white space I just ignore it.
{Comment} { /*Ignore */ }

But then the output is not like what I expect for eg - If i give the input
int main()
{
/*
*
* Have a pleasant day
*
*
*/
}

I get the output

int main()
{

}

I dont get the 6 lines in between. Thanks

]]>
By: Estuardolh http://hackerdan.com/programing/using-jflex/#comment-283 Estuardolh Tue, 14 Feb 2012 09:53:21 +0000 http://hackerdan.com/programing/using-jflex/#comment-283 nice link of resource for using Jflex & cup, thaks! nice link of resource for using Jflex & cup, thaks!

]]>
By: Andrés Portillo http://hackerdan.com/programing/using-jflex/#comment-281 Andrés Portillo Thu, 05 Jan 2012 18:27:38 +0000 http://hackerdan.com/programing/using-jflex/#comment-281 Hey thanks for writing this, I was wondering though if you could send me those .java files, i'm trying to understand Jflex but its been so far quite difficult to get any example on how use it, I have to do a kind of Interpreter for an assingment at the Uni and have really no Idea where I should start at, I would really appreciate it if you would send me something I can start with. Andrés Portillo Hey thanks for writing this, I was wondering though if you could send me those .java files, i’m trying to understand Jflex but its been so far quite difficult to get any example on how use it, I have to do a kind of Interpreter for an assingment at the Uni and have really no Idea where I should start at, I would really appreciate it if you would send me something I can start with.

Andrés Portillo

]]>
By: HackerDan.com » Using Java CUP http://hackerdan.com/programing/using-jflex/#comment-103 HackerDan.com » Using Java CUP Tue, 16 Mar 2010 05:24:53 +0000 http://hackerdan.com/programing/using-jflex/#comment-103 [...] and Setup It is assumed that you have java and jflex (see http://hackerdan.com/programing/using-jflex/) installed and [...] […] and Setup It is assumed that you have java and jflex (see http://hackerdan.com/programing/using-jflex/) installed and […]

]]>