Grammar: Multiparadigm Programming Language 0.9


WORK IN PROGRESS

The goal of this work is

This work is supports ideas developing in Introduction to Programming Languages where abstraction, generalization and computational models are used as unifying concepts for understanding programming languages.


Notation

 
Figure M.N: Notation
Notation Means
N ::= R 
A B 
A | B 
( A ) 
[ A ] 
[ A ]* 
[ A ]+ 
bold
italic
standard font
Occurrence of N may be replaced with R 
A followed by B 
A or B 
Grouping 
A is optional 
Possibly empty sequence of A's 
One or more As 
Literal symbols 
Nonterminals 
Symbols of the grammar definition language

The Grammar

Figure N.M: Unified Paradigm Grammar
Program:
program ::= [ module ]+  ( ?- predicate [ predicate ]* | ! command | #expression
Modules & blocks:
module ::= module [ (extends moduleName+| implements interfaceName) ] declaration*
| interface import* declaration
declaration ::= | [ (export | public) | private | protected | static ] ( abstraction | clause
| ( initial | final ) abstract
import ::= import(moduleName [ as localAlias ])+
| from moduleName import name+
block ::= block declaration* abstract
Abstraction, Generalization, & Specialization:
abstraction ::= name [ is abstract ]
abstract ::= expression | command  | [ a ] type [, constant
| module | generalization
generalization ::= \ parameter . abstract
parameter ::= declaration
specialization ::= generalization argument
argument ::= [[non] strict] abstract
Object Oriented Programming
class ::= class[ (extends className+ | implements interfaceName) ] declaration*
object ::= nameis[a] module
Functional Programming: lambda calculus (reduction of an expression to a normal form) 
expression ::= constant | variableName | ( expression expression ) 
| expressionGeneralization | expressonBlock | expressionModule
Imperative Programming: binding sequences 
command ::= skip
| event
| identifier+ := expression+
| {; command* } | {|| command* }
| {? guardedCommand* } | {* guardedCommand* }
| commandInvocation | commandBlock | commandModule
guardedCommand ::= guard--> command
guard ::= (event | booleanExpression)[ , booleanExpression) ]* | else
Logic Programming: pure Prolog (deduction) 
logicProgram ::= theory query
theory ::= clause+
clause ::= [ predicate :- ] [  predicate ,  ]* predicate
predicate ::= atom | atom( term [ , term ]* )
term ::= number | atom[( term [, term ]* )] | variable
query ::= ?- predicate [ predicate ]*
Concurrent ProgrammingThreads: class or ?
Communication and Event Primitives:I/O, keyboard, mouse, etc
monitor ::= monitor declaration*
event ::= send | receive
send ::= sendmessagetoprocessIdentifier  | p!e | output expression
receive ::= receivemessagefrom processIdentifier  | p?x | input variable
message ::= <info,a,b>
Exceptions:class, expression, command, predicate
throw ::= ( throw | raise | error ) exceptionName [ ( value ) ]
exception ::= try abstract ( catch | except ) handlersfinally handler
handlers ::= [ | handler ]+
handler ::= exceptionName[ ( value ) ] [ , exceptionName [ ( value ) ]]* => command
Type Expressions:
type ::= primitiveType | structuredType | typeName
primitiveType ::= null | atom | Boolean | Number | Character | String
structuredType ::= sum | product | function | module  exception [(type)]
sum ::= (+ (atom | [name:]type) [ (atom | [name:]type) ]* )
| (+ I..J) | (+ I,J..K)
 A is module end B is module extends A end ... N is module extends N-1 end
product ::= (* [name  isa]type [ , [name isa]type ]* ) | module (export name isa type .)+ end
function ::= [map] sum --> type
Element Construction: literals and values
constant ::= atomic | structured
atomic ::= nil | _|_ | atom | boolean | number | character | string
structured ::= (* constant [ , constant ]* ) | map  sum --> sum

Syntactic Sugar - conventions & idioms for simplying programming


by nthony A. Aaby.Send comments to aabyan@wwc.edu