Single page description of Smalltalk

Dwight Hughes dwighth at ipa.net
Tue Mar 7 01:02:04 UTC 2000


Once I got rid of the extra comments I added, it will fit on one page.
I've attached it. Now whether it is actually clear to all who read it,
that is another matter.

Looks like I may need to revisit this definition -- there are still
certain elements that are more semantic than syntactic. I think it would
be simpler if I made the separation clearer.

-- Dwight

Bob Arning wrote:
> 
> On Mon, 6 Mar 2000 15:47:49 -0800 (GMT) Tim Rowledge <tim at sumeru.stanford.edu> wrote:
> >A friend is asking me if I know of a single page description of the syntax and
> >semantics of Smalltalk. I'm sure I read of somebody popping such a page
> >somewhere on the web, and it is surely possible; after all (IIRC) Alan bet that
> >a decent language could be described in half a page.
> >
> >Anyone know where I might point my friend?
> 
> One possibility is:
> 
>         http://minnow.cc.gatech.edu/squeak/409
> 
> Cheers,
> Bob
-------------- next part --------------
The EBNF used is defined as:
[ ... ] apply zero or one times;    [ ... ]* apply zero or more times;
[ ... ]+ apply one or more times;   ... | ... choose one of the alternatives;
"..." use the literal characters enclosed; ( ... ) used for grouping.
-------------------------------------------------------------------------------
method = message_pattern [temporaries] [primitive_declaration] [statements].
message_pattern = unary_selector | binary_selector argument_name | [keyword argument_name]+.
temporaries = "|" [variable_name]* "|".
primitive_declaration = "<" "primitive:" decimal_digits ">".
block = "[" [[":" argument_name]+ "|"] [temporaries] [statements] "]".
statements = [expression "."]* ["^"] expression ["."].
brace_expression = "{" [expression ["." expression]*] "}".
expression = [variable_name assignment_op]* (primary | message_expression | cascaded_message_expression).
primary = variable_name | argument_name | literal | block | brace_expression | "(" expression ")".
assignment_op = ":=" | "_". 
cascaded_message_expression = message_expression [";" ( unary_selector | binary_selector unary_object_description | [keyword binary_object_description]+ ) ]+.
message_expression = unary_expression | binary_expression | keyword_expression.
keyword_expression = binary_object_description [keyword binary_object_description]+.
binary_expression = binary_object_description binary_selector unary_object_description.
unary_expression = unary_object_description unary_selector.
binary_object_description = unary_object_description | binary_expression.
unary_object_description = primary | unary_expression.
keyword = identifier ":".
binary_selector = (special_character [special_character]) | ("-" [special_character]) | "|".
unary_selector = identifier.
argument_name = identifier.
variable_name = identifier.
class_name = capital_identifier.
class_variable_name = capital_identifier.
instance_variable_name = identifier.
class_instance_variable_name = identifier.
literal = (number | symbol_constant | character_constant | string | array_constant).
array_constant = "#" array.
array = "(" [number | symbol | string | character_constant | array]* ")".
comment = """ [character | """ """ | "'"]* """.
string = "'" [character | "'" "'" | """]* "'".
character_constant = "$"(character | "'" | """).
symbol_constant = "#" symbol.
symbol = identifier | binary_selector | [keyword]+ | string.
identifier = letter [letter | decimal_digit]*.
capital_identifier = uppercase [letter | decimal_digit]*.
letter = uppercase | lowercase.
character = ("["|"]"|"{"|"}"|"("|")"|"_"|"^"|";"|"$"|"#"|":"|"-"|"|"|".")|decimal_digit|letter|special_character.
special_character = ("+"|""|"/"|"\"|"~"|"<"|">"|"="|"@"|"%"|"&"|"?"|"!"|"`"|"," ).
uppercase = "A"|"B"|"C"|"D"|"E"|"F"|"G"|"H"|"I"|"J"|"K"|"L"|"M"|"N"|"O"|"P"|"Q"|"R"|"S"|"T"|"U"|"V"|"W"|"X"|"Y"|"Z".
lowercase = "a"|"b"|"c"|"d"|"e"|"f"|"g"|"h"|"i"|"j"|"k"|"l"|"m"|"n"|"o"|"p"|"q"|"r"|"s"|"t"|"u"|"v"|"w"|"x"|"y"|"z".
number = [radix "r"]["-"]digits["."digits]["e"["-"]exponent].
exponent = decimal_digits.
radix = decimal_digits. 
digits = [digit]+.
digit = decimal_digit | uppercase.
decimal_digits = [decimal_digit]+.
decimal_digit = "0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9".
separator = whitespace | comment.
whitespace = [space | tab | newline]+.
newline = cr | lf | crlf.
pseudo_variable = "true"|"false"|"nil"|"self"|"super"|"thisContext"|"homeContext".
-------------------------------------------------------------------------------


More information about the Squeak-dev mailing list