Recent

Author Topic: "vintage" BASIC highlighter  (Read 15885 times)

Ladywasky

  • New Member
  • *
  • Posts: 20
Re: "vintage" BASIC highlighter
« Reply #15 on: October 20, 2018, 01:45:31 pm »
Update :
- Forked SynFacilUtils :
https://github.com/DJChloe/SynFacilUtils
- Pulled a request to main Repo (bug fix in editor that prevent to compile + 8Bit BASIC compatibility) :
https://github.com/t-edson/SynFacilUtils/pull/1

Edson

  • Hero Member
  • *****
  • Posts: 1296
Re: "vintage" BASIC highlighter
« Reply #16 on: October 21, 2018, 07:08:29 pm »
Excelent work.  :) Old Basic is some special in its syntax.

I would like to see a highlighter for the Commodore 64, too.

About the changes to SynFacilSyn, I having problems using the highlighter with the new modifications (I'm using the SynFacilBASICEnabled.zip.), when processing the BASIC text.  The main form never show. It's something like a infinite loop.

Maybe there is another way to implement a highlighter for this BASIC. I will think some alternative solution.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Ladywasky

  • New Member
  • *
  • Posts: 20
Re: "vintage" BASIC highlighter
« Reply #17 on: October 21, 2018, 07:27:00 pm »
Hey Edson,

Infinite Loop ?
My mod should not have any impact, I compile and use your "Editor Muestra", straight as it is, without any problem, and no other modification than those I put in my files :

https://github.com/DJChloe/SynFacilUtils/tree/1.21/Editor_Muestra

No infinite loop here.


Ladywasky

  • New Member
  • *
  • Posts: 20
Re: "vintage" BASIC highlighter
« Reply #18 on: October 21, 2018, 07:38:46 pm »
OK, I reproduced it : when your highlighter is set to Oric Basic  and that you load a non BASIC file. I can see on my side what can be done.

Ladywasky

  • New Member
  • *
  • Posts: 20
Re: "vintage" BASIC highlighter
« Reply #19 on: October 21, 2018, 08:29:46 pm »
OK ! Solved !
See attached files.
I push them on Github just right after on.

Edson

  • Hero Member
  • *****
  • Posts: 1296
Re: "vintage" BASIC highlighter
« Reply #20 on: October 22, 2018, 07:04:45 am »
Hi. I have updated SynFacilSyn to include access to the parameter "TokPos" in definition of tokens by content.

Now  It's possible to process directly the line number of the BASIC instructions.

Just need to change the definiton of numbers to:

Code: XML  [Select][+][-]
  1.  <!--Number or Line number-->
  2.  <Token CharsStart="0..9" Attribute='NUMBER'>
  3.    <Regex Text="[0-9]*" />
  4.    <Regex Text="TokPos=1" ifTrue="move(+7)" atTrue="Comment" ifFalse="next"/>
  5.    <Regex Text="TokPos=2" ifTrue="move(+6)" atTrue="Comment" ifFalse="next"/>
  6.    <Regex Text="[\.]" IfFalse='move(+2)' />
  7.    <Regex Text="[0-9]+"/>
  8.    <Regex Text="[eE]" />
  9.    <Regex Text="[+-]?" />
  10.    <Regex Text="[0-9]+" IfTrue="exit"/>
  11.    <!--Line number-->
  12.    <Regex Text="[ ]+"/>
  13.    <Regex Text="[0-9]*" />
  14.  </Token>

I think this is a more general solution and can be adapted to other BASIC dialects.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Ladywasky

  • New Member
  • *
  • Posts: 20
Re: "vintage" BASIC highlighter
« Reply #21 on: October 22, 2018, 03:47:56 pm »
hum, hello Edson,
You will face up a problem with this method.

In fact, Modern "regular" languages where designed to deal with two things in mind  :
1) The obvious : Line numbering was a pain in the "XXX" for coding. Open a any Magazine from the 80s and count all the listings dealing with "RENUM" routines: they are Legion ! But the numbering was essential in order to dis tinguish an immediate command from a line insert/editing after the "Ready" prompt :
Code: [Select]
Ready
PRINT "Hello"

