Open mingodad opened 3 years ago
This is another view of the same grammar with several duplications and indirections removed, it's full of commented out pieces to allow compare with the original (ideally they would be removed after finishing the cleanup).
I think that's worth spend some time playing with the grammar in EBNF form using https://www.bottlecaps.de/rr/ui to help visualize it before go forward implementing it because it can save writing a ton of lines of code.
/************************************************************************/
/* */
/* Applied Type System */
/* */
/* Hongwei Xi */
/* */
/************************************************************************/
/*
** ATS/Anairiats - Unleashing the Potential of Types!
**
** Copyright (C) 2002-2008 Hongwei Xi.
**
** All rights reserved
**
** ATS is free software; you can redistribute it and/or modify it under
** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
** Free Software Foundation; either version 3, or (at your option) any
** later version.
**
** ATS 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 ATS; see the file COPYING. If not, please write to the
** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
** 02110-1301, USA.
*/
/* ****** ****** */
//
// Author: Hongwei Xi (hwxi AT cs DOT bu DOT edu)
// Start time: July 2007
//
// This version is prepared together with
// Sylvain Nahas (sylvain.nahas AT googlemail DOT com)
//
/* ****** ****** */
/*
Grammar for ATS/Anairiats
Some Explanation on the EBNF Notation
"..." : terminal string
::= : nonterminal definition
a , b : concatenation
(...) : grouping
{a} : 0 or more a (Kleene's star closure)
{a}+ : 1 or more a (this is an extension to the standard EBNF)
[a] : 0 or 1 a (option)
a | b : a or b (alternation)
*/
/*...*/ //: comment
program ::=
/*|*/ YYBEG_d0ecseq_sta d0ecseq_sta TOKEN_eof
| YYBEG_d0ecseq_dyn d0ecseq_dyn TOKEN_eof
| YYBEG_i0de i0de TOKEN_eof
| YYBEG_s0rtid s0rtid TOKEN_eof
| YYBEG_si0de si0de TOKEN_eof
| YYBEG_di0de di0de TOKEN_eof
| YYBEG_s0exp s0exp TOKEN_eof
| YYBEG_d0exp d0exp TOKEN_eof
/* program */
//abskind ::=
// /*|*/ "absprop"
// | "abstype"
// | "abst@ype"
// | "absview"
// | "absviewtype"
// | "absviewt@ype"
///* abskind */
dcstkind ::=
/*|*/ "fun"
| "val"
| "castfn"
| "praxi"
| "prfun"
| "prval"
/* dcstkind */
//datakind ::=
// /*|*/ "dataprop"
// | "datatype"
// | "dataview"
// | "dataviewtype"
///* datakind */
//stadefkind ::=
// /*|*/ "stadef"
// | "propdef"
// | "typedef"
// | "viewdef"
// | "viewtypedef"
///* stadefkind */
//valkind ::=
// /*|*/ "val"
// | "val-"
// | "val+"
// | "prval"
///* valkind */
//funkind ::=
// /*|*/ "fn"
// | "fn*"
// | "fun"
// | "castfn"
// | "prfn"
// | "prfun"
///* funkind */
//lamkind ::=
// /*|*/ "lam"
// | "@lam"
// | "llam"
// | "@llam"
///* lamkind */
//fixkind ::=
// /*|*/ "fix"
// | "@fix"
///* fixkind */
srpifkind ::=
/*|*/ "#if"
| "#ifdef"
| "#ifndef"
/* srpifkind */
srpelifkind ::=
/*|*/ "#elif"
| "#elifdef"
| "#elifndef"
/* srpelifkind */
srpthenopt ::=
/*|*/ "#then"?
/* srpthenopt */
i0de ::=
/*|*/ ALNUMRIC_IDENTIFIER
| SYMBOLIC_IDENTIFIER
| "&"
| "\"
| "!"
| "="
| ">"
| "><"
| "<"
| "->"
| "-<>"
| "~"
/* i0de */
i0de_dlr ::=
/*|*/ IDENTIFIER_dlr
/* i0de_dlr */
//i0deseq ::=
// /*|*/ i0de*
///* i0deseq */
//i0dext ::=
// /*|*/ EXTERNAL_IDENTIFIER
// | "do"
// | "while"
///* i0dext */
l0ab ::=
/*|*/ i0de
| LITERAL_int
| "(" l0ab ")"
/* l0ab */
//stai0de ::=
// /*|*/ ALNUMRIC_IDENTIFIER
///* stai0de */
//p0rec ::=
// //| /*(empty)*/
// (
// /*|*/ LITERAL_int
// | "(" i0de ")"
// | "(" i0de SYMBOLIC_IDENTIFIER LITERAL_int ")"
// )?
///* p0rec */
e0xp ::=
/*|*/ /*atme0xp*/(
LITERAL_char
| LITERAL_float
| LITERAL_int
| LITERAL_string
| "#FILENAME"
| "#LOCATION"
| i0de
| "(" /*e0xpseq*/ (e0xp /*commae0xpseq*/ ("," e0xp)*)? ")"
| "%(" e0xp ")"
)+
/* e0xp */
//atme0xp ::=
// /*|*/ LITERAL_char
// | LITERAL_float
// | LITERAL_int
// | LITERAL_string
// | "#FILENAME"
// | "#LOCATION"
// | i0de
// | "(" e0xpseq ")"
// | "%(" e0xp ")"
///* atme0xp */
//e0xpseq ::=
// //| /*(empty)*/
// /*|*/ (e0xp commae0xpseq)?
///* e0xpseq */
//commae0xpseq ::=
// /*|*/ ("," e0xp)*
///* commae0xpseq */
//e0xpopt ::=
// /*|*/ e0xp?
///* e0xpopt */
//e0ffid ::=
// /*|*/ ALNUMRIC_IDENTIFIER
///* e0ffid */
e0fftag ::=
///*|*/ "!" e0ffid
//| "~" e0ffid
('!' | '~')? /*e0ffid*/ ALNUMRIC_IDENTIFIER
| "fun"
| LITERAL_int
/* e0fftag */
e0fftagseq ::=
//| /*(empty)*/
/*|*/ (e0fftag /*commae0fftagseq*/ ("," e0fftag)*)?
/* e0fftagseq */
//commae0fftagseq ::=
// /*|*/ ("," e0fftag)*
///* commae0fftagseq */
colonwith ::=
/*|*/ ":"
| ":<>"
| ":<" e0fftagseq ">"
/* colonwith */
s0rt ::=
/*|*/ /*atms0rt*/
(
s0rtid
| /*s0rtq*/ ( i0de_dlr "." | "$" LITERAL_string ".") s0rtid
//| "(" s0rtseq ")"
| "@"? "(" /*s0rtseq*/ (s0rt /*commas0rtseq*/ ("," s0rt)*)? ")"
)+
/* s0rt */
//s0rtq ::=
// /*|*/ i0de_dlr "."
// | "$" LITERAL_string "."
///* s0rtq */
s0rtid ::=
/*|*/ ALNUMRIC_IDENTIFIER
| SYMBOLIC_IDENTIFIER
| "t@ype"
| "viewt@ype"
| "\"
| "->"
| "-<>"
/* s0rtid */
//atms0rt ::=
// /*|*/ s0rtid
// | /*s0rtq*/ ( i0de_dlr "." | "$" LITERAL_string ".") s0rtid
// | "(" s0rtseq ")"
// | "@(" s0rtseq ")"
///* atms0rt */
//s0rtseq ::=
// //| /*(empty)*/
// /*|*/ (s0rt commas0rtseq)?
///* s0rtseq */
//commas0rtseq ::=
// /*|*/ ("," s0rt)*
///* commas0rtseq */
//s0rtpol ::=
// /*|*/ s0rt
// | "prop-"
// | "prop+"
// | "type-"
// | "type+"
// | "t@ype-"
// | "t@ype+"
// | "view-"
// | "view+"
// | "viewtype-"
// | "viewtype+"
// | "viewt@ype-"
// | "viewt@ype+"
///* s0rtpol */
d0atsrtcon ::=
/*|*/ i0de
| i0de "of" s0rt
/* d0atsrtcon */
//d0atsrtconseq ::=
// /*|*/ bard0atsrtconseq
// | d0atsrtcon bard0atsrtconseq
///* d0atsrtconseq */
//bard0atsrtconseq ::=
// /*|*/ ("|" d0atsrtcon)*
///* bard0atsrtconseq */
d0atsrtdec ::=
/*|*/ i0de "=" /*d0atsrtconseq*/ (d0atsrtcon? /*bard0atsrtconseq*/ ("|" d0atsrtcon)*)
/* d0atsrtdec */
//andd0atsrtdecseq ::=
// /*|*/ ("and" d0atsrtdec)*
///* andd0atsrtdecseq */
s0taq ::=
/*|*/ i0de_dlr "."
| i0de_dlr ":"
| "$" LITERAL_string "."
/* s0taq */
d0ynq ::=
/*|*/ i0de_dlr "."
| i0de_dlr ":"
| i0de_dlr i0de_dlr ":"
| "$" LITERAL_string "."
| "$" LITERAL_string i0de_dlr ":"
/* d0ynq */
si0de ::=
/*|*/ ALNUMRIC_IDENTIFIER
| SYMBOLIC_IDENTIFIER
| "r@ead"
| "&"
| "\"
| "!"
| ">"
| "<"
| "->"
| "~"
/* si0de */
sqi0de ::=
/*|*/ si0de
| s0taq si0de
/* sqi0de */
//commasi0deseq ::=
// /*|*/ ("," si0de)*
///* commasi0deseq */
di0de ::=
/*|*/ ALNUMRIC_IDENTIFIER
| SYMBOLIC_IDENTIFIER
| "\"
| "!"
| "="
| ">"
| "><"
| "<"
| "~"
/* di0de */
dqi0de ::=
/*|*/ di0de
| d0ynq di0de
/* dqi0de */
pi0de ::=
/*|*/ ALNUMRIC_IDENTIFIER
| SYMBOLIC_IDENTIFIER
/* pi0de */
//fi0de ::=
// /*|*/ di0de
// | "op" di0de
///* fi0de */
//arri0de ::=
// /*|*/ ARRAY_IDENTIFIER
///* arri0de */
//arrqi0de ::=
// ///*|*/ arri0de
// /*|*/ d0ynq? ARRAY_IDENTIFIER
///* arrqi0de */
//tmpi0de ::=
// /*|*/ TEMPLATE_IDENTIFIER
///* tmpi0de */
tmpqi0de ::=
/*|*/ tmpi0de
/*|*/ d0ynq? TEMPLATE_IDENTIFIER
/* tmpqi0de */
colons0rtopt ::=
/*|*/ (":" s0rt)?
/* colons0rtopt */
s0arg ::=
/*|*/ si0de colons0rtopt
/* s0arg */
s0argseq ::=
//| /*(empty)*/
/*|*/ (s0arg /*commas0argseq*/ ("," s0arg)*)?
/* s0argseq */
//commas0argseq ::=
// /*|*/ ("," s0arg)*
///* commas0argseq */
s0argseqseq ::=
//| /*(empty)*/
(
/*|*/ si0de s0argseqseq
| "(" s0argseq ")" s0argseqseq
)?
/* s0argseqseq */
//decs0argseq ::=
// //| /*(empty)*/
// /*|*/ (s0arg commadecs0argseq)?
///* decs0argseq */
//commadecs0argseq ::=
// /*|*/ ("," s0arg)*
///* commadecs0argseq */
decs0argseqseq ::=
//| /*(empty)*/
/*|*/ ("{" /*decs0argseq*/ (s0arg /*commadecs0argseq*/ ("," s0arg)*)? "}" decs0argseqseq)?
/* decs0argseqseq */
//sp0at ::=
// /*|*/ sqi0de "(" s0argseq ")"
///* sp0at */
s0exp ::=
/*|*/ apps0exp
| exts0exp
| s0exp ":" s0rt
| "lam" s0argseqseq colons0rtopt "=>" s0exp
/* s0exp */
atms0exp ::=
/*|*/ LITERAL_char
| LITERAL_int
| LITERAL_intsp
| si0de
| "op" si0de
| s0taq si0de
| "(" s0expseq ")"
| "(" s0expseq "|" s0expseq ")"
| "@(" s0expseq ")"
| "'(" s0expseq ")"
| "$tup_t" "(" s0expseq ")"
| "$tup_vt" "(" s0expseq ")"
| "@(" s0expseq "|" s0expseq ")"
| "'(" s0expseq "|" s0expseq ")"
| "$tup_t" "(" s0expseq "|" s0expseq ")"
| "$tup_vt" "(" s0expseq "|" s0expseq ")"
//| "@{" labs0expseq "}"
//| "'{" labs0expseq "}"
//| "$rec_t" "{" labs0expseq "}"
//| "$rec_vt" "{" labs0expseq "}"
//| "$extype_struct" LITERAL_string "of" "{" labs0expseq "}"
| (
'@'? '{'
| "$rec_t"
| "$rec_vt"
| "$extype_struct" LITERAL_string "of"
) '{' (l0ab "=" s0exp /*commalabs0expseq*/ ("," l0ab "=" s0exp)*)? '}'
| "@[" s0exp "]" "[" s0arrind
| "-<" e0fftagseq ">"
| "-<>"
| "{" s0quaseq "}"
| "[" s0quaseq "]"
| "#[" s0quaseq "]"
/* atms0exp */
apps0exp ::=
/*|*/ atms0exp+
/* apps0exp */
exts0exp ::=
/*|*/ "$extype" LITERAL_string
| exts0exp atms0exp
/* exts0exp */
//s0expelt ::=
// //| /*(empty)*/
// (
// /*|*/ "{" s0exp "}"
// | "[" s0exp "]"
// )?
///* s0expelt */
s0arrind ::=
/*|*/ s0expseq "]"
| s0expseq "]" "[" s0arrind
/* s0arrind */
s0qua ::=
/*|*/ apps0exp
| si0de /*commasi0deseq*/ ("," si0de)* ":" s0rtext
/* s0qua */
s0quaseq ::=
//| /*(empty)*/
/*|*/ (s0qua /*barsemis0quaseq*/ (("|" | ";") s0qua)*)?
/* s0quaseq */
//barsemis0quaseq ::=
// /*|*/ (("|" | ";") s0qua)*
///* barsemis0quaseq */
s0rtext ::=
/*|*/ s0rt
| "{" si0de ":" s0rtext "|" s0exp /*barsemis0expseq*/ (("|" | ";") s0exp)* "}"
/* s0rtext */
s0expseq ::=
//| /*(empty)*/
/*|*/ s0expseq1?
/* s0expseq */
//barsemis0expseq ::=
// /*|*/ (("|" | ";") s0exp)*
///* barsemis0expseq */
//commas0expseq ::=
// /*|*/ ("," s0exp)*
///* commas0expseq */
//
s0expseq1 ::=
/*|*/ s0exp /*commas0expseq*/ ("," s0exp)*
/* s0expseq1 */
//labs0expseq ::=
// //| /*(empty)*/
// /*|*/ (l0ab "=" s0exp commalabs0expseq)?
///* labs0expseq */
//commalabs0expseq ::=
// /*|*/ ("," l0ab "=" s0exp)*
///* commalabs0expseq */
//t0mps0exp ::=
// /*|*/ atms0exp+
///* t0mps0exp */
//t1mps0exp ::=
// /*|*/ /*t0mps0exp*/ atms0exp+
///* t1mps0exp */
t1mps0expseq ::=
//| /*(empty)*/
/*|*/ (/*t1mps0exp*/ atms0exp+ /*commat1mps0expseq*/ ("," /*t1mps0exp*/ atms0exp+)*)?
/* t1mps0expseq */
//commat1mps0expseq ::=
// /*|*/ ("," t1mps0exp)*
///* commat1mps0expseq */
gtlt_t1mps0expseqseq ::=
//| /*(empty)*/
/*|*/ ("><" t1mps0expseq gtlt_t1mps0expseqseq)?
/* gtlt_t1mps0expseqseq */
//impqi0de ::=
// /*|*/ dqi0de
// | tmpqi0de t1mps0expseq gtlt_t1mps0expseqseq ">"
///* impqi0de */
s0rtdef ::=
/*|*/ s0rtid "=" s0rtext
/* s0rtdef */
//ands0rtdefseq ::=
// /*|*/ ("and" s0rtdef)*
///* ands0rtdefseq */
d0atarg ::=
///*|*/ s0rtpol
/*|*/ (i0de ":")? /*s0rtpol*/
(
s0rt
| "prop-"
| "prop+"
| "type-"
| "type+"
| "t@ype-"
| "t@ype+"
| "view-"
| "view+"
| "viewtype-"
| "viewtype+"
| "viewt@ype-"
| "viewt@ype+"
)
/* d0atarg */
d0atargseq ::=
//| /*(empty)*/
/*|*/ (d0atarg /*commad0atargseq*/ ("," d0atarg)*)?
/* d0atargseq */
//commad0atargseq ::=
// /*|*/ ("," d0atarg)*
///* commad0atargseq */
s0tacon ::=
/*|*/ si0de
| si0de "(" d0atargseq ")"
| si0de "=" s0exp
| si0de "(" d0atargseq ")" "=" s0exp
/* s0tacon */
//ands0taconseq ::=
// /*|*/ ("and" s0tacon)*
///* ands0taconseq */
s0tacst ::=
/*|*/ si0de ":" s0rt
| si0de "(" d0atargseq ")" ":" s0rt
/* s0tacst */
//ands0tacstseq ::=
// /*|*/ ("and" s0tacst)*
///* ands0tacstseq */
s0tavar ::=
/*|*/ si0de ":" s0rt
/* s0tavar */
//ands0tavarseq ::=
// /*|*/ ("and" s0tavar)*
///* ands0tavarseq */
s0expdef ::=
/*|*/ si0de s0argseqseq colons0rtopt "=" s0exp
/* s0expdef */
ands0expdefseq ::=
/*|*/ ("and" s0expdef)*
/* ands0expdefseq */
//s0aspdec ::=
// /*|*/ sqi0de s0argseqseq colons0rtopt "=" s0exp
///* s0aspdec */
conq0uaseq ::=
//| /*(empty)*/
/*|*/ ("{" s0quaseq "}" conq0uaseq)?
/* conq0uaseq */
//coni0ndopt ::=
// //| /*(empty)*/
// /*|*/ ("(" s0expseq ")")?
///* coni0ndopt */
cona0rgopt ::=
//| /*(empty)*/
/*|*/ ("of" s0exp)?
/* cona0rgopt */
d0atcon ::=
/*|*/ conq0uaseq di0de /*coni0ndopt*/ ("(" s0expseq ")")? cona0rgopt
/* d0atcon */
//d0atconseq ::=
// /*|*/ bard0atconseq
// | d0atcon bard0atconseq
///* d0atconseq */
//bard0atconseq ::=
// /*|*/ ("|" d0atcon)*
///* bard0atconseq */
d0atdec ::=
///*|*/ si0de "=" d0atconseq
/*|*/ si0de ("(" d0atargseq ")")? "=" /*d0atconseq*/ d0atcon ("|" d0atcon)*
/* d0atdec */
//andd0atdecseq ::=
// /*|*/ ("and" d0atdec)*
///* andd0atdecseq */
//s0expdefseqopt ::=
// //| /*(empty)*/
// /*|*/ ("where" s0expdef ands0expdefseq)?
///* s0expdefseqopt */
e0xndec ::=
/*|*/ conq0uaseq di0de cona0rgopt
/* e0xndec */
//ande0xndecseq ::=
// /*|*/ ("and" e0xndec)*
///* ande0xndecseq */
p0arg ::=
/*|*/ pi0de
| pi0de ":" s0exp
/* p0arg */
p0argseq ::=
//| /*(empty)*/
/*|*/ (p0arg /*commap0argseq*/ ("," p0arg)*)?
/* p0argseq */
//commap0argseq ::=
// /*|*/ ("," p0arg)*
///* commap0argseq */
//d0arg ::=
// /*|*/ pi0de
// | "(" p0argseq ("|" p0argseq)? ")"
// | "{" s0quaseq "}"
///* d0arg */
//d0argseq ::=
// /*|*/ /*d0arg*/ (
// pi0de
// | "(" p0argseq ("|" p0argseq)? ")"
// | "{" s0quaseq "}"
// )*
///* d0argseq */
//extnamopt ::=
// //| /*(empty)*/
// /*|*/ ("=" LITERAL_string)?
///* extnamopt */
d0cstdec ::=
/*|*/ di0de /*d0argseq*/ (
pi0de
| "(" p0argseq ("|" p0argseq)? ")"
| "{" s0quaseq "}"
)* colonwith s0exp /*extnamopt*/ ("=" LITERAL_string)?
/* d0cstdec */
andd0cstdecseq ::=
/*|*/ ("and" d0cstdec)*
/* andd0cstdecseq */
//s0vararg ::=
// /*|*/ ".."
// | "..."
// | s0argseq
///* s0vararg */
s0exparg ::=
/*|*/ ".."
| "..."
| s0expseq1
/* s0exparg */
//s0elop ::=
// /*|*/ "."
// | "->"
///* s0elop */
witht0ype ::=
//| /*(empty)*/
(
/*|*/ "withprop" s0exp
| "withtype" s0exp
| "withview" s0exp
| "withviewtype" s0exp
)?
/* witht0ype */
p0at ::=
/*|*/ atmp0at /*argp0atseq*/ (atmp0at | "{" /*s0vararg*/ ".." | "..." | s0argseq "}")*
| p0at ":" s0exp
| pi0de "as" p0at
| "!" pi0de "as" p0at
| "~" p0at
/* p0at */
atmp0at ::=
/*|*/ LITERAL_char
| LITERAL_int
| LITERAL_float
| LITERAL_string
| pi0de
| "!" pi0de
| "op" pi0de
| d0ynq pi0de
| "(" p0atseq ")"
| "(" p0atseq "|" p0atseq ")"
| "'[" p0atseq "]"
| "@(" p0atseq ")"
| "'(" p0atseq ")"
| "@(" p0atseq "|" p0atseq ")"
| "'(" p0atseq "|" p0atseq ")"
| ("@" | "'")? "{" /*labp0atseq*/ ("..." | l0ab "=" p0at /*commalabp0atseq*/ ("," l0ab "=" p0at)*) "}"
//| "'{" labp0atseq "}"
| "[" s0argseq "]"
/* atmp0at */
//argp0at ::=
// /*|*/ atmp0at
// | "{" /*s0vararg*/ ".." | "..." | s0argseq "}"
///* argp0at */
//argp0atseq ::=
// /*|*/ /*argp0at*/ (atmp0at | "{" /*s0vararg*/ ".." | "..." | s0argseq "}")*
///* argp0atseq */
p0atseq ::=
//| /*(empty)*/
/*|*/ (p0at /*commap0atseq*/ ("," p0at)*)?
/* p0atseq */
//commap0atseq ::=
// /*|*/ ("," p0at)*
///* commap0atseq */
//labp0atseq ::=
// /*|*/ "..."
// | l0ab "=" p0at commalabp0atseq
///* labp0atseq */
//commalabp0atseq ::=
// /*|*/ ("," l0ab "=" p0at)*
///* commalabp0atseq */
//f0arg1 ::=
// /*|*/ "{" s0quaseq "}"
// | atmp0at
// | ".<" s0expseq ">."
// | ".<>."
///* f0arg1 */
f0arg1seq ::=
/*|*/ /*f0arg1*/ (
"{" s0quaseq "}"
| atmp0at
| ".<" s0expseq ">."
| ".<>."
)*
/* f0arg1seq */
//f0arg2 ::=
// /*|*/ "{" s0argseq "}"
// | atmp0at
///* f0arg2 */
//f0arg2seq ::=
// /*|*/ /*f0arg2*/ ("{" s0argseq "}" | atmp0at)*
///* f0arg2seq */
d0exp ::=
/*|*/ atmd0exp /*argd0expseq*/ (atmd0exp | s0expdarg)*
| d0exp ":" s0exp
//| ifhead d0exp "then" d0exp
| /*ifhead*/ "if" caseinv d0exp "then" d0exp ("else" d0exp)?
| /*sifhead*/ "sif" caseinv s0exp "then" d0exp "else" d0exp
| /*casehead*/ ("case" "case-" | "case+") caseinv d0exp "of" c0lauseq
| /*scasehead*/ "scase" caseinv s0exp "of" /*sc0lauseq*/ sc0lau? /*barsc0lauseq*/ ("|" sc0lau)*
| /*lamkind*/ (
"lam"
| "@lam"
| "llam"
| "@llam"
) f0arg1seq colons0expopt funarrow d0exp
| /*fixkind*/ (
"fix"
| "@fix"
) di0de f0arg1seq colons0expopt funarrow d0exp
| /*forhead*/ ("for" | "for*" loopi0nv "=>") /*initestpost*/ "(" d0expcommaseq ";" d0expcommaseq ";" d0expcommaseq ")" d0exp
| /*whilehead*/ "while*" loopi0nv "=>" atmd0exp d0exp
| "$raise" d0exp
| tryhead d0expsemiseq0 "with" c0lauseq
| d0exp "where" "{" d0ecseq_dyn "}"
/* d0exp */
atmd0exp ::=
/*|*/ LITERAL_char
| LITERAL_float
| LITERAL_floatsp
| LITERAL_int
| LITERAL_intsp
| LITERAL_string
| "#FILENAME"
| "#LOCATION"
| di0de
| "op" di0de
| d0ynq i0de
| /*i0dext*/ (EXTERNAL_IDENTIFIER | "do" | "while")
| "&"
| "break"
| "continue"
//| "fold@" s0expdargseq
| ( "fold@" | "free@") /*s0expdargseq*/ s0expdarg*
| "view@"
| "$decrypt"
| "$encrypt"
| "$delay"
| "$ldelay"
| "$dynload"
| "$effmask_all"
| "$effmask_exn"
| "$effmask_ntm"
| "$effmask_ref"
| "@[" s0exp "]" "(" d0expcommaseq ")"
| "@[" s0exp "]" "[" d0exp "]" "(" d0expcommaseq ")"
| ("$arrsz" | "$lst_t" | "$lst_vt") /*s0expelt*/
(
"{" s0exp "}"
| "[" s0exp "]"
)? "(" d0expcommaseq ")"
| /*arrqi0de*/ (d0ynq? ARRAY_IDENTIFIER) d0arrind
| /*s0elop*/ ("." | "->") (l0ab | "[" d0arrind)
//| s0elop "[" d0arrind
| tmpqi0de t1mps0expseq gtlt_t1mps0expseqseq ">"
| "#[" s0exparg "|" d0exp "]"
| "(" d0expcommaseq ")"
| "(" d0expcommaseq "|" d0expcommaseq ")"
//| "$lst_t" s0expelt "(" d0expcommaseq ")"
//| "$lst_vt" s0expelt "(" d0expcommaseq ")"
| "'[" d0expcommaseq "]"
| "begin" d0expsemiseq0 "end"
| "(" /*d0expsemiseq1*/ d0exp ";" d0expsemiseq0 ")"
| "@(" d0expcommaseq ")"
| "'(" d0expcommaseq ")"
| "$tup_t" "(" d0expcommaseq ")"
| "$tup_vt" "(" d0expcommaseq ")"
| "@(" d0expcommaseq "|" d0expcommaseq ")"
| "'(" d0expcommaseq "|" d0expcommaseq ")"
(
"@"
| "'"
| "$rec_t"
| "$rec_vt"
) "{" /*labd0expseq*/ (l0ab "=" d0exp /*commalabd0expseq*/ ("," l0ab "=" d0exp)*)? "}"
| "$extval" "(" s0exp "," LITERAL_string ")"
| "%(" d0exp ")"
| ",(" d0exp ")"
| "`(" d0expsemiseq0 ")"
| "let" d0ecseq_dyn "in" d0expsemiseq0 "end"
| "{" d0ecseq_dyn "}"
/* atmd0exp */
s0expdarg ::=
/*|*/ "{" s0exparg "}"
/* s0expdarg */
//s0expdargseq ::=
// /*|*/ s0expdarg*
///* s0expdargseq */
//argd0exp ::=
// /*|*/ atmd0exp
// | s0expdarg
///* argd0exp */
//argd0expseq ::=
// /*|*/ /*argd0exp*/ (atmd0exp | s0expdarg)*
///* argd0expseq */
d0arrind ::=
/*|*/ d0expcommaseq "]"
| d0expcommaseq "]" "[" d0arrind
/* d0arrind */
colons0expopt ::=
//| /*(empty)*/
/*|*/ (":" s0exp)?
/* colons0expopt */
funarrow ::=
/*|*/ "=>"
| "=<>"
| "=<" e0fftagseq ">"
/* funarrow */
caseinv ::=
//| /*(empty)*/
/*|*/ (i0nvresstate "=>")?
/* caseinv */
//ifhead ::=
// /*|*/ "if" caseinv
///* ifhead */
//sifhead ::=
// /*|*/ "sif" caseinv
///* sifhead */
//casehead ::=
// /*|*/ "case" caseinv
// | "case-" caseinv
// | "case+" caseinv
///* casehead */
//scasehead ::=
// /*|*/ "scase" caseinv
///* scasehead */
//forhead ::=
// /*|*/ "for"
// | "for*" loopi0nv "=>"
///* forhead */
//whilehead ::=
// /*|*/ "while*" loopi0nv "=>"
///* whilehead */
tryhead ::=
/*|*/ "try"
/* tryhead */
d0expcommaseq ::=
//| /*(empty)*/
/*|*/ (d0exp /*commad0expseq*/ ("," d0exp)*)?
/* d0expcommaseq */
//commad0expseq ::=
// | ("," d0exp)*
///* commad0expseq */
d0expsemiseq0 ::=
//| /*(empty)*/
(
/*|*/ d0exp
| d0exp ";" d0expsemiseq0
)?
/* d0expsemiseq0 */
//d0expsemiseq1 ::=
// /*|*/ d0exp ";" d0expsemiseq0
///* d0expsemiseq1 */
//labd0expseq ::=
// //| /*(empty)*/
// /*|*/ (l0ab "=" d0exp commalabd0expseq)?
///* labd0expseq */
//commalabd0expseq ::=
// /*|*/ ("," l0ab "=" d0exp)*
///* commalabd0expseq */
m0atch ::=
/*|*/ d0exp
| d0exp "as" p0at
/* m0atch */
//m0atchseq ::=
// /*|*/ m0atch andm0atchseq
///* m0atchseq */
//andm0atchseq ::=
// /*|*/ ("and" m0atch)*
///* andm0atchseq */
//guap0at ::=
// /*|*/ p0at
// | p0at "when" /*m0atchseq*/ m0atch /*andm0atchseq*/ ("and" m0atch)*
///* guap0at */
c0lau ::=
///*|*/ guap0at "=>" d0exp
//| guap0at "=>>" d0exp
//| guap0at "=/=>" d0exp
//| guap0at "=/=>>" d0exp
p0at ("when" /*m0atchseq*/ m0atch /*andm0atchseq*/ ("and" m0atch)*)? ("=>" | "=>>" | "=/=>" | "=/=>>") d0exp
/* c0lau */
c0lauseq ::=
///*|*/ barc0lauseq
/*|*/ c0lau? /*barc0lauseq*/ ("|" c0lau)*
/* c0lauseq */
//barc0lauseq ::=
// /*|*/ ("|" c0lau)*
///* barc0lauseq */
sc0lau ::=
/*|*/ /*sp0at*/ sqi0de "(" s0argseq ")" "=>" d0exp
/* sc0lau */
//sc0lauseq ::=
// /*|*/ barsc0lauseq
// | sc0lau barsc0lauseq
///* sc0lauseq */
//barsc0lauseq ::=
// /*|*/ ("|" sc0lau)*
///* barsc0lauseq */
//i0nvqua ::=
// //| /*(empty)*/
// /*|*/ ("{" s0quaseq "}")?
///* i0nvqua */
//i0nvmet ::=
// //| /*(empty)*/
// (
// /*|*/ ".<" s0expseq ">."
// | ".<>."
// )?
///* i0nvmet */
i0nvarg ::=
/*|*/ di0de ":"
| di0de ":" s0exp
/* i0nvarg */
i0nvargseq ::=
//| /*(empty)*/
/*|*/ (i0nvarg /*commai0nvargseq*/ ("," i0nvarg)*)?
/* i0nvargseq */
//commai0nvargseq ::=
// /*|*/ ("," i0nvarg)*
///* commai0nvargseq */
//i0nvargstate ::=
// /*|*/ "(" i0nvargseq ")"
///* i0nvargstate */
//i0nvresqua ::=
// //| /*(empty)*/
// /*|*/ ("[" s0quaseq "]")?
///* i0nvresqua */
i0nvresstate ::=
//| /*(empty)*/
/*|*/ (":" /*i0nvresqua*/ ("[" s0quaseq "]")? "(" i0nvargseq ")")?
/* i0nvresstate */
loopi0nv ::=
/*|*/ /*i0nvqua*/ ("{" s0quaseq "}")? /*i0nvmet*/ (
/*|*/ ".<" s0expseq ">."
| ".<>."
)? /*i0nvargstate*/ "(" i0nvargseq ")" i0nvresstate
/* loopi0nv */
//initestpost ::=
// /*|*/ "(" d0expcommaseq ";" d0expcommaseq ";" d0expcommaseq ")"
///* initestpost */
m0arg ::=
/*|*/ pi0de
/* m0arg */
//m0argseq ::=
// //| /*(empty)*/
// /*|*/ (m0arg commam0argseq)?
///* m0argseq */
//commam0argseq ::=
// /*|*/ ("," m0arg)*
///* commam0argseq */
//m0acarg ::=
// /*|*/ m0arg
// | "(" /*m0argseq */ (m0arg /*commam0argseq*/ ("," m0arg)*)? ")"
///* m0acarg */
m0acargseq ::=
/*|*/ /*m0acarg*/ (
m0arg
| "(" /*m0argseq */ (m0arg /*commam0argseq*/ ("," m0arg)*)? ")"
)*
/* m0acargseq */
m0acdef ::=
/*|*/ di0de m0acargseq "=" d0exp
/* m0acdef */
//andm0acdefseq ::=
// /*|*/ ("and" m0acdef)*
///* andm0acdefseq */
v0aldec ::=
/*|*/ p0at "=" d0exp witht0ype
/* v0aldec */
andv0aldecseq ::=
/*|*/ ("and" v0aldec)*
/* andv0aldecseq */
f0undec ::=
///*|*/ fi0de f0arg1seq "=" d0exp witht0ype
//| fi0de f0arg1seq colonwith s0exp "=" d0exp witht0ype
(di0de | "op" di0de) f0arg1seq (colonwith s0exp)? "=" d0exp witht0ype
/* f0undec */
//andf0undecseq ::=
// /*|*/ ("and" f0undec)*
///* andf0undecseq */
v0arwth ::=
//| /*(empty)*/
/*|*/ ("with" pi0de)*
/* v0arwth */
v0ardec ::=
/*|*/ pi0de v0arwth "=" d0exp
| "!" pi0de v0arwth "=" d0exp
| pi0de ":" s0exp v0arwth
| pi0de ":" s0exp v0arwth "=" d0exp
/* v0ardec */
//andv0ardecseq ::=
// /*|*/ ("and" v0ardec)*
///* andv0ardecseq */
//i0mpdec ::=
// /*|*/ /*impqi0de*/ (
// dqi0de
// | tmpqi0de t1mps0expseq gtlt_t1mps0expseqseq ">"
// ) /*f0arg2seq*/ ("{" s0argseq "}" | atmp0at)* colons0expopt "=" d0exp
///* i0mpdec */
d0ec ::=
( ("infix"
| "infixl"
| "infixr"
| "prefix"
| "postfix"
) /*p0rec*/ (
LITERAL_int
| "(" i0de ")"
| "(" i0de SYMBOLIC_IDENTIFIER LITERAL_int ")"
)?
| "nonfix"
| "symintr"
) i0de*
| "#undef" i0de
| "#define" i0de /*e0xpopt*/ e0xp?
| "#assert" e0xp
| "#error" e0xp
| "#print" e0xp
| "sortdef" s0rtdef /*ands0rtdefseq*/ ("and" s0rtdef)*
(
"datasort"
| "dataparasort"
) d0atsrtdec /*andd0atsrtdecseq*/ ("and" d0atsrtdec)*
| /*abskind*/ (
"absprop"
| "abstype"
| "abst@ype"
| "absview"
| "absviewtype"
| "absviewt@ype"
) s0tacon /*ands0taconseq*/ ("and" s0tacon)*
| "stacst" s0tacst /*ands0tacstseq*/ ("and" s0tacst)*
| "stavar" s0tavar /*ands0tavarseq*/ ("and" s0tavar)*
| /*stadefkind*/ (
"stadef"
| "propdef"
| "typedef"
| "viewdef"
| "viewtypedef"
) s0expdef ands0expdefseq
| "assume" /*s0aspdec*/ sqi0de s0argseqseq colons0rtopt "=" s0exp
| /*datakind*/ (
"dataprop"
| "datatype"
| "dataview"
| "dataviewtype"
) d0atdec /*andd0atdecseq*/ ("and" d0atdec)* /*s0expdefseqopt*/ ("where" s0expdef ands0expdefseq)?
| "exception" e0xndec /*ande0xndecseq*/ ("and" e0xndec)*
| "classdec" si0de
| "classdec" si0de ":" s0exp
| "overload" di0de "with" dqi0de
| "overload" "[" "]" "with" dqi0de
(
//| "macdef" m0acdef andm0acdefseq
| "macdef" "rec"?
//| "macrodef" m0acdef andm0acdefseq
| "macrodef" "rec"?
) m0acdef /*andm0acdefseq*/ ("and" m0acdef)*
| "staload" LITERAL_string
| "staload" /*stai0de*/ ALNUMRIC_IDENTIFIER "=" LITERAL_string
/* d0ec */
//d0ecarg ::=
// /*|*/ "{" s0quaseq "}"
///* d0ecarg */
d0ecargseq ::=
/*|*/ /*d0ecarg*/ ("{" s0quaseq "}") *
/* d0ecargseq */
semicolonseq ::=
/*|*/ ";"*
/* semicolonseq */
//d0ec_sta ::=
// /*|*/ d0ec
// | dcstkind d0ecargseq d0cstdec andd0cstdecseq
// | LITERAL_extcode
// | srpifkind guad0ec_sta
// | "#include" LITERAL_string
// | "local" d0ecseq_sta "in" d0ecseq_sta "end"
///* d0ec_sta */
guad0ec_sta ::=
/*|*/ e0xp srpthenopt d0ecseq_sta "#endif"
| e0xp srpthenopt d0ecseq_sta "#else" d0ecseq_sta "#endif"
| e0xp srpthenopt d0ecseq_sta srpelifkind guad0ec_sta
/* guad0ec_sta */
d0ecseq_sta ::=
/*|*/ d0ecseq_sta_rev
/* d0ecseq_sta */
d0ecseq_sta_rev ::=
//| /*(empty)*/
/*|*/ (d0ecseq_sta_rev /*d0ec_sta*/
(
d0ec
| dcstkind d0ecargseq d0cstdec andd0cstdecseq
| LITERAL_extcode
| srpifkind guad0ec_sta
| "#include" LITERAL_string
| "local" d0ecseq_sta "in" d0ecseq_sta "end"
) semicolonseq)?
/* d0ecseq_sta_rev */
//d0ec_dyn ::=
// /*|*/ d0ec
// | "extern" dcstkind d0ecargseq d0cstdec andd0cstdecseq
// | "extern" "typedef" LITERAL_string "=" s0exp
// | "extern" "val" LITERAL_string "=" d0exp
// | /*valkind*/ (
// "val"
// | "val-"
// | "val+"
// | "prval"
// ) v0aldec andv0aldecseq
// | "val" "par" v0aldec andv0aldecseq
// | "val" "rec" v0aldec andv0aldecseq
// | /*funkind*/ (
// "fn"
// | "fn*"
// | "fun"
// | "castfn"
// | "prfn"
// | "prfun"
// ) d0ecargseq f0undec /*andf0undecseq*/ ("and" f0undec)*
// | "var" v0ardec /*andv0ardecseq*/ ("and" v0ardec)*
// | "implement" decs0argseqseq /*i0mpdec*/ (
// dqi0de
// | tmpqi0de t1mps0expseq gtlt_t1mps0expseqseq ">"
// ) /*f0arg2seq*/ ("{" s0argseq "}" | atmp0at)* colons0expopt "=" d0exp
// | "local" d0ecseq_dyn "in" d0ecseq_dyn "end"
// | LITERAL_extcode
// | srpifkind guad0ec_dyn
// | "#include" LITERAL_string
// | "dynload" LITERAL_string
///* d0ec_dyn */
guad0ec_dyn ::=
/*|*/ e0xp srpthenopt d0ecseq_dyn "#endif"
| e0xp srpthenopt d0ecseq_dyn "#else" d0ecseq_dyn "#endif"
| e0xp srpthenopt d0ecseq_dyn srpelifkind guad0ec_dyn
/* guad0ec_dyn */
d0ecseq_dyn ::=
/*|*/ d0ecseq_dyn_rev
/* d0ecseq_dyn */
d0ecseq_dyn_rev ::=
//| /*(empty)*/
/*|*/ (d0ecseq_dyn_rev /*d0ec_dyn*/
(
d0ec
| "extern" dcstkind d0ecargseq d0cstdec andd0cstdecseq
| "extern" "typedef" LITERAL_string "=" s0exp
| "extern" "val" LITERAL_string "=" d0exp
| /*valkind*/ (
"val"
| "val-"
| "val+"
| "prval"
) v0aldec andv0aldecseq
| "val" "par" v0aldec andv0aldecseq
| "val" "rec" v0aldec andv0aldecseq
| /*funkind*/ (
"fn"
| "fn*"
| "fun"
| "castfn"
| "prfn"
| "prfun"
) d0ecargseq f0undec /*andf0undecseq*/ ("and" f0undec)*
| "var" v0ardec /*andv0ardecseq*/ ("and" v0ardec)*
| "implement" decs0argseqseq /*i0mpdec*/ (
dqi0de
| tmpqi0de t1mps0expseq gtlt_t1mps0expseqseq ">"
) /*f0arg2seq*/ ("{" s0argseq "}" | atmp0at)* colons0expopt "=" d0exp
| "local" d0ecseq_dyn "in" d0ecseq_dyn "end"
| LITERAL_extcode
| srpifkind guad0ec_dyn
| "#include" LITERAL_string
| "dynload" LITERAL_string
) semicolonseq)?
/* d0ecseq_dyn_rev */
/* ****** ****** */
/* end of [ats_grammar.desc] */
Thanks for your interest.
The grammar for ATS3/Xanadu has yet to be finalized. I could only do it after getting a running implementation of ATS3. Please keep tuned :)
After seeing the info on this issue https://github.com/githwxi/ATS-Postiats/issues/208#issuecomment-406652935 I tweaked the gammar to be able to view it at https://www.bottlecaps.de/rr/ui as a railroad diagram (paste the tweaked grammar bellow in the
Edit Grammar
tab then switch to theView Diagram
tab and you can also download the diagram from threre).There is a way to have a grammar to what this project is trying to build ?