Thread: [cedet-semantic] f90 ampersand
Brought to you by:
zappo
From: Fedor B. <f....@gm...> - 2013-02-10 23:51:46
|
Hi, I noticed the following line in the semantic-f90.el: (modify-syntax-entry ?& " " f90-mode-syntax-table) This causes the & to be considered whitespace. This causes some issues if you cleanup trailing whitespace. Suppose you have the following line: a = 1 + & 1 In this case after a delete-trailing-whitespace, the & will be deleted, which is incorrect. a = 1 + 1 ! Invalid code See http://fortranwiki.org/fortran/show/Continuation+lines for some details. I think that it can be considered an escape character (if placed at the end of a line). Perhaps when placed at the start of the line (after optional whitespace), it can be considered extra whitespace. Cheers, Fedor |
From: Eric M. L. <er...@si...> - 2013-02-14 01:21:36
Attachments:
f90.patch
|
On 02/10/2013 06:51 PM, Fedor Baart wrote: > Hi, > > I noticed the following line in the semantic-f90.el: > > (modify-syntax-entry ?& " " f90-mode-syntax-table) > > This causes the & to be considered whitespace. This causes some issues > if you cleanup trailing whitespace. > Suppose you have the following line: > > a = 1 + & > 1 > > In this case after a delete-trailing-whitespace, the & will be deleted, > which is incorrect. > > a = 1 + > 1 ! Invalid code > > See http://fortranwiki.org/fortran/show/Continuation+lines for some > details. > > I think that it can be considered an escape character (if placed at the > end of a line). Perhaps when placed at the start of the line (after > optional whitespace), it can be considered extra whitespace. Hi Fedor, You are right, there is a problem here. The f90 fortran parser for Semantic explicitly changes the syntax table. I'm guessing it should instead use the lexical syntax modification system instead. I don't use fortran, nor would I know what to do with a fortran file, but the attached patch is my guess as to how to resolve this issue. It compiles and passes unit tests. Perhaps it will help fix your problem? Thanks Eric |
From: David E. <de...@ra...> - 2013-03-20 21:23:24
|
Eric M. Ludlam writes: > On 02/10/2013 06:51 PM, Fedor Baart wrote: >> I noticed the following line in the semantic-f90.el: > >> >> (modify-syntax-entry ?& " " f90-mode-syntax-table) >> >> This causes the & to be considered whitespace. This causes some issues >> if you cleanup trailing whitespace. > You are right, there is a problem here. The f90 fortran parser for > Semantic explicitly changes the syntax table. I'm guessing it should > instead use the lexical syntax modification system instead. I've pushed this change now. -David |
From: David E. <de...@ra...> - 2013-02-20 19:38:55
|
Eric M. Ludlam writes: > On 02/10/2013 06:51 PM, Fedor Baart wrote: >> I noticed the following line in the semantic-f90.el: > >> >> (modify-syntax-entry ?& " " f90-mode-syntax-table) >> >> This causes the & to be considered whitespace. This causes some issues >> if you cleanup trailing whitespace. Yes, I realize now this was a pretty stupid and dangerous idea. > You are right, there is a problem here. The f90 fortran parser for > Semantic explicitly changes the syntax table. I'm guessing it should > instead use the lexical syntax modification system instead. > > I don't use fortran, nor would I know what to do with a fortran file, > but the attached patch is my guess as to how to resolve this issue. > It compiles and passes unit tests. Perhaps it will help fix your > problem? Oh, I didn't know semantic-lex-syntax-modifications. If the unit test passes, that's good. However, as far as I see I forgot to add a test with a continuation line, so Fedor, could you test if those lines are still parsed correctly? -David |
From: Fedor B. <f....@gm...> - 2013-02-20 21:40:36
|
Hi Eric, David, Thanks for the update. I will test it and let you know if it works. Cheers, Fedor On Feb 20, 2013, at 12:38 PM, David Engster wrote: > Eric M. Ludlam writes: >> On 02/10/2013 06:51 PM, Fedor Baart wrote: >>> I noticed the following line in the semantic-f90.el: >> >>> >>> (modify-syntax-entry ?& " " f90-mode-syntax-table) >>> >>> This causes the & to be considered whitespace. This causes some issues >>> if you cleanup trailing whitespace. > > Yes, I realize now this was a pretty stupid and dangerous idea. > >> You are right, there is a problem here. The f90 fortran parser for >> Semantic explicitly changes the syntax table. I'm guessing it should >> instead use the lexical syntax modification system instead. >> >> I don't use fortran, nor would I know what to do with a fortran file, >> but the attached patch is my guess as to how to resolve this issue. >> It compiles and passes unit tests. Perhaps it will help fix your >> problem? > > Oh, I didn't know semantic-lex-syntax-modifications. If the unit test > passes, that's good. However, as far as I see I forgot to add a test > with a continuation line, so Fedor, could you test if those lines are > still parsed correctly? > > -David |
From: David E. <de...@ra...> - 2013-02-21 20:15:19
|
Fedor Baart writes: > Thanks for the update. I will test it and let you know if it works. I'd also be interested in general feedback in how useful the F90 parser is. My Fortran days are pretty much over and I stopped development as it became just good enough for my daily use. The question is whether it is good enough to be merged to Emacs proper. -David |