Twistpad Carthago Software forums / Twistpad /  

 Syntax Files : Adding outline for FORTRAN

 
SolarAngel
Member
#1 | Posted: 2 Jan 2007 16:04 
I was talking to my friend that I used to edit Javascript file long 6000 lines and more last 3 months only with Textpad that recognises syntax and nothing more, he told me I was crazy ;)

But talk went to Twistpad and outline where I can compact blocks of code, he wanted to see it - so I've gave him link for download bla blah, but in FORTRAN case there is no outline.

So as I wanted to help him out tried to write new syntax file, but there are problems like :
[code]
DO ....
DO ....
CONTINUE

c.. -OR-

DO ...
DO ..
ENDDO
[/code]

well I learn basics of FORTRAN in 10 min ;)

ok now syntax file finds first DO and marks block till first CONTINUE, but when he encounters second DO he searches for seconds CONTINUE and he finds it later in code if exist even if there is one more DO before that CONTINUE and so on, so it renders compacting block of DO almost immposible for me to figure it out how to write proper syntax file.
it is simlar with ENDDO

All I have managed to do so far is THEN -> ENDIF, SUBROUTINE -> END, not even sure if it works in all cases (not yet custom to fortran syntax fully, I am using knowlidge of basic to write syntax file)

so my question is have someone managed to write proper syntax file for FORTRAN (with outline compact) -or- have concluded it is immposible?

Andre Santos
Carthago
Moderator
#2 | Posted: 2 Jan 2007 16:55 
I'll have to have a look.

can you post here your modified SDF file for fortran?
And a sample of fortran would be nice to make tests, since I don't really use it.

Thanks,

André Santos
Carthago Software Support
http://www.carthagosoft.net

SolarAngel
Member
#3 | Posted: 4 Jan 2007 10:16 
blah you don't allow your own program extenssion ;)

I've edited file since but with no success
SDF Source:
_______________________________
;Fortran adicional Syntax highlight Script for Twistpad
;1998 - 2006 (C) Carthago Software

[::Header::]
SyntaxName=Fortran
Extensions=F
Spelling=0
SpellingContexts=1;2
CommentChar=!

[Comment1]
Type=StartStop
Context=1
Scope=0
Priority=10
WholeWordOnly=1
First=c
Last=
Background=Default
Foreground=008000
italic=0

[Comment2]
Type=StartStop
Context=1
Scope=0
Priority=10
WholeWordOnly=1
First=!
Last=
Background=Default
Foreground=008000
italic=0

[String1]
Type=StartStop
Context=2
Scope=0
Priority=10
WholeWordOnly=0
First="
Last="
Background=Default
Foreground=800000

[String2]
Type=StartStop
Context=2
Scope=0
Priority=10
WholeWordOnly=0
First='
Last='
Background=Default
Foreground=800000

[blockIF]
Type=StartStop
Context=4
Scope=0
Priority=4
WholeWordOnly=1
First=THEN
Last=ENDIF
Background=Default
Foreground=Default
Outline=1
Smart=1

[blockSubroutine]
Type=StartStop
Context=4
Scope=0
Priority=3
WholeWordOnly=1
First=SUBROUTINE
Last=END
Background=Default
Foreground=Default
Outline=1
Smart=1

[blockDoEnddo]
Type=StartStop
Context=4
Scope=0
Priority=2
WholeWordOnly=1
First=DO
Last=ENDDO
Background=Default
Foreground=808000
Outline=1

[blockDoContinue]
Type=StartStop
Context=4
Scope=0
Priority=3
WholeWordOnly=1
First=DO
Last=CONTINUE
Background=Default
Foreground=8080FF
Outline=1
Smart=1

[Statements Keyword]
Type=keyword
Context=101
Scope=0
Priority=6
WholeWordOnly=1
Keyword1=ALIAS;ALLOCATE;ASSIGN;AUTOMATIC;BACKSPACE;BLOCK;BYTE;C;CALL;C ASE;CHARACTER;CLOSE;COMMON;COMPLEX;CONTINUE;CYCLE;DATA;DEALLOCATE;DIME NSION;DO;DOUBLE;ELSE;END;ENDFILE;ENTRY;EQUIVALENCE;EXIT;EXTERNAL;FORMA T;FUNCTION;GOTO;IF;IMPLICIT;INCLUDE;INQUIRE;INTEGER;INTRINSIC;LOCKING; LOGICAL;MAP;NAMELIST;OPEN;PARAMETER;PAUSE;PRECISION;PRINT;PROGRAM;READ ;REAL;RECORD;REFERENCE;RETURN;REWIND;SAVE;SELECT;STDCALL;STOP;STRUCTUR E;SUBROUTINE;TO;UNION;VALUE;VARYING;WHILE;WRITE
Keyword2=ATTRIBUTES;DECLARE;DEFINE;DEFINED;ELSE;ELSEIF;ENDIF;FIXED;FOR MLINESIZE;FREEFORM;IDENT;IF;INTEGER;MESSAGE;NODECLARE;NOFREEFORM;NOSTR ICT;OBJCOMMENT;OPTIONS;PACK;PSECT;REAL;STRICT;SUBTITLE;THEN;TITLE;UNDE FINE
keyword3=.AND.;.EQ.;.EQV.;.FALSE.;.GT.;.LT.;.NEQV.;.NOT.;.OR.;.TRUE.;. XOR
Background=Default
Foreground=0000FF
Bold=0
________________________________________________

