WebL EBNF

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.

The WebL EBNF is:

Module = { Import } SS

Import = import [ Ident { "," Ident } ] ";"

SS = (Var | E) { ";" (Var | E) } [ ";" ]

Var = [ export ] var IdentInit { "," IdentInit }

IdentInit = Ident [ "=" E ]

E = Value

| ImportRef

| E BinOp E

| UnOp E

| Statement

| "(" E ")"

| E "(" [ E { "," E } ] ")"

| FieldRef

| FieldRef ":=" E // define expr

Value = nil | Bool | String | Real | Integer | Character | Object | Set | List

ImportRef = Ident [ "_" Ident ]

Bool = true | false

Object = "[." [ Field { "," Field } ] ".]"

Field = Ident "=" E

Set = "{" [ E { "," E } ] "}"

List = "[" [ E { "," E } ] "]"

| "[|" [ E { "," E } ] "|]"

FieldRef = E "[" E "]"

| E "." Ident

BinOp = "+" | "-" | "*" | "/" | div | mod

| "<" | "<=" | "==" | "!=" | ">" | ">="

| and | or

| "|" | "?"

| "="

| member

| inside | !inside | directlyinside | !directlyinside

| contain | !contain

| directlycontain | !directlycontain

| after | !after | directlyafter | !directlyafter

| before | !before | !directlybefore | directlybefore

| overlap | !overlap

| without

UnOp = "-" | "+" | "!"

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

LockStat = lock SS do SS end

RepeatStat = repeat SS until SS end

BeginStat = begin SS end

ReturnStat = return [E]

 

Ident = Letter { Letter | Digit }

Integer = Digit { Digit }

Real = Integer [ Fraction ] [ Exponent ]

Fraction = "." Integer

Exponent = ( "e" | "E" ) [ "+" | "-"] Integer

String = "\"" { Char } "\"" | "`" { Char } "`"

Char = "'" Char "'"

Digit = "0" .. "9"

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.

String and Character Escape Sequences

Escape

Description

\b

Backspace

\t

Horizontal tab

\n

Newline

\f

Form feed

\r

Carriage return

\"

Double quote

\'

Single quote

\\

Backslash

\xxx

Character of octal value xxx

\uxxxx

Character of hexadecimal value xxxx


Up Previous Next