Syntax Highlighting for External Variables and Functions

21 views
Skip to first unread message

Matthias

unread,
Jan 30, 2020, 3:03:46 AM1/30/20
to blech-lang
Hi Blech Team,

I was just wondering whether it could be helpful for the Blech user to highlight external variables, functions, etc. in a special way. Consider the following example.

activity RF_sendCmdWord (cmd: uint8, dataTx: [SPI_TX_BUF]uint8, len: uint8)(dataRx: [SPI_TX_BUF]uint8) returns int8
   
SPI_beginTransfer() // external function call

   
var res: int8

   
// Send command.
   
var tmp: [SPI_TX_BUF]uint8 = {cmd}
    res
= run SPI_txRxBytes(tmp, 1)(dataRx)

   
if res == 0 then
       
// Send data.
        res
= run SPI_txRxBytes(dataTx, len)(dataRx)
   
end

   
SPI_endTransfer() // external function call

   
return res
end

In this example, SPI_beginTransfer() is a call to an external C function (we leave the synchronous island) while SPI_txRxBytes(), for instance, runs a Blech activity (part of the synchronous island). Highlighting SPI_beginTransfer() in italic, for instance, would make it visible / obvious to the user that this is actually an interaction point between Blech and C – means a call in the asynchronous environment. Maybe this could help to visually separate concerns!?

What is your opinion?

Regards,
Matthias

Gretz Friedrich (CR/AEE1)

unread,
Jan 30, 2020, 5:15:02 AM1/30/20
to blech-lang

Hi Matthias,

thank you for this suggestion. I do think it may be useful. Feel free to post this as a feature request on

https://github.com/boschresearch/blech-tools/issues

However, we cannot easily support this in the current state of the language services plugin. This is because currently highlighting is done using a grammar only. A grammar only talks about syntactic elements of the language such as keywords or identifiers. It has no clue about semantics – in this case: that the identifier SPI_beginTransfer represents an external function.

To make your idea work we would have to feed back the results from the type checker in the language server and use these results to alter the syntax highlighting. While this should be possible, it requires a redesign of the language service plugin.

 

Best regards

Friedrich Gretz

--
You received this message because you are subscribed to the Google Groups "blech-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blech-lang+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/blech-lang/14245f5e-35bf-453d-95f8-c4f53d2751f3%40googlegroups.com.

Matthias

unread,
Jan 30, 2020, 8:06:11 AM1/30/20
to blech-lang
Hi Friedrich,

okay, got it. I will open a ticket for that. It is just an idea for the future evolution of Blech.

Regards,
Matthias
Reply all
Reply to author
Forward
0 new messages