Ready
10 PRINT "Hello"

2) Old school "Darmouth like" BASIC languages where designed for memory compactness (white spaces are just code formatters and are meaningfull to the interpreter) and not modular at all (procedure/functions do not exist)  to the point that for that for certain BASIC Dialect "GO TO" and "GO SUB" where just the same that "GOTO" and "GOSUB" or "P R I N T" was meaning "PRINT" (not for the ORIC whose BASIC interpreter did allow "token splitting" in edition mode just for the line numbers.)
"GO TO" example : https://en.wikipedia.org/wiki/BASIC#Unstructured_BASIC (line 70, the wikipedia highlighter can't handle it properly !  :D)
When typing :
Code: [Select]
Ready
    2 10 5PRINT"Hello"
The interpreter was removin the first whitespace character until a non number or non white character was meet, was recombining the numbers and was adding a space so that the listing was rewritten like this :
Code: [Select]
Ready
LIST
2105 PRINT"Hello"
By the way, your solution fails here... mine is compliant.
I have tried to fiddle with this without any success :
Code: Pascal  [Select][+][-]
  1.  <!--Line number-->
  2.    <Regex Text="[ ]*"/>
  3.    <Regex Text="[0-9\s]+" />
An highlighter for BASIC should Allow the same silly editing "facility", you understood it.
In fact, I was thinking about 2 mechanism for editing :
- when loading a file : recombining the line numbering like the interpretor of the Oric is doing, but it is a problem if you load a pascal file or a FORTRAN one, with the Oric BASIC highlighter loaded.
- from within edit windows : ignoring any spaces until a non number is entered (a kind of "dynamic" completion code"). Elegant if your highlighter deals only with BASIC, Not a good idea if you load a C file.

3) modern languages were also designed for "Context free grammars", bit old school BASIC is contextual and sometimes it is impossible to build a valid BNF grammar.
For instance, a few years ago I tried to write a parser for the Oric with Gold Parser, it was easy to do it until one point. In order to load from or save to a tape, the BASIC commands where CLOAD and CSAVE :
Code: [Select]
CLOAD "filename"(,S)
CLOAD ""(,S)
CLOAD "filename",J,(,S)
CLOAD "filename",V,(,S)
CLOAD "filename",V,(,S)

CSAVE "filename"(,AUTO)(,S)
CSAVE "filename",A adr,E adr(,S)

J=join (=merge) filename to existing BASIC listing in memory
V=verify filename on tape
AUTO=run the program AUTOmatically when using CLOAD
S=Program in "slow mode" on tape. Safer when loading back, but you were waiting 10 minutes instead of 3 in order to wait for your program to be loaded on the Oric !

The J,V or S options is totally contextual and impossible to handle with LLAR or LL parsers :they impose to be recognised as standard float variables !

It's the same problem with the strings in DATA that are allowed to not be quoted (see above).

Of course, in cross development, and emulators, we are building digitalized tapes or wav files and the ,S will not be used anymore (fiability of the signal is better than real tapes/tape recorders), and we can, now, live with it. But if we want to stick to the original BASIC language we face up some other problem with modern highlighter that can handle only Context free grammars. And that's why Notepad++ does not have a single highlighter for old school BASIC (not even one !).

All of that to say that the only tokpos exposition seems (to me) not the best choice.
Ideally, the use of grammar file should permit to redirect  to an event handler in code or a script file.
Something like that, maybe :
Code: XML  [Select][+][-]
  1. <Regex Text="DATA" ifTrueCustomEvent="1"/>
Code: Pascal  [Select][+][-]
  1. TSynFacilSyn1.OnCustom1:=CustomTreatment1;
  2. procedure CustomTreatment1(TokPos:integer;TokString:string);
  3. begin
  4.   if TokString='DATA' then
  5.   begin
  6.      ...
  7.   end;
  8. end;


