Page 1 of 1

Oberon Lexer [RESOLVED]

Posted: 19.01.2016 21:29
by captbill
Hi,
The Oberon lexer does not recognize the "*" as a suffix to "PROCEDURE" (PROCEDURE*), which indicates a "leaf procedure" (much like an inline proc). When the * is a suffix of the procedure name "PROCEDURE myProcedure* ()" this indicates an "exported public procedure". And also both are possible "PROCEDURE* myProcedure*()".

I have made several attempts to customize the lexer to sort these issues with SynWrite with no luck. I am sure it is simple and I am missing something obvious. Any ideas/pointers?

Thanks,
Bill

Code: Select all

MODULE ADC;
(* =========================================================================  
   Astrobe Library Functions for LPC1xxx ADC0  
   
   Target: LPC1xxx family microcontrollers with Analog-toDigital Converter

   (c) 2012-2015 CFB Software   
   http://www.astrobe.com  
   
   ========================================================================= *)

IMPORT SYSTEM, MCU;

CONST
  (* ADC0 control register bits *) 
  burstBit = {16};
  startBit = {24};
  
  maxChannels = MCU.ADC0MaxChannels;
  msb = MCU.ADC0GDRMSB;
  lsb = MCU.ADC0GDRLSB;
  
TYPE 
  ChannelData = ARRAY maxChannels OF INTEGER;
  
VAR
  control: SET;
  data: ChannelData;

PROCEDURE* ClearData*;
VAR
  channel: INTEGER;
BEGIN
  FOR channel := 0 TO LEN(data) - 1 DO data[channel] := 0 END
END ClearData;


PROCEDURE* GetData*(channel: INTEGER): INTEGER;
VAR 
  d: INTEGER;
BEGIN
  ASSERT(channel DIV maxChannels = 0, 22);
  SYSTEM.UBFX(d, data[channel], msb, lsb);
  RETURN d
END GetData;


PROCEDURE* ReadChannels*(channels: SET);
VAR 
  channel, value: INTEGER;
BEGIN
  SYSTEM.PUT(MCU.ADC0CR, control + burstBit + channels);
  WHILE channels # {} DO 
    (* GDR Sign bit (31) is set when A/D conversion is done *)
    REPEAT
      SYSTEM.GET(MCU.ADC0GDR, value)
    UNTIL value < 0;
    (* channel number = GDR 26:24 *)
    SYSTEM.UBFX(channel, value, 26, 24);
    data[channel] := value;
    channels := channels - {channel}
  END;
  SYSTEM.PUT(MCU.ADC0CR, control)
END ReadChannels;


PROCEDURE* Read*(channel: INTEGER; VAR value: INTEGER);
VAR
  gdr: INTEGER;
BEGIN
  ASSERT(channel DIV maxChannels = 0, 21);
  SYSTEM.PUT(MCU.ADC0CR, control + startBit + {channel});
  (* GDR Sign bit (31) is set when A/D conversion is done *)
  REPEAT
    SYSTEM.GET(MCU.ADC0GDR, gdr)
  UNTIL gdr < 0;
  SYSTEM.UBFX(value, gdr, msb, lsb);
  SYSTEM.PUT(MCU.ADC0CR, control)
END Read;


PROCEDURE Init*();
BEGIN 
  SYSTEM.GET(MCU.ADC0CR, control);
  ClearData()
END Init;

END ADC.


Posted: 19.01.2016 21:51
by Alexey
updated lex. I added rule for "procedure * name" and tree OK now for your file.

Posted: 19.01.2016 22:01
by captbill
Wow. That was fast. Brilliant!

I need to study what you did now.

Thanks again,
Bill