Initial Commit
[packages] / xemacs-packages / semantic / bovine / erlang.by
1 ;;; erlang.by -- LL grammar for Erlang language specification
2 ;;
3 ;; Copyright (C) 2002, 2003 Vladimir G. Sekissov
4 ;; Copyright (C) 2003 David Ponce
5 ;;
6 ;; Author: Vladimir G. Sekissov <svg@surnet.ru>
7 ;;         David Ponce <david@dponce.com>
8 ;;
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)
12 ;; any later version.
13 ;;
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.
18 ;;
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.
23 ;;
24 ;; $Id: erlang.by,v 1.1 2007-11-26 15:11:52 michaels Exp $
25 ;;
26
27 %package semantic-erlang-by
28
29 %start         module-decl
30 %languagemode  erlang-mode
31
32 ;;; Keywords
33 ;;
34 %token BEGIN       "begin"
35 %token END         "end"
36 %token CASE        "case"
37 %token OF          "of"
38 %token IF          "if"
39 %token WHEN        "when"
40 %token TRUE        "true"
41 %token RECEIVE     "receive"
42 %token AFTER       "after"
43 %token OR          "or"
44 %token ORELSE      "orelse"
45 %token XOR         "xor"
46 %token BOR         "bor"
47 %token BXOR        "bxor"
48 %token BSL         "bsl"
49 %token BSR         "bsr"
50 %token DIV         "div"
51 %token REM         "rem"
52 %token BAND        "band"
53 %token AND         "and"
54 %token ANDALSO     "andalso"
55 %token BNOT        "bnot"
56 %token NOT         "not"
57 %token CATCH       "catch"
58 %token FUN         "fun"
59 %token QUERY       "query"
60 %token LET         "let"
61 %token MODULE      "module"
62 %token INCLUDE     "include"
63 %token INCLUDE_LIB "include_lib"
64 %token BEHAVIOUR   "behaviour"
65 %token DEFINE      "define"
66 %token UNDEF       "undef"
67 %token IFDEF       "ifdef"
68 %token IFNDEF      "ifndef"
69 %token ELSE        "else"
70 %token ENDIF       "endif"
71 %token EXPORT      "export"
72 %token IMPORT      "import"
73 %token RECORD      "record"
74 %token SIGNED      "signed"
75 %token UNSIGNED    "unsigned"
76
77
78 ;;; Punctuations
79 ;;
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    "$"
98
99 ;;; Symbol literals
100 ;;
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   "_"
110 ;; binary tokens
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"
119
120
121 ;;; Blocks
122 ;;
123 %token <semantic-list> PAREN_BLCK "^("
124 %token <semantic-list> BRACK_BLCK "^\\["
125 %token <semantic-list> BRACE_BLCK "^{"
126
127 ;;; Parenthesis
128 ;;
129 %token <open-paren>    LPAREN "("
130 %token <close-paren>   RPAREN ")"
131 %token <open-paren>    LBRACE "{"
132 %token <close-paren>   RBRACE "}"
133
134 %%
135
136 add-op
137   : PLUS
138   | MINUS
139   | BOR
140   | BXOR
141   | BSL
142   | BSR
143   ;
144
145 list-conc-op
146   : PLUS PLUS
147   | MINUS MINUS
148   ;
149
150 comp-op
151   : EQUAL EQUAL
152     ( "==" )
153   | EQUAL COLON EQUAL
154     ( "=:=" )
155   | EQUAL DIVIDE EQUAL
156     ( "=/=" )
157   | DIVIDE EQUAL
158     ( "/=" )
159   | EQUAL LESS
160     ( "=<" )
161   | GREATER EQUAL
162     ( ">=" )
163   | LESS
164   | GREATER
165   | OR
166   | ORELSE
167   | XOR
168   | AND
169   | ANDALSO
170   ;
171
172 multi-op
173   : STAR
174   | DIVIDE
175   | DIV
176   | REM
177   | BAND
178   ;
179
180 prefix-op
181   : PLUS
182   | MINUS
183   | BNOT
184   | NOT
185   ;
186
187 basic-type
188   : float-literal
189   | integer-literal
190   | char-literal
191   | atom
192   | var
193   | string
194   | TRUE
195   ;
196
197 atom
198   : ATOM1
199     ( $1 )
200   | ATOM2
201     ( $1 )
202   ;
203
204 float-literal
205   : DIGITS PERIOD DIGITS exp-part
206   | PERIOD DIGITS exp-part
207   ;
208
209 exp-part
210   : EE SIGN DIGITS
211   | EE DIGITS
212   | ;;EMPTY
213   ;
214
215 integer-literal
216   : INT1
217   | INT2 HASH INT1
218   ;
219
220 char-literal
221   : CHAR
222   ;
223
224 var
225   : VAR1
226  ;;($1 variable nil nil nil nil)
227     (VARIABLE-TAG $1 nil nil)
228   | VAR2
229  ;;($1 variable nil nil nil nil)
230     (VARIABLE-TAG $1 nil nil)
231   ;
232
233 uni-pattern
234   : USCORE
235   ;
236
237 binary
238   : LESS LESS GREATER GREATER
239  ;;( "<<>>" binary nil nil )
240     (TAG "<<>>" 'binary)
241   | LESS LESS binary-segments GREATER GREATER
242  ;;( "<<Binary>>" binary nil nil)
243     (TAG "<<Binary>>" 'binary)
244   ;
245
246 binary-segments
247   : binary-segment binary-segments-rest
248   ;
249
250 binary-segments-rest
251   : COMA binary-segments
252     ( ,$2 )
253   | ;;EMPTY
254   ;
255
256 binary-segment
257   : basic-type binary-segment-rest
258   | clause-pattern binary-segment-rest
259   ;
260
261 ;; binary-segment-rest
262 ;;   : COLON integer-literal DIVIDE basic-type
263 ;;   | COLON basic-type
264 ;;   | DIVIDE basic-type
265 ;;   | ;;EMPTY
266 ;;   ;
267
268 binary-segment-rest
269   : COLON basic-type DIVIDE binary-type-spec-list
270   | COLON basic-type
271   | DIVIDE binary-type-spec-list
272   | ;;EMPTY
273   ;
274
275 ;; addition by david wallin [david.wallin@ul.ie]
276
277 binary-type
278   : INTEGER
279   | FLOAT
280   | BINARY
281   ;
282
283 binary-signed
284   : SIGNED
285   | UNSIGNED
286   ;
287
288 binary-endian
289   : BIG
290   | LITTLE
291   | NATIVE
292   ;
293
294 binary-unit
295   : UNIT COLON basic-type
296   ;
297
298 binary-type-spec
299   : binary-type 
300   | binary-signed 
301   | binary-endian 
302   | binary-unit
303   ;
304
305 binary-type-spec-list
306   : binary-type-spec MINUS binary-type-spec-list
307   | binary-type-spec
308   ;
309
310 ;; end addition
311
312 module-decl
313   : module-attr
314   | function-decl
315   | header-form
316   | directive
317   | file-attr
318   ;
319
320 module-attr
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)
324   ;
325
326 module-attr-name
327   : LPAREN module-name RPAREN
328     ( (car $2) )
329   ;
330
331 module-name
332   : atom module-name-rest
333     ( (concat (car $1) (car $2)) )
334   | module-name-rest
335     ( (car $1) )
336   ;
337
338 module-name-rest
339   : PERIOD atom module-name-rest
340     ( (concat $1 (car $2) (car $3)) )
341   | ;;EMPTY
342     ( nil )
343   ;
344
345 header-form
346   : header-attr
347   | anywhere-attr
348   ;
349
350 header-attr
351   : export-attr
352   | import-attr
353   | compile-attr
354   | whild-attr
355   ;
356
357 anywhere-attr
358   : file-attr
359   | macro-def
360   | record-decl
361   ;
362
363 export-attr
364   : MINUS EXPORT PAREN_BLCK full-stop
365  ;;( (car (EXPAND $3 export-name-list)) export nil nil )
366   ;
367
368 export-name-list
369   : open-paren BRACK_BLCK close-paren
370  ;; ( (car (EXPAND $2 function-name-list)) )
371   ;
372
373 import-attr
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)
377   ;
378
379 import-name-list
380   : open-paren module-name COMA BRACK_BLCK close-paren
381     ( ,$2 (EXPAND $4 function-name-list))
382   | open-paren module-name close-paren
383     ( ,$2 )
384   ;
385
386 function-name-list
387   : open-paren close-paren
388     ( nil )
389   | open-paren function-names close-paren
390     ( $2 )
391   ;
392
393 function-names
394   : function-arity COMA function-names
395     ( $1  $3 )
396   | function-arity
397     ( $1 )
398   ;
399
400 function-arity
401   : atom DIVIDE integer-literal
402     ( ,$1 $2 ,$3 )
403   ;
404
405 compile-attr
406   : MINUS COMPILE PAREN_BLCK full-stop
407  ;;( $3 compile nil nil )
408   ;
409
410 file-attr
411   : MINUS FILE PAREN_BLCK full-stop
412  ;;( (car (EXPAND $3 file-attr-list)) file nil nil )
413   ;
414
415 file-attr-list
416   : open-paren string COMA integer-literal close-paren
417     ( (cons (read $2) ,$4) )
418   ;
419
420 whild-attr
421   : MINUS atom PAREN_BLCK full-stop
422  ;; ( $3 (read (car $2)) nil nil )
423   ;
424
425 function-decl
426   : function-clauses full-stop
427     ( ,$1 )
428   ;
429
430 function-clauses
431   : function-clause function-clauses-rest
432     ( ,$1 )
433   ;
434
435 function-clauses-rest
436   : SEMICOLON function-clauses
437   | ;;EMPTY
438   ;
439
440 function-clause
441   : atom fun-clause
442  ;;\( (concat (car $1) "/" (number-to-string (length (car $2))))
443  ;;  function nil ,$2 nil nil)
444     (FUNCTION-TAG
445      (concat (car $1) "/" (number-to-string (length (car $2))))
446      nil ,$2)
447   ;
448
449 record-decl
450   : MINUS RECORD PAREN_BLCK full-stop
451     ( ,(car (EXPANDFULL $3 record-def)) )
452   ;
453
454 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)
458   ;
459
460 record-decl-tuple
461   : open-paren record-field-decls close-paren
462     ( $2 )
463   | open-paren close-paren
464     ( nil )
465   ;
466
467 record-field-decl
468   : atom record-field-value
469  ;;( ,$1 variable nil "" () nil)
470     (VARIABLE-TAG ,$1 nil "")
471   | atom
472  ;;( ,$1 variable nil "" () nil)
473     (VARIABLE-TAG ,$1 nil "")
474   | LBRACE
475     ( nil )
476   | RBRACE
477     ( nil )
478   | COMA
479     ( nil )
480   ;
481
482 pattern
483   : pattern-expr
484     ( ,$1 )
485   | uni-pattern
486   | binary
487   | basic-type
488   | BRACK_BLCK
489  ;;( "List" list nil nil )
490     (TAG "List" 'list)
491  ;; ( (EXPAND $1 list-pattern ) )
492   | BRACE_BLCK
493  ;;( "Tuple" tuple nil nil )
494     (TAG "Tuple" 'list)
495  ;; ( (EXPAND $1 tuple-pattern) )
496   | record-pattern
497     ( ,$1 )
498   ;
499
500 pattern-expr
501   : pattern-conc-expr pattern-conc-expr-rest
502     ( ,$1 )
503   ;
504
505 pattern-conc-expr
506   : string-literal
507   | var
508   ;
509
510 pattern-conc-expr-rest
511   : list-conc-op pattern-expr
512     ( )
513   | ;;EMPTY
514   ;
515
516 tuple-pattern
517   : open-paren patterns close-paren
518   | open-paren close-paren
519     ( nil )
520   ;
521
522 list-pattern
523   : open-paren patterns list-pattern-tail close-paren
524   | open-paren close-paren
525     ( nil )
526   ;
527
528 list-pattern-tail
529   : VDEL pattern
530   | ;;EMPTY
531     ( nil )
532   ;
533
534 patterns
535   : pattern patterns-rest
536     ((cons (car $1) (car $2)))
537   ;
538
539 patterns-rest
540   : COMA patterns
541     ( ,$2 )
542   | ;;EMPTY
543   ;
544
545 record-pattern
546   : HASH atom BRACE_BLCK
547     ( (car $2) )
548  ;; ( (cons $2 (EXPAND $3 record-pattern-tuple) ) )
549   ;
550
551 record-pattern-tuple
552   : open-paren record-field-patterns close-paren
553     ( $2 )
554   | open-paren close-paren
555     ( nil )
556   ;
557
558 record-field-patterns
559   : record-field-patterns COMA record-field-pattern
560   | record-field-pattern
561   ;
562
563 record-field-pattern
564   : atom EQUAL pattern
565   ;
566
567 body
568   : exprs
569   ;
570
571 exprs
572   : expr exprs-rest
573   ;
574
575 exprs-rest
576   : COMA exprs
577   | ;;EMPTY
578   ;
579
580 expr
581   : CATCH expr
582   | match-expr
583   ;
584
585 match-expr
586   : pattern EQUAL match-expr
587   | send-expr
588   ;
589
590 send-expr
591   : compare-expr send-expr-rest
592   ;
593
594 send-expr-rest
595   : BANG send-expr
596   | ;;EMPTY
597   ;
598
599 compare-expr
600   : list-conc-expr compare-expr-rest
601   ;
602
603 compare-expr-rest
604   : comp-op list-conc-expr
605   | ;;EMPTY
606   ;
607
608 list-conc-expr
609   : add-expr list-conc-expr-rest
610   ;
611
612 list-conc-expr-rest
613   : list-conc-op list-conc-expr
614   | ;;EMPTY
615   ;
616
617 add-expr
618   : multi-expr add-expr-rest
619   ;
620
621 add-expr-rest
622   : add-op add-expr
623   | ;;EMPTY
624   ;
625
626 multi-expr
627   : prefix-expr multi-expr-rest
628   ;
629
630 multi-expr-rest
631   : multi-op multi-expr
632   | ;;EMPTY
633   ;
634
635 prefix-expr
636   : prefix-op record-expr
637   | record-expr
638   ;
639
640 record-expr
641   : HASH record-expr-field
642   | application-expr record-expr-rest
643   ;
644
645 record-expr-rest
646   : HASH record-expr-field
647   | ;;EMPTY
648   ;
649
650 record-expr-field
651   : atom PERIOD atom
652   | atom BRACE_BLCK
653  ;; ( $1 (EXPAND $3 record-update-tuple) )
654   | record-expr
655   ;
656
657 record-update-tuple
658   : open-paren close-paren
659   | open-paren record-field-updates close-paren
660   ;
661
662 record-field-updates
663   : record-field-update record-field-updates-rest
664   ;
665
666 record-field-updates-rest
667   : COMA record-field-updates
668   | ;;EMPTY
669   ;
670
671 record-field-update
672   : atom record-field-value
673   ;
674
675 record-field-value
676   : EQUAL expr
677   | ;;EMPTY
678   ;
679
680 application-expr
681   : module-name COLON primary-expr PAREN_BLCK
682   | primary-expr application-expr-rest
683   ;
684
685 application-expr-rest
686   : PAREN_BLCK
687  ;;( (EXPAND $1 application-expr-list) )
688   | COLON primary-expr PAREN_BLCK
689  ;;( $1 $2 (EXPAND $3 application-expr-list) )
690   | ;;EMPTY
691   ;
692
693 application-expr-list
694   : open-paren close-paren
695   | open-paren exprs close-paren
696   ;
697
698 primary-expr
699   : binary
700   | string-literal
701   | basic-type
702  ;;| module-name
703   | BRACE_BLCK
704  ;;  ( (EXPAND $1 tuple-skel) )
705   | BRACK_BLCK
706  ;;  ( (EXPAND $1 list-skel) )
707   | BRACK_BLCK
708  ;;  ( (EXPAND $1 list-compr) )
709   | block-expr
710   | if-expr
711   | case-expr
712   | receive-expr
713   | fun-expr
714   | query-expr
715   | paren-expr
716   ;
717
718 string-literal
719   : string
720   | macro-app
721   | string string-literal
722   ;
723
724 tuple-skel
725   : open-paren close-paren
726   | open-paren exprs close-paren
727   ;
728
729 list-skel
730   : open-paren close-paren
731   | open-paren exprs list-skel-tail close-paren
732   ;
733
734 list-skel-tail
735   : VDEL expr
736   | ;;EMPTY
737   ;
738
739 list-compr
740   : open-paren expr VDEL VDEL list-compr-exprs close-paren
741   ;
742
743 list-compr-exprs
744   : list-compr-expr list-compr-exprs-rest
745   ;
746
747 list-compr-exprs-rest
748   : COMA list-compr-exprs
749   | ;;EMPTY
750   ;
751
752 list-compr-expr
753   : generator
754   | filter
755   ;
756
757 generator
758   : pattern LESS MINUS expr
759   ;
760
761 filter
762   : expr
763   ;
764
765 block-expr
766   : BEGIN body END
767   ;
768
769 if-expr
770   : IF if-clauses END
771   ;
772
773 if-clauses
774   : if-clause SEMICOLON if-clauses
775   | if-clause
776   ;
777
778 if-clause
779   : guard clause-body
780   | expr clause-body
781   ;
782
783 clause-body
784   : MINUS GREATER body
785   ;
786
787 case-expr
788   : CASE expr OF cr-clauses END
789   ;
790
791 cr-clauses
792   : cr-clause SEMICOLON cr-clauses
793   | cr-clause
794   ;
795
796 cr-clause
797   : clause-pattern clause-guard clause-body
798   ;
799
800 clause-guard
801   : WHEN guard
802   | ;;EMPTY
803   ;
804
805 receive-expr
806   : RECEIVE cr-clauses receive-after END
807   | RECEIVE receive-after END
808   | RECEIVE cr-clauses AFTER expr clause-body END
809   ;
810
811 receive-after
812   : AFTER expr clause-body
813   | ;;EMPTY
814   ;
815
816 fun-expr
817   : FUN function-arity
818   | FUN fun-clauses END
819   ;
820
821 fun-clauses
822   : fun-clause fun-clauses-rest
823   ;
824
825 fun-clauses-rest
826   : SEMICOLON fun-clauses
827   | ;;EMPTY
828   ;
829
830 fun-clause
831   : PAREN_BLCK clause-guard clause-body
832     ( ,(car (EXPAND $1 clause-pattern-list)) )
833   ;
834
835 clause-pattern-list
836   : open-paren clause-patterns close-paren
837     ( $2 )
838   ;
839
840 clause-patterns
841   : clause-pattern clause-patterns-rest
842     ((cons (car $1) (car $2)))
843   ;
844
845 clause-patterns-rest
846   : COMA clause-patterns
847     ( ,$2 )
848   | ;;EMPTY
849   ;
850
851 clause-pattern
852   : match-pattern
853   | pattern
854   ;
855
856 match-pattern
857   : var EQUAL pattern
858     ( ,$1 )
859   | pattern EQUAL var
860     ( ,$1 )
861   ;
862
863 query-expr
864   : QUERY BRACK_BLCK END
865  ;; ( $1 (EXPAND $2 list-compr) $3)
866   ;
867
868 paren-expr
869   : PAREN_BLCK
870  ;;  ( ,(EXPAND $1 paren-expr-list) )
871   ;
872
873 paren-expr-list
874   : open-paren expr close-paren
875   ;
876
877 guard
878   : guard-test guard-rest
879   ;
880
881 guard-rest
882   : COMA guard
883   | SEMICOLON guard
884   | ;;EMPTY
885   ;
886
887 guard-test
888   : TRUE
889   | guard-record-test
890   | guard-term-cmp
891   | guard-recognizer
892   | PAREN_BLCK
893  ;;  ( (EXPAND $1 paren-guard-test) )
894   ;
895
896 guard-record-test
897   : RECORD PAREN_BLCK
898  ;;  ( ,(EXPAND $2 guard-record-test) )
899   | open-paren guard-expr COMA symbol close-paren
900   ;
901
902 guard-recognizer
903   : symbol PAREN_BLCK
904  ;;  ( ,(cons $1 ,(EXPAND $2 guard-expr) ) )
905   ;
906
907 guard-term-cmp
908   : guard-expr guard-term-op guard-expr
909   ;
910
911 guard-term-op
912   : comp-op
913   | EQUAL
914   ;
915
916 paren-guard-test
917   : open-paren guard-test close-paren
918   ;
919
920 guard-expr
921   : guard-add-expr
922   ;
923
924 guard-add-expr
925   : guard-multi-expr guard-add-expr-rest
926   ;
927
928 guard-add-expr-rest
929   : add-op guard-add-expr
930   | ;;EMPTY
931   ;
932
933 guard-multi-expr
934   : guard-prefix-expr guard-multi-expr-rest
935   ;
936
937 guard-multi-expr-rest
938   : multi-op guard-multi-expr
939   | ;;EMPTY
940   ;
941
942 guard-prefix-expr
943   : prefix-op guard-application-expr
944   | guard-application-expr
945   ;
946
947 guard-application-expr
948   : atom PAREN_BLCK
949  ;;  ( (cons $1 (EXPAND $2 guard-exprs-list) ) )
950   | guard-record-expr
951   | guard-primary-expr
952   ;
953
954 guard-exprs-list
955   : open-paren close-paren
956   | open-paren guard-exprs close-paren
957   ;
958
959 guard-exprs
960   : guard-expr guard-exprs-rest
961   ;
962
963 guard-exprs-rest
964   : COMA guard-exprs
965   | SEMICOLON guard-exprs
966   | ;;EMPTY
967   ;
968
969 guard-record-expr
970   : HASH atom PERIOD atom
971   | guard-primary-expr HASH atom PERIOD atom
972   ;
973
974 guard-primary-expr
975   : basic-type
976   | macro-app
977   | BRACE_BLCK
978  ;;  ( ,(EXPAND $1 guard-tuple-skel) )
979   | BRACK_BLCK
980  ;;  ( ,(EXPAND $1 guard-list-skel) )
981   | PAREN_BLCK
982  ;;  ( ,(EXPAND $1 guard-paren-expr) )
983   ;
984
985 guard-tuple-skel
986   : open-paren close-paren
987   | open-paren guard-exprs close-paren
988   ;
989
990 guard-list-skel
991   : open-paren close-paren
992   | open-paren guard-exprs guard-list-skel-tail close-paren
993   ;
994
995 guard-list-skel-tail
996   : VDEL guard-expr
997   | ;;EMPTY
998   ;
999
1000 guard-paren-expr
1001   : open-paren guard-expr close-paren
1002   ;
1003
1004 directive
1005   : macro-def
1006   | macro-undef
1007   | include-dir
1008   | include-lib-dir
1009   | ifdef-dir
1010   | ifndef-dir
1011   | else-dir
1012   | endif-dir
1013   ;
1014
1015 macro-def
1016   : MINUS DEFINE PAREN_BLCK full-stop
1017     ( ,(EXPAND $3 macro-def-list) )
1018   ;
1019
1020 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)
1024   ;
1025
1026 macro-def-opt
1027   : semantic-list
1028   | expr
1029   | ;;EMPTY
1030   ;
1031
1032 macro-undef
1033   : MINUS UNDEF PAREN_BLCK full-stop
1034   ;
1035
1036 macro-app
1037   : WHY symbol PAREN_BLCK
1038   | WHY symbol
1039   ;
1040
1041 include-dir
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)
1045   ;
1046
1047 include-lib-dir
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)
1051   ;
1052
1053 include-file-name
1054   : open-paren string close-paren
1055     ( (read $2) )
1056   ;
1057
1058 ifdef-dir
1059   : MINUS IFDEF PAREN_BLCK full-stop
1060  ;;( ,(EXPAND $3 macro-name) )
1061   ;
1062
1063 ifndef-dir
1064   : MINUS IFNDEF PAREN_BLCK full-stop
1065  ;;( ,(EXPAND $3 macro-name) )
1066   ;
1067
1068 else-dir
1069   : MINUS ELSE full-stop
1070   ;
1071
1072 endif-dir
1073   : MINUS ENDIF full-stop
1074   ;
1075
1076 full-stop
1077   : PERIOD
1078   ;
1079
1080 ;;; erlang.by ends here