« Last Edit: October 22, 2018, 03:57:27 pm by Ladywasky »

BSaidus

  • Hero Member
  • *****
  • Posts: 538
  • lazarus 1.8.4 Win8.1 / cross FreeBSD
Re: "vintage" BASIC highlighter
« Reply #22 on: October 22, 2018, 04:22:37 pm »
I would like to see highlighter for MAkeFile  ::)
lazarus 1.8.4 Win8.1 / cross FreeBSD
dhukmucmur vernadh!

Ladywasky

  • New Member
  • *
  • Posts: 20
Re: "vintage" BASIC highlighter
« Reply #23 on: October 22, 2018, 04:46:02 pm »
I would like to see highlighter for MAkeFile  ::)
1) You are totally off topic, MakeFile is totally context-free, write an highlighter should not be difficult and has nothing in common with Vintage BASIC
2) I know it is very frustrating to have answers like :
Quote
There is a tutorial
http://wiki.lazarus.freepascal.org/SynEdit_Highlighter
I felt myself upset at the beginning of this thread, like you did, I suppose, here : http://forum.lazarus-ide.org/index.php?topic=27152.0
In my opinion, I think that such an answer ("Read the fucking Manual") is totally disrespectful : everybody has not the same skills, what can be obvious for certain people is not for some others, and mainly, if you read the famous tutorial, tried to do to something from it and failed because the solution is simply not adapted.
3) Your idea is certainly excellent (it is !), but, please, stick to the thread you opened and don't com to pollute other threads that have nothing to do with your deep wishes.
4) If a MakeFile do not exist yet, it's may be because, like for Old School BASIC, it is not so obvious to do it. (Martin_fr, tu peux le comprendre ça ? Et ça vient de quelqu'un qui a rédigé une grosse partie de la FAQ Delphi sur developpez.com (waskol, c'est moi)...).
5) Insist, a bit more in your thread, someone will answer, and mainly try to do the thing by yourself and tell where you've been stuck. For sure people will stop by to help you. For sure, if you ask people to do things for yourself and wait things to be done for the sake of your only person, you will certainly be ignored.

Seriously, did I permit myself to ask for a BASIC highlighter in YOUR thread or another one ???
Thank you for understanding this.
« Last Edit: October 22, 2018, 04:54:02 pm by Ladywasky »

Edson

  • Hero Member
  • *****
  • Posts: 1296
Re: "vintage" BASIC highlighter
« Reply #24 on: October 22, 2018, 06:08:59 pm »
By the way, your solution fails here... mine is compliant.
I have tried to fiddle with this without any success :
Code: XML  [Select][+][-]
  1.  <!--Line number-->
  2.    <Regex Text="[ ]*"/>
  3.    <Regex Text="[0-9\s]+" />

What about?:
Code: XML  [Select][+][-]
  1.  <!--Line number-->
  2.    <Regex Text="[ ]*"/>
  3.    <Regex Text="[0-9 ]+" />

Regex in SynFacilSyn is some special. Not standard, optimized for speed.  :-X

Ideally, the use of grammar file should permit to redirect  to an event handler in code or a script file.
Something like that, maybe :
Code: XML  [Select][+][-]
  1. <Regex Text="DATA" ifTrueCustomEvent="1"/>
Code: Pascal  [Select][+][-]
  1. TSynFacilSyn1.OnCustom1:=CustomTreatment1;
  2. procedure CustomTreatment1(TokPos:integer;TokString:string);
  3. begin
  4.   if TokString='DATA' then
  5.   begin
  6.      ...
  7.   end;
  8. end;

I have thought some similar but haven't not time to include. In some previous versions of SynFacilSyn there was an event call inside the Next() method to give the programmer the option to custom the scan.

In SynFacilCompeltion there are some events to make completion programmatically.
« Last Edit: October 22, 2018, 06:11:13 pm by Edson »
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Ladywasky

  • New Member
  • *
  • Posts: 20
Re: "vintage" BASIC highlighter
« Reply #25 on: October 22, 2018, 06:26:10 pm »
I give it a try, asap

Edson

  • Hero Member
  • *****
  • Posts: 1296
Re: "vintage" BASIC highlighter
« Reply #26 on: October 22, 2018, 06:27:30 pm »
2) I know it is very frustrating to have answers like :
Quote
There is a tutorial
http://wiki.lazarus.freepascal.org/SynEdit_Highlighter
I guess Martin_fr answer this way because he's very busy and tired of read people doing the same question about SynEdit. That's why he's wrote a tutorial. Probably not the best but it's a help.

Martin_fr, I think you should include SynFacilSyn in Lazarus distribution, so instead of respond:

Quote
There is a tutorial  >:(
http://wiki.lazarus.freepascal.org/SynEdit_Highlighter

You could say:

Quote
There are 200 pages documentation in Spanish and English >:D>:D  >:D
https://github.com/t-edson/SynFacilSyn/blob/1.21/Docs/Technical%20documentation%20-%20Rev1.odt
« Last Edit: October 22, 2018, 06:29:39 pm by Edson »
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Ladywasky

  • New Member
  • *
  • Posts: 20
Re: "vintage" BASIC highlighter
« Reply #27 on: October 22, 2018, 07:22:25 pm »
That's more or less what I have written in French :
In the past, I was moderator, animating the Delphi forum and wrote a lot of the Delphi FAQs for developpez.com, and I always considered beginners.
When I saw that I could not spend any more time, instead of the answer "Read the FAQ", I retired from my role.
My pseudo was waskol before changing into Ladywasky :
- https://delphi.developpez.com/faq/?page=Le-composant-TPageControl#Comment-permettre-le-deplacement-des-onglets-d-un-TPageControl
- https://www.developpez.com/user/profil/40819/LadyWasky
even contributed to the JVCL :
- http://issuetracker.delphi-jedi.org/view.php?id=3073
- http://issuetracker.delphi-jedi.org/view.php?id=3079
- http://issuetracker.delphi-jedi.org/print_bug_page.php?bug_id=3098
(Olivier Bones was not a very nice guy, I remember : you find a bug, you bring a solution and the guy is patronizing with you : stupid....)

I am not a newbie, but I will never permit myself to throw away a beginner back to documentation without a bit of humanity.

Anyway, no judgement : everybody has his own limitations and life. And I understand Martin to have too much time for helping people, it is just better to not answer and leave somebody else to do it, sometime.

ANd you are right, your technical documentation is excellent and it's a pity to not see it included into lazarus. Same remark for ATSynEdit I am discovering too.

Ladywasky

  • New Member
  • *
  • Posts: 20
Re: "vintage" BASIC highlighter
« Reply #28 on: October 22, 2018, 07:37:26 pm »
OK,
Edson I have tested your solution. I validate it ;)

By the way,
1) in your SynFacilUtils, on Github, there is missing Misutils.pas : it prevents to compile your editor.
2) When you open another file in your editor, there is a refresh problem with the syntax highlight : you are obliged to drop down the language menu and click again on your already selected language (I did not investigate this issue furthermore, but I am sure that you will sort it out).

Good work Edson !

Ladywasky

  • New Member
  • *
  • Posts: 20
Re: "vintage" BASIC highlighter
« Reply #29 on: October 22, 2018, 07:40:17 pm »
I would like to see highlighter for MAkeFile  ::)

There is a makefile highlighter existing for EControl :
http://econtrol.ru/syntedit_lexlib.html

So that you can use http://wiki.freepascal.org/ATSynEdit wich is a EControl descendant working in Lazarus.

In order to build an xml file for SynFacilEdit, you may start from this document (Makefile syntax) :
https://www.mkssoftware.com/docs/man5/makefile.5.asp
« Last Edit: October 22, 2018, 08:04:12 pm by Ladywasky »

 

TinyPortal © 2005-2018