Skip to content

Instantly share code, notes, and snippets.

@Tomcat-42
Created February 12, 2023 20:45
Show Gist options
  • Save Tomcat-42/f363b311484b4dbbf98393720bd4a3cf to your computer and use it in GitHub Desktop.
Save Tomcat-42/f363b311484b4dbbf98393720bd4a3cf to your computer and use it in GitHub Desktop.
<Program> ::= <Exps> | <Decs>
<Exps> ::= <Exp> | <Exp> <Exps> | ''
<Exp> ::= <Nil> | <Integer> | <String> | <ListExp> | <Struct> | <LValue> | <FnCall> | <Operation> | <Group> | <IfExp> | <WhileExp> | <ForExp> | <Break> | <LetExp>
<ListExp> ::= <Id> <LSquareBracket> <Exp> <RSquareBracket> <Of> <Exp>
<Struct> ::= <Id> <LCurlyBracket> <StructFields> <RCurlyBracket>
<StructFields> ::= <Id> <Equal> <Exp> | <Id> <Equal> <Exp> <Comma> <StructFields> | ''
<FnCall> ::= <Id> <LRoundBracket> <FnCallArgs> <RRoundBracket>
<FnCallArgs> ::= <Exp> | <Exp> <Comma> <FnCallArgs> |''
<Operation> ::= <ArithmeticOperation> | <RelationalOperation> | <LogicalOperation>
<ArithmeticOperation> ::= <ArithmeticSumOperarition> | <ArithmeticMulOperation>
<ArithmeticSumOperarition> ::= <Exp> <Plus> <ArithmeticMulOperation> | <Exp> <Minus> <ArithmeticMulOperation> | <ArithmeticMulOperation>
<ArithmeticMulOperation> ::= <Exp> <Times> <Exp> | <Exp> <Slash> <Exp> | <Exp>
<RelationalOperation> ::= <Exp> <Equal> <Exp> | <Exp> <NotEqual> <Exp> | <Exp> <GreaterThan> <Exp> | <Exp> <LessThan> <Exp> | <Exp> <GreaterThanEqual> <Exp> | <Exp> <LessThanEqual> <Exp>
<LogicalOperation> ::= <Exp> <And> <Exp> | <Exp> <Or> <Exp> | <Not> <RelationalOperation> | <Not> <LogicalOperation>
<Group> ::= <LRoundBracket> <Exps> <RRoundBracket>
<IfExp> ::= <If> <Exp> <Then> <Exp> <ElseExp>
<ElseExp> ::= <Else> <Exp> | ''
<WhileExp> ::= <While> <Exp> <Do> <Exp>
<ForExp> ::= <For> <Id> <Atrib> <Exp> <To> <Exp> <Do> <Exp>
<LetExp> ::= <Let> <Decs> <In> <Exps> <End>
<LValue> ::= <Id> | <LValue> <Dot> <Id> | <LValue> <LSquareBracket> <Exp> <RSquareBracket>
<Decs> ::= <Dec> | <Dec> <Decs> | ''
<Dec> ::= <TyDec> | <VarDec> | <FnDec>
<TyDec> ::= <Type> <Id> <Equal> <Ty>
<VarDec> ::= <Var> <Id> <TyAnnotation> <Atrib> <Exp>
<FnDec> ::= <Fn> <Id> <LRoundBracket> <TyFields> <RRoundBracket> <TyAnnotation> <Equal> <Exps>
<Ty> ::= <Id> | <LCurlyBracket> <TyFields> <RCurlyBracket> | <List> <Of> <Id>
<TyFields> ::= <Id> <Colon> <Id> | <Id> <Colon> <Id> <Comma> <TyFields> | ''
<TyAnnotation> ::= <Colon> <Id> | ''
<Semicolon> ::= ';'
<Nil> ::= 'nil'
<LSquareBracket> ::= '\['
<RSquareBracket> ::= '\]'
<Of> ::= 'of'
<LCurlyBracket> ::= '\{'
<RCurlyBracket> ::= '\}'
<LRoundBracket> ::= '\('
<RRoundBracket> ::= '\)'
<Integer> ::= '(-)?[0-9]+'
<Plus> ::= '\+'
<Minus> ::= '-'
<Times> ::= '\*'
<Slash> ::= '/'
<Atrib> ::= ':='
<NotEqual> ::= '<>'
<GreaterThanEqual> ::= '>='
<LessThanEqual> ::= '<='
<GreaterThan> ::= '>'
<LessThan> ::= '<'
<Equal> ::= '='
<And> ::= '&'
<Or> ::= '\|'
<Not> ::= '!'
<If> ::= 'if'
<Then> ::= 'then'
<Else> ::= 'else'
<While> ::= 'while'
<Do> ::= 'do'
<For> ::= 'for'
<To> ::= 'to'
<Break> ::= 'break'
<Let> ::= 'let'
<In> ::= 'in'
<Fn> ::= 'fn'
<Colon> ::= ':'
<Comma> ::= ','
<Dot> ::= '\.'
<Type> ::= 'type'
<Var> ::= 'var'
<End> ::= 'end'
<List> ::= 'list'
<String> ::= '".*"'
<Id> ::= '[a-z][a-za-z0-9]*'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment