Raku Lexer

All questions regarding lexer highlighting schemes are discussed here...
demanuel
Posts: 8
Joined: 31.05.2021 20:27

Raku Lexer

Post by demanuel »

Hi!

I added some keywords to the raku lexer. Don't know if they are in the right place, though....
I also changed the displaying types in the code browser, because it's possible to put comments in the signature and it will make the display unusable.

The lcf file is attached.

Another thing that i did was a linter for raku. You can find the source for it in: https://github.com/demanuel/cuda_lint_raku

Please confirm that everything's fine.
Attachments
Raku.lcf.tar.gz
raku lcf file
(4.01 KiB) Downloaded 39 times
uvviewsoft
Posts: 392
Joined: 01.12.2020 13:46

Post by uvviewsoft »

You added keywords:
proto regex.
You added special words which start code-tree items:
'model'
'module'
'monitor'
'proto'
Did you check that these 4 blocks are OK on code-tree? I don't know the syntax and don't have sample files.
uvviewsoft
Posts: 392
Joined: 01.12.2020 13:46

Post by uvviewsoft »

Linter is now published to addons, thanks for your work.
demanuel
Posts: 8
Joined: 31.05.2021 20:27

Post by demanuel »

New version attached.

The only issue i see is with the code

Code: Select all

grammar Calculator {
    token TOP { [ <add> | <sub> ] }
    rule  add { <num> '+' <num> }
    rule  sub { <num> '-' <num> }
    token num { \d+ }
}
in the code tree for the sub rule it becomes

Code: Select all

gramar Calculator
    token TOP
    rule add
    sub {
    token num
How do i make it

Code: Select all

gramar Calculator
    token TOP
    rule add
    rule sub
    token num
?
Attachments
Raku.lcf.tar.gz
(4.03 KiB) Downloaded 35 times
uvviewsoft
Posts: 392
Joined: 01.12.2020 13:46

Post by uvviewsoft »

1. I can fix it but need to know: are all these words- keywords, and must be bold-black (default theme)?

class
grammar
method
model
module
monitor
package
proto
regex
role
rule
sub
submethod
token

2. if 'sub' is keyword, then this line is bad?
token TOP { [ <add> | <sub> ] }

and this?
rule sub { <num> '-' <num> }

or 'sub' is not always a keyword?
uvviewsoft
Posts: 392
Joined: 01.12.2020 13:46

Post by uvviewsoft »

3. Can i consider all these words as keywords IF the next 'token' is identifier?
'sub Id' = here 'sub' is keyword?
'rule sub { ... }' = here 'sub' is not keyword?
demanuel
Posts: 8
Joined: 31.05.2021 20:27

Post by demanuel »

uvviewsoft wrote:3. Can i consider all these words as keywords IF the next 'token' is identifier?
'sub Id' = here 'sub' is keyword?
'rule sub { ... }' = here 'sub' is not keyword?
The example is correct. sub is not always a keyword.

This is valid code with the sub as the name of the rule: https://docs.raku.org/language/grammars ... to_regexes

Code: Select all

grammar Calculator {
    token TOP { [ <add> | <sub> ] }
    rule  add { <num> '+' <num> }
    rule  sub { <num> '-' <num> }
    token num { \d+ }
}
Last edited by demanuel on 01.06.2021 12:15, edited 1 time in total.
uvviewsoft
Posts: 392
Joined: 01.12.2020 13:46

Post by uvviewsoft »

Adjusted as suggested, pls update lexer (Addon Manager) and test. 'sub' is now not always a keyword.
demanuel
Posts: 8
Joined: 31.05.2021 20:27

Post by demanuel »

Seems good now :-)
demanuel
Posts: 8
Joined: 31.05.2021 20:27

Post by demanuel »

H, uvviewsoft,

I updated the https://github.com/demanuel/cuda_lint_raku however i'm unable to create a PR as your repo is a fork of mine :-(
Post Reply