This is an example of the Clarion source language. It produces a clean compile but otherwise is total nonsense. It is very badly formated by design, to facilitate testing. It parses clean.
I'm not sure if the "OMIT" structure can be accomodated, it's kind of weird. Basically it will omit all code up to and including the supplied string.
Code: Select all
Extension: .clw ; .cla Line Comment: ! Block Comment: none Begin: Program End: none Begin: Module End: End Begin: File (has a label in column 1) End: End Begin: Record (has a label in column 1) End: End Begin: Procedure (has a label in column 1) End: none Begin: Function (has a label in column 1) End: none Begin: Routine (has a label in column 1) End: none Begin: Data End: Code Begin: Code End: none Begin: Loop (Can have a label in column 1. Optional) End: End Begin: If End: End Begin: Case End: End Begin: Execute End: End Begin: OMIT End: (The string specified in the OMIT statement) Note: END keyword can also be represented by a period (.) Sample Code: PROGRAM Taglines FILE,DRIVER('TOPSPEED'),RECLAIM,PRE(TAG),BINDABLE,CREATE,THREAD Key_MD5 KEY(TAG:MD5),DUP,NOCASE,OPT Key_ID KEY(TAG:TAG_ID),NOCASE,OPT,PRIMARY Record RECORD,PRE() TAG_ID LONG Tagline STRING(4096) MD5 CSTRING(32) END END MAP Main PROCEDURE Dis Function(STRING p:linein),STRING MODULE('WinAPI') AttachThreadToClarion (BOOL Full),PASCAL END ! Module END !Map CODE Main() Main PROCeDURE StartDay LONG Of_Beer String(20) Got_Beer BYTE(20) UnLooped LONG Hell_Freezes_Over LONG CoDE ! This is a single line comment If TODAY() = StartDay Do something_daring EnD ! IF - (I usually end my structures with a comment) Case Of_Beer OF 'Ringnes' OF 'Budweiser' OF 'Hansa' OF 'Tuborg' End ! Case Of_Beer Loop UnTiL NoT Got_Beer Got_Beer -= 1 END ! Loop OMIT('This code') Rollover() Reboot() PlayDead() 'This code' ! String comparisons are case sensitive even if the ! language isn't OPEN(Taglines) FirstLoop LOOP until Unlooped TAG:TAG_ID += 1 SET(TAG:Key_ID,TAG:Key_ID) SecondLoop LOOP Until Hell_Freezes_Over Next(Taglines) IF ERRORCODE() Break FirstLoop END ! IF Hell_Freezes_Over -= 1 End ! SecondLoop END ! FirstLoop Close(Taglines) Something_Daring ROUTINE DaTA A_Number LONG Code A_Number = Random(1,4) EXECUTE(A_Number) Of_Beer = 'Ringnes' Of_Beer = 'Budweiser' Of_Beer = 'Hansa' Of_Beer = 'Tuborg' END ! Execute Dis Function(STRING p:linein) Somevar LONG AnyOfThisMakesSense LONG ReturnString STRING(120) CODE IF Somevar ReturnString = 'Yep!' Else ReturnString = 'nope' END !IF IF AnyOfThisMakesSense THEN RETURN('0'). !This is a valid variation of an if statement RETURN(ReturnString)
This example code produces a clean compile and demonstrates every
keyword structure in the Clarion source language.
Clarion is case insensitive. procedure, Procedure and PROCEDURE
are all considered the same. This example code is difficult to
read because I have intentionally mixed the case of the keywords
for testing purposes.
Column 1 in all Clarion source is reserved to indicate a label.
Procedure names, variable names, all begin in column 1. So the
structure names that have labels will always be the second word
on the line, with the exception of Loop which may or may not have
a label. This exception is useful for breaking an inner loop when
you really want to break out of the topmost loop. I have provided
examples of both.
The END keyword can have a period (.) used as an indicator. i.e.
This is probably going to be removed in the future but there is
20 years of legacy code that still use this syntax. I hate it.
But I didn't design the language. I have provided examples of
this structure in the source code.
*.clw is the windows source file suffix, *.cla is the older DOS
suffix. The code is substantially the same. This folding scheme
should support Clarion source code written in the 1980's
If you are interested, I have syntax highlighting keyword
lists available for adding as a supported language.