[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mango parser for Self?



On Tue, 19 Dec 1995 16:05:46 -0500,
Cameron Elliott <cam@indy.mvbms.com> wrote:
> Has anyone written a Mango grammer description for Self ?

I don't think so, but I started to do it a long time ago. I never finished
or tested it, but here is what I wrote:
------------------------ start of s3.grm ----------------------
Name:       's3'
Behavior:   's3.behavior.self'

Syntax:  SLR(1)

<exprssion>  ::= <keyMess>;

<keyMess>    ::| <binkey> <rkey>;
<binkey>     ::= <binMess> <keyopt>;
<rkey>       ::= <resend> <kMess>;
<keyopt>     ::? <kMess>;
<kMess>      ::= {smallKey} <argList>;
<argList>    ::+ <keyMess> {capKey};

<binMess>    ::| <unbin> <rbin>;
<unbin>      ::= <unaryMess> <bList>;
<rbin>       ::= <resend> <bMess> <bList>;
<bList>      ::* <bMess>;
<bMess>      ::= {operator} <expression>;

<unaryMess>  ::| <primun> <run>;
<primun>     ::= <primary> <uopt>;
<run>        ::= <resend> <uMess>;
<uMess>      ::+ {identifier};

<resend>     ::| <ropt> <directed>;
<ropt>       ::? 'resend.';
<directed>   ::= {identifier} '.';

<primary>    ::| 'self' {number} {string} <method> <block> <annotation>;

<method>     ::= '(' <slotList> <code> ')';

<block>      ::= '[' <slotList> <code> ']';

<anootation> ::= '{' {string} <primary> '}';

<code>       ::? <codes>
<codes>      ::| <codeList> <codeBoth> <return>;
<codeBoth>   ::= <codeList> '.' <return>; 
<codeList>   ::+ <expression> '.';
<return>     ::= '^' <expression> <dotopt>;
<dotopt>     ::? '.';

<slotList>   ::? <sList>;
<sList>      ::= '|' <sList2> '|';
<sList2>     ::* <slotDefs>;
<slotDefs>   ::| <annotSlots> <slotDef>;
<slotDef>    ::+ <slot> '.';
<annotSlots> ::= '{' {string} <sList2> '}';

<slot>       ::| <privDecl> <simpleDecl>;
<privDecl>   ::= <privacy> <simpleDecl>;
<privacy>    ::| '^' '_' '^_' '_^';
<simpleDecl> ::| <argSlot> <dataSlot> <bSlot> <kSlot>;

<argSlot>    ::= ':' <slotName>;

<dataSlot>   ::= <slotName> <initopt>;
<initopt>    ::? <datainit>;
<datainit>   ::| <varinit> <constinit>;
<varinit>    ::= '<-' <expression>;
<constinit>  ::= '=' <expression>;

<bSlot>      ::= {operator} <bDef>;
<bDef>       ::| <bDef1> <bDef2>;
<bDef1>      ::= '=' <method>;
<bDef2>      ::= {identifier} '=' <method>;

<kSlot>      ::= {smallKeyword} <kDef>;
<kDef>       ::| <kDef1> <kDef2>;
<kDef1>      ::= <ceList> '=' <method>;
<kDef2>      ::= <cList>  '=' <method>;
<ceList>     ::* {identifier} {capKeyword};
<cList>      ::* {capKeyword};

<slotName>   ::= {identifier} <paropt>;
<paropt>     ::? '*';

Lex:         SLR(1)

{digit}      = [0-9];
{smallLetter}= [a-z];
{capLetter}  = [A-Z];
{letter}     = [a-zA-Z];
{opChar}     = [!@#$%^&*-+=~/?<>,;|`\\];
{smallstart} = {smallLetter} | '_';
{indentChars}= {digit} | {letter} | '_';
{delimChar}  = [()\[\]{}.:];
{blank}      = [ \t\n] | {comment}
{comment}    = '"' {commentStuff}* '"';


{whitespace} -> {blank}+;

{op}         -> {opChar}+;
{capKeyword} -> {capLetter}{identChars}+ ':';
{smallKeyword}-> {smallstart}{identChars}+ ':';
{identifier} -> {smallLetter}{identChars}+;
------------------------ end of s3.grm ------------------------

Notes: I doubt very much that the grammar is SRL(1) - I just put
that done until I figure out what it should be. The lexical part
is very incomplete (mostly missing comments, numbers and strings).
The "-" is rather nasty and this mango file doesn't handle it
correctly. The "." char isn't taken care of here either.
One element that showed up in Self 4.0 is a new syntax for
object annotation declaration - it isn't handled here.

I hope this isn't worse than nothing ;-)

-- Jecel