1 ;;; erlang.by -- LL grammar for Erlang language specification
3 ;; Copyright (C) 2002, 2003 Vladimir G. Sekissov
4 ;; Copyright (C) 2003 David Ponce
6 ;; Author: Vladimir G. Sekissov <svg@surnet.ru>
7 ;; David Ponce <david@dponce.com>
9 ;; This is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; This software is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, USA.
24 ;; $Id: erlang.by,v 1.1 2007-11-26 15:11:52 michaels Exp $
27 %package semantic-erlang-by
30 %languagemode erlang-mode
41 %token RECEIVE "receive"
44 %token ORELSE "orelse"
54 %token ANDALSO "andalso"
61 %token MODULE "module"
62 %token INCLUDE "include"
63 %token INCLUDE_LIB "include_lib"
64 %token BEHAVIOUR "behaviour"
65 %token DEFINE "define"
68 %token IFNDEF "ifndef"
71 %token EXPORT "export"
72 %token IMPORT "import"
73 %token RECORD "record"
74 %token SIGNED "signed"
75 %token UNSIGNED "unsigned"
80 %token <punctuation> HASH "\\`[#]\\'"
81 %token <punctuation> PERIOD "\\`[.]\\'"
82 %token <punctuation> COLON "\\`[:]\\'"
83 %token <punctuation> SEMICOLON "\\`[;]\\'"
84 %token <punctuation> STAR "\\`[*]\\'"
85 %token <punctuation> AMPERSAND "\\`[&]\\'"
86 %token <punctuation> DIVIDE "\\`[/]\\'"
87 %token <punctuation> PLUS "\\`[+]\\'"
88 %token <punctuation> MINUS "\\`[-]\\'"
89 %token <punctuation> BANG "\\`[!]\\'"
90 %token <punctuation> WHY "\\`[?]\\'"
91 %token <punctuation> EQUAL "\\`[=]\\'"
92 %token <punctuation> LESS "\\`[<]\\'"
93 %token <punctuation> GREATER "\\`[>]\\'"
94 %token <punctuation> COMA "\\`[,]\\'"
95 %token <punctuation> VDEL "\\`[|]\\'"
96 %token <punctuation> SIGN "[-+]"
97 ;; %token <charquote> DOLLAR "$"
101 %token <symbol> ATOM1 "[a-z][a-zA-Z0-9_@]*"
102 %token <symbol> ATOM2 "'.+'"
103 %token <symbol> DIGITS "[0-9]+"
104 %token <symbol> EE "[eE]"
105 %token <symbol> INT1 "[0-9a-eA-E]+"
106 %token <symbol> INT2 "[0-9]\\{1,2\\}"
107 %token <symbol> VAR1 "^_[a-zA-Z0-9]+"
108 %token <symbol> VAR2 "^[A-Z][_a-zA-Z0-9]*"
109 %token <symbol> USCORE "_"
111 %token <symbol> FILE "file"
112 %token <symbol> INTEGER "integer"
113 %token <symbol> FLOAT "float"
114 %token <symbol> BINARY "binary"
115 %token <symbol> BIG "big"
116 %token <symbol> LITTLE "little"
117 %token <symbol> NATIVE "native"
118 %token <symbol> UNIT "unit"
123 %token <semantic-list> PAREN_BLCK "^("
124 %token <semantic-list> BRACK_BLCK "^\\["
125 %token <semantic-list> BRACE_BLCK "^{"
129 %token <open-paren> LPAREN "("
130 %token <close-paren> RPAREN ")"
131 %token <open-paren> LBRACE "{"
132 %token <close-paren> RBRACE "}"
205 : DIGITS PERIOD DIGITS exp-part
206 | PERIOD DIGITS exp-part
226 ;;($1 variable nil nil nil nil)
227 (VARIABLE-TAG $1 nil nil)
229 ;;($1 variable nil nil nil nil)
230 (VARIABLE-TAG $1 nil nil)
238 : LESS LESS GREATER GREATER
239 ;;( "<<>>" binary nil nil )
241 | LESS LESS binary-segments GREATER GREATER
242 ;;( "<<Binary>>" binary nil nil)
243 (TAG "<<Binary>>" 'binary)
247 : binary-segment binary-segments-rest
251 : COMA binary-segments
257 : basic-type binary-segment-rest
258 | clause-pattern binary-segment-rest
261 ;; binary-segment-rest
262 ;; : COLON integer-literal DIVIDE basic-type
263 ;; | COLON basic-type
264 ;; | DIVIDE basic-type
269 : COLON basic-type DIVIDE binary-type-spec-list
271 | DIVIDE binary-type-spec-list
275 ;; addition by david wallin [david.wallin@ul.ie]
295 : UNIT COLON basic-type
305 binary-type-spec-list
306 : binary-type-spec MINUS binary-type-spec-list
321 : MINUS MODULE PAREN_BLCK full-stop
322 ;;( (car (EXPAND $3 module-attr-name)) package nil nil )
323 (PACKAGE-TAG (car (EXPAND $3 module-attr-name)) nil)
327 : LPAREN module-name RPAREN
332 : atom module-name-rest
333 ( (concat (car $1) (car $2)) )
339 : PERIOD atom module-name-rest
340 ( (concat $1 (car $2) (car $3)) )
364 : MINUS EXPORT PAREN_BLCK full-stop
365 ;;( (car (EXPAND $3 export-name-list)) export nil nil )
369 : open-paren BRACK_BLCK close-paren
370 ;; ( (car (EXPAND $2 function-name-list)) )
374 : MINUS IMPORT PAREN_BLCK full-stop
375 ;;( (car (EXPAND $3 import-name-list)) import nil nil )
376 (TAG (car (EXPAND $3 import-name-list)) 'import)
380 : open-paren module-name COMA BRACK_BLCK close-paren
381 ( ,$2 (EXPAND $4 function-name-list))
382 | open-paren module-name close-paren
387 : open-paren close-paren
389 | open-paren function-names close-paren
394 : function-arity COMA function-names
401 : atom DIVIDE integer-literal
406 : MINUS COMPILE PAREN_BLCK full-stop
407 ;;( $3 compile nil nil )
411 : MINUS FILE PAREN_BLCK full-stop
412 ;;( (car (EXPAND $3 file-attr-list)) file nil nil )
416 : open-paren string COMA integer-literal close-paren
417 ( (cons (read $2) ,$4) )
421 : MINUS atom PAREN_BLCK full-stop
422 ;; ( $3 (read (car $2)) nil nil )
426 : function-clauses full-stop
431 : function-clause function-clauses-rest
435 function-clauses-rest
436 : SEMICOLON function-clauses
442 ;;\( (concat (car $1) "/" (number-to-string (length (car $2))))
443 ;; function nil ,$2 nil nil)
445 (concat (car $1) "/" (number-to-string (length (car $2))))
450 : MINUS RECORD PAREN_BLCK full-stop
451 ( ,(car (EXPANDFULL $3 record-def)) )
455 : open-paren atom COMA BRACE_BLCK close-paren
456 ;;(,$2 type "record" (EXPANDFULL $4 record-field-decl) nil nil)
457 (TYPE-TAG ,$2 "record" (EXPANDFULL $4 record-field-decl) nil)
461 : open-paren record-field-decls close-paren
463 | open-paren close-paren
468 : atom record-field-value
469 ;;( ,$1 variable nil "" () nil)
470 (VARIABLE-TAG ,$1 nil "")
472 ;;( ,$1 variable nil "" () nil)
473 (VARIABLE-TAG ,$1 nil "")
489 ;;( "List" list nil nil )
491 ;; ( (EXPAND $1 list-pattern ) )
493 ;;( "Tuple" tuple nil nil )
495 ;; ( (EXPAND $1 tuple-pattern) )
501 : pattern-conc-expr pattern-conc-expr-rest
510 pattern-conc-expr-rest
511 : list-conc-op pattern-expr
517 : open-paren patterns close-paren
518 | open-paren close-paren
523 : open-paren patterns list-pattern-tail close-paren
524 | open-paren close-paren
535 : pattern patterns-rest
536 ((cons (car $1) (car $2)))
546 : HASH atom BRACE_BLCK
548 ;; ( (cons $2 (EXPAND $3 record-pattern-tuple) ) )
552 : open-paren record-field-patterns close-paren
554 | open-paren close-paren
558 record-field-patterns
559 : record-field-patterns COMA record-field-pattern
560 | record-field-pattern
586 : pattern EQUAL match-expr
591 : compare-expr send-expr-rest
600 : list-conc-expr compare-expr-rest
604 : comp-op list-conc-expr
609 : add-expr list-conc-expr-rest
613 : list-conc-op list-conc-expr
618 : multi-expr add-expr-rest
627 : prefix-expr multi-expr-rest
631 : multi-op multi-expr
636 : prefix-op record-expr
641 : HASH record-expr-field
642 | application-expr record-expr-rest
646 : HASH record-expr-field
653 ;; ( $1 (EXPAND $3 record-update-tuple) )
658 : open-paren close-paren
659 | open-paren record-field-updates close-paren
663 : record-field-update record-field-updates-rest
666 record-field-updates-rest
667 : COMA record-field-updates
672 : atom record-field-value
681 : module-name COLON primary-expr PAREN_BLCK
682 | primary-expr application-expr-rest
685 application-expr-rest
687 ;;( (EXPAND $1 application-expr-list) )
688 | COLON primary-expr PAREN_BLCK
689 ;;( $1 $2 (EXPAND $3 application-expr-list) )
693 application-expr-list
694 : open-paren close-paren
695 | open-paren exprs close-paren
704 ;; ( (EXPAND $1 tuple-skel) )
706 ;; ( (EXPAND $1 list-skel) )
708 ;; ( (EXPAND $1 list-compr) )
721 | string string-literal
725 : open-paren close-paren
726 | open-paren exprs close-paren
730 : open-paren close-paren
731 | open-paren exprs list-skel-tail close-paren
740 : open-paren expr VDEL VDEL list-compr-exprs close-paren
744 : list-compr-expr list-compr-exprs-rest
747 list-compr-exprs-rest
748 : COMA list-compr-exprs
758 : pattern LESS MINUS expr
774 : if-clause SEMICOLON if-clauses
788 : CASE expr OF cr-clauses END
792 : cr-clause SEMICOLON cr-clauses
797 : clause-pattern clause-guard clause-body
806 : RECEIVE cr-clauses receive-after END
807 | RECEIVE receive-after END
808 | RECEIVE cr-clauses AFTER expr clause-body END
812 : AFTER expr clause-body
818 | FUN fun-clauses END
822 : fun-clause fun-clauses-rest
826 : SEMICOLON fun-clauses
831 : PAREN_BLCK clause-guard clause-body
832 ( ,(car (EXPAND $1 clause-pattern-list)) )
836 : open-paren clause-patterns close-paren
841 : clause-pattern clause-patterns-rest
842 ((cons (car $1) (car $2)))
846 : COMA clause-patterns
864 : QUERY BRACK_BLCK END
865 ;; ( $1 (EXPAND $2 list-compr) $3)
870 ;; ( ,(EXPAND $1 paren-expr-list) )
874 : open-paren expr close-paren
878 : guard-test guard-rest
893 ;; ( (EXPAND $1 paren-guard-test) )
898 ;; ( ,(EXPAND $2 guard-record-test) )
899 | open-paren guard-expr COMA symbol close-paren
904 ;; ( ,(cons $1 ,(EXPAND $2 guard-expr) ) )
908 : guard-expr guard-term-op guard-expr
917 : open-paren guard-test close-paren
925 : guard-multi-expr guard-add-expr-rest
929 : add-op guard-add-expr
934 : guard-prefix-expr guard-multi-expr-rest
937 guard-multi-expr-rest
938 : multi-op guard-multi-expr
943 : prefix-op guard-application-expr
944 | guard-application-expr
947 guard-application-expr
949 ;; ( (cons $1 (EXPAND $2 guard-exprs-list) ) )
955 : open-paren close-paren
956 | open-paren guard-exprs close-paren
960 : guard-expr guard-exprs-rest
965 | SEMICOLON guard-exprs
970 : HASH atom PERIOD atom
971 | guard-primary-expr HASH atom PERIOD atom
978 ;; ( ,(EXPAND $1 guard-tuple-skel) )
980 ;; ( ,(EXPAND $1 guard-list-skel) )
982 ;; ( ,(EXPAND $1 guard-paren-expr) )
986 : open-paren close-paren
987 | open-paren guard-exprs close-paren
991 : open-paren close-paren
992 | open-paren guard-exprs guard-list-skel-tail close-paren
1001 : open-paren guard-expr close-paren
1016 : MINUS DEFINE PAREN_BLCK full-stop
1017 ( ,(EXPAND $3 macro-def-list) )
1021 : open-paren symbol macro-def-opt COMA macro-def-opt close-paren
1022 ;;( $2 variable nil $5 (ASSOC const t) nil)
1023 (VARIABLE-TAG $2 nil $5 :constant-flag t)
1033 : MINUS UNDEF PAREN_BLCK full-stop
1037 : WHY symbol PAREN_BLCK
1042 : MINUS INCLUDE PAREN_BLCK full-stop
1043 ;;( (car (EXPAND $3 include-file-name)) include nil nil )
1044 (INCLUDE-TAG (car (EXPAND $3 include-file-name)) nil)
1048 : MINUS INCLUDE_LIB PAREN_BLCK full-stop
1049 ;;( (car (EXPAND $3 include-file-name)) include nil nil )
1050 (INCLUDE-TAG (car (EXPAND $3 include-file-name)) nil)
1054 : open-paren string close-paren
1059 : MINUS IFDEF PAREN_BLCK full-stop
1060 ;;( ,(EXPAND $3 macro-name) )
1064 : MINUS IFNDEF PAREN_BLCK full-stop
1065 ;;( ,(EXPAND $3 macro-name) )
1069 : MINUS ELSE full-stop
1073 : MINUS ENDIF full-stop
1080 ;;; erlang.by ends here