fortran example friend sent me over MSN maybe even outof order I have downloaded fortrans syntax file but since I can't make it work for DO ENDDO CONTINUE problem I haven't read it

this is example I'was testing, eg: there should be indent around 10 or 8 characters (fortran biz), this example renders problem with keywords mentioned above.
_________________________________________________
subroutine allcalc(IWSE,iwsg)
include 'eq_par.inc'
double precision aval
integer iwse ,iwsg ,lokp,lok,ier
logical SG2ERR
c.. calculate present value for all conditions; copied from QSLOAD
C..FIND PRESENT EQUILIBRIUM
LOKP=IQPREQ(IWSE)
IF(SG2ERR(IER))GOTO 900
C..CALCULATE CONDITION VALUES (AND STORE IN THE CONDITION RECORDS.)
LOK=LOKP+M

LOKP=IQPREQ(IWSE)
IF(SG2ERR(IER))GOTO 900
C..CALCULATE CONDITION VALUES (AND STORE IN THE CONDITION RECORDS.)
LOK=LOKP+MBEQRT
300 LOK=IWSE(LOK)
IF(LOK.EQ.0)GOTO 310
IF(IWSE(LOK+MJEQKD).NE.0)THEN
CALL QCNCAL(AVAL,LOK,IWSE,IWSG)
WRITE(*,*) 'CONDITION ',lok,AVAL
c do not prescribe!
CALL STORR1(IWSE(IWSE(LOK+MJPL1)),AVAL)
ENDIF
GOTO 300
310 CONTINUE

DO 40 I=1,NAX
DO 40 j=1,10
I=I+j
ENDDO
40 CONTINUE

C.. CONTINUE
do

continue
write(*,*)
900 return
end
____________________________________________

OFFTOPIC releated to syntax files only:

have this in my defined javascript.sdf file:
_______________
[::Header::]
SyntaxName=Java Script (Dark BG)
Extensions=js
CaseSensitive=1
Spelling=0
SpellingContexts=1;2
CommentChar=//
escapeChar=\

;... string problem

[Quote2]
Type=StartStop
Context=3
Scope=0
Priority=10
WholeWordOnly=0
First='
Last='
Background=Default
Foreground=FFFF00
escapeChar=\

; and brackets problem

[Brackets]
Type=StartStop
Context=4
Scope=0
Priority=4
WholeWordOnly=0
First={
Last=}
Background=Default
Foreground=FFFFFF
escapeChar=\
Outline=1
Smart=1

[ssBrackets]
Type=keyword
Context=1000
Scope=0
Priority=6
WholeWordOnly=0
Keyword1=(;);[;];{;};
Background=Default
Foreground=FF0000
Bold=0
________________________

now string problem is manifested whenever I have two ['] chars next to each other it is like first escapes second eg: '<sometext >''<now this should be text but it is rendered like code>'
but if I enter any char between those two chars it is rendered corectly eg: '<sometext>'+'<now this should be text but it is rendered like code>'
IMG:


blah I've tried to make those bugs with brackets again but with no success, can't remmember exactly what have I've done. But one is it renders brackets in comments, second makes error in twistpad to not recognize brackets anymore, and third makes editor unuable (but only after error something releated to outlines).
could this be releated to syntax above ?

//SolarAngel

SolarAngel
Member
#4 | Posted: 4 Jan 2007 10:31 
releated to strings:

Andre Santos
Carthago
Moderator
#5 | Posted: 4 Jan 2007 18:03 
Hi,

Tested your Fortran Syntax and in fact that Do .. EndDo and Do .. Continue is a problem. There is no possibility to have outline for two start-stops that start the same way. It will always give priority to the first definition, in this case, Do .. endDo. So you can only have a Do outlined with either EndDo or Continue, not both.

Regarding your problem with the ' chars in the JS syntax, I managed to reproduce this, and his ended a bug. if you reopen the file it will show properly. and it only happens when it's inside an outline. there is no workaround for this at the moment.

Thanks

André Santos
Carthago Software Support
http://www.carthagosoft.net

SolarAngel
Member
#6 | Posted: 5 Jan 2007 11:47 
Andre Santos wrote:
Regarding your problem with the ' chars in the JS syntax, I managed to reproduce this, and his ended a bug. if you reopen the file it will show properly. and it only happens when it's inside an outline. there is no workaround for this at the moment.


well I've noticed that I don't need to reopen file only need to go one line up, and press return and backspace and it all looks ok.
think you have small problem while parsing edit line syntax, and when that same line parsed with the normal parsing eg: edit line somewhere else above that line, everything looks ok.
it looks like you are using wrong escape char for processing edit line, so error might be somewhere in loading escape char for edit line from syntax file, but I might be wrong - not sure how you've orginized source.

hope it helps you to find error in code ;)

Twistpad Carthago Software forums / Twistpad /
 Syntax Files : Adding outline for FORTRAN

Your Reply Click this icon to move up to the quoted message


 
Only registered users are allowed to post here. Please, enter your username/password details upon posting a message, or register first.

 

  Powered By minibb