# Slate BNF language specification # # Copyright (C) 2003 Brian P. Templeton # # Authors: Brian P. Templeton , # Brian T. Rice # # $Id: slate.bnf,v 1.4 2003/05/22 06:38:24 water Exp $ # # slate.bnf is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This software is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Emacs; see the file COPYING. If not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. %start slate %outputfile slate-semantic.el %parsetable slate-toplevel-bovine-table %keywordtable slate-keyword-table %languagemode slate-mode %setupfunction slate-default-semantic-setup %(setq semantic-case-fold nil semantic-command-separation-character "." document-comment-start "\"" document-comment-end "\"" ) # symbol SYMBOL : symbol ( $1 ) # comment -- semantic apparently ignores comments # character CHARACTER : charquote "\$" punctuation "[^\\]" | charquote "\$" symbol | charquote "\$" punctuation "\\" symbol ; # string STRING : string ( $1 ) ; %token INTEGER symbol "[0-9]+" %token FLOAT symbol "[0-9]+[.][0-9]*" # expression sequence EXPRESSIONS : EXPRESSION punctuation "[.]" EXPRESSION | EXPRESSION punctuation "[.]" EXPRESSIONS ; # array ARRAY : open-paren "{" EXPRESSIONS close-paren "}" ; # compond COMPOUND : open-paren "(" EXPRESSIONS close-paren ")" ; # block BLOCK-UNTYPED-DECL : symbol ":?[A-z0-9]+" ; BLOCK-TYPED-DECL : BLOCK-DECL punctuation "!" EXPRESSION ; BLOCK-DECL : BLOCK-UNTYPED-DECL | BLOCK-TYPED-DECL ; BLOCK-DECLS : BLOCK-DECL | BLOCK-DECLS ; BLOCK-HEADER : symbol "|" BLOCK-DECLS symbol "|" ; BLOCK : open-paren "[" BLOCK-HEADER EXPRESSIONS close-paren "]" | open-paren "[" EXPRESSIONS close-paren "]" ; # messages UNARY-MESSAGE-SEND : symbol ; BINARY-MESSAGE-SEND : punctuation "[-%^&*+=|\/;,?<>~]+" EXPRESSION ; KEYWORD-ARG-PAIR : symbol "[A-z0-9]+:" EXPRESSION ; OPT-KEYWORD-PAIR : punctuation "&" KEYWORD-ARG-PAIR ; KEYWORD-MESSAGE-SEND : KEYWORD-ARG-PAIR KEYWORD-MESSAGE-SEND | KEYWORD-ARG-PAIR ; KEYWORD-MESSAGE-SEND-OPTS : KEYWORD-MESSAGE-SEND OPT-KEYWORD-PAIR | KEYWORD-MESSAGE-SEND-OPTS OPT-KEYWORD-PAIR ; MESSAGE-SEND : UNARY-MESSAGE-SEND | BINARY-MESSAGE-SEND | KEYWORD-MESSAGE-SEND | KEYWORD-MESSAGE-SEND-OPTS ; MACRO-MESSAGE-SEND : punctuation "`" MESSAGE-SEND ; # "built-ins" %token LOBBY UNARY-MESSAGE-SEND "lobby" %token CONTEXT UNARY-MESSAGE-SEND "thisContext" %token RESEND UNARY-MESSAGE-SEND "resend" %token TRAITS UNARY-MESSAGE-SEND "traits" %token TRUE UNARY-MESSAGE-SEND "True" %token FALSE UNARY-MESSAGE-SEND "False" %token NIL UNARY-MESSAGE-SEND "Nil" %token NOROLE UNARY-MESSAGE-SEND "NoRole" # method METHOD : MESSAGE-SIGNATURE BLOCK ; # All major classes of expressions. EXPRESSION : MESSAGE-SEND | MACRO-MESSAGE-SEND | METHOD | ARRAY | COMPOUND | BLOCK | SYMBOL | CHARACTER | STRING | INTEGER | FLOAT ; # A Slate source file is, at the top level, just some expressions in sequence. SLATE-FILE : EXPRESSIONS ;