Visual dbase

All questions regarding lexer highlighting schemes are discussed here...
senendds
Posts: 11
Joined: 06.03.2015 11:14

Visual dbase

Post by senendds »

Hello,
I've just started trying SynWrite because it seems to have a great flexibility my current editor doesn't have.

I've read the tutorials about how to write new lexers, but still have many questions.

For instance, how do I distinguish these construct:

Code: Select all

Class SomeClass
   Procedure SomeProcedure
      a=1
      return
EndClass
which defines a class with a procedure, from this other construct:

Code: Select all

set procedure to AnotherFile.PRG additive
which makes available the code defined in another file?

For the "Class ... EndClass" part I've defined one '_Class' rule of "Block type"="Range start" and one '_EndClass' rule of "BlockType"="Range end", and linked both with the respective "Range end" and "Range start" conditions.

For the "Procedure" part I've defined a '_Procedure' rule of type "Range start", I've assigned the "Range end condition"='_EndClass', I've marked it as a "Self closing range" (because there is no "EndProcedure" keyword in the language).

The problem is that the sentence "set procedure to..." is matched by the '_Procedure' rule and it should not.

To prevent that, I've defined a 'SetProcedureTo' parser with the regexp

Code: Select all

set\s+proc(edure)?\s+to
but that seems overly complicated to my taste. I would prefer to define a condition in the '_Procedure' rule not to match the key list "set procedure", but I don't know how. Is that possible?

A second question (for now) is about keywords:
The language allows the programmer to be lazy (by writing only the first 4 characters of some keywords) and I've to deal with a lot of code where the original programmer does have been lazy and instead of "procedure", "enddo", "while", "endif", he has used "proc", "endd", "whil", "endi". Is there a why I can configure keywords that match with the trimmed version?


Thanks,
Senen
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

1--yes, possible. Make 2 rules for procedure. 1st takes "set procedure to", 2nd takes only "procedure", and SET "skip next rules" for rule1 so rule2 won't work if rule1 worked. (rule1 must have 3 tokens: set, procedure, to... don't use regex for whole line)
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

2--list all keywords with short+long view. so list "procedure" and "proc"--also for rules, for folding, and for hilite.
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

Feel free to post lexr with sample files/ maybe I fix smth
senendds
Posts: 11
Joined: 06.03.2015 11:14

Post by senendds »

Alexey wrote:1--yes, possible. Make 2 rules for procedure. 1st takes "set procedure to", 2nd takes only "procedure", and SET "skip next rules" for rule1 so rule2 won't work if rule1 worked. (rule1 must have 3 tokens: set, procedure, to... don't use regex for whole line)
Thank you. I will go with the parser option, though, because it allows me to assign a style to highlight "set procedure..." expressions.
senendds
Posts: 11
Joined: 06.03.2015 11:14

Post by senendds »

Alexey wrote:2--list all keywords with short+long view. so list "procedure" and "proc"--also for rules, for folding, and for hilite.
Ok. I was thinking that I would need all the intermediate versions: "procedure", "procedur", "procedu",... "proc", but most of the times with the longest and the shortest is enough.
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

Intermediate needed too (if wanted OK lexer)
senendds
Posts: 11
Joined: 06.03.2015 11:14

Post by senendds »

I'm still having some problems defining the lexer for Visual dBase.

Let's supose I have this code

Code: Select all

CLASS Class1
   Procedure P1
        some code

   Procedure P2
        some code

ENDCLASS

CLASS Class2
    some code
ENDCLASS

"CLASS" and "ENDCLASS" have respectively a "Range start" and "Range end" rule, but "PROCEDURE" has a rule without "Range end condition".

If I set the property "Self closing range" to the "PROCEDURE" rule, then the whole class Class2 is displayed, in the tree view, as a child of Class2.P2, but if I don't set it, the Procedures are not collapsable in the source window. How can I solve that?

By the way, could someone clarify the meaning and use of the properties:
  • Parent block
  • Strict parent block
  • Not a parent
  • Always enabled
  • Cancel next rules
Thanks
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

Pls attach lex-file (use ExLexer plugin!) so I can test.. (meaning of opts--see my tutorials in Readme)
Alexey
Posts: 1633
Joined: 05.10.2012 22:10

Post by Alexey »

Solution==> file attach (open zip in program, activate "tt")
Attachments
lexer.tt.zip
(882 Bytes) Downloaded 52 times
Locked