WebL programs can be written in the Unicode character set (little or big-endian byte ordering with an initial Unicode byte ordering mark) or the more compact UTF-8 character set. Note that the first 127 characters of UTF-8 correspond to the widely used western ISO-8859-1 or Latin 1 character set.
White space and comments are ignored in WebL programs. Comments consist of either:
a double forward slash token //, which introduces a comment till the end of the line, or
the token pairs /* and */ with comments in between.
Note that comments of the style /* */ may nest.
Import = import [ Ident { "," Ident } ] ";"
SS = (Var | E) { ";" (Var | E) } [ ";" ]
Var = [ export ] var IdentInit { "," IdentInit }
| FieldRef ":=" E // define expr
Value = nil | Bool | String | Real | Integer | Character | Object | Set | List
ImportRef = Ident [ "_" Ident ]
Object = "[." [ Field { "," Field } ] ".]"
List = "[" [ E { "," E } ] "]"
BinOp = "+" | "-" | "*" | "/" | div | mod
| "<" | "<=" | "==" | "!=" | ">" | ">="
| inside | !inside | directlyinside | !directlyinside
| directlycontain | !directlycontain
| after | !after | directlyafter | !directlyafter
| before | !before | !directlybefore | directlybefore
Statement = WhileStat | IfStat | FunStat | MethStat | CatchStat
| EveryStat | LockStat | RepeatStat | BeginStat | ReturnStat
WhileStat = while SS do SS end
IfStat = if SS then SS [ ElseStat ] end
ElseStat = else SS | elsif SS then SS [ ElseStat ]
FunStat = fun "(" [ Ident ( "," Ident } ] ")" SS end
MethStat = meth "(" [ Ident ( "," Ident } ] ")" SS end
CatchStat = try SS catch Ident { on E do SS } end
// Ident introduced into a new scope
EveryStat = every Ident in E do SS end
// Ident introduced into a new scope
RepeatStat = repeat SS until SS end
Ident = Letter { Letter | Digit }
Real = Integer [ Fraction ] [ Exponent ]
Exponent = ( "e" | "E" ) [ "+" | "-"] Integer
String = "\"" { Char } "\"" | "`" { Char } "`"
Letter = "a" .. "z" | "A" .. "Z"
Char = *any unicode character*
Strings and characters may contain the escapes listed in See String and Character Escape Sequences. To write the non-standard escapes that occur in regular expressions (like \w and \d), it is advisable to use back-quoted strings which ignore the string content completely.