A small functional/scope oriented language parsed with Antlr and compiled to llvm IR
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

51 lines
946 B

parser grammar ScriptoidParser;
options {
tokenVocab=ScriptoidLexer;
}
//(importDecl eos)*
script: scope;
block: '{' scope '}';
scope: (line)* closeIndents+=INDENT*;
line: INDENT* declaration eos
| NEWLINE
;
declaration:
variable
// | assign
| function
;
variable: VAR SPACE assign;
assign: IDENTIFIER SPACE ASSIGN SPACE literal;
function: FUNC SPACE IDENTIFIER SPACE? COLON SPACE (parameters SPACE)? block;
function_literal: '(' parameters? ')' SPACE FUNC_LIT SPACE block;
parameters: params+=IDENTIFIER (COMMA SPACE params+=IDENTIFIER)*;
literal:
INT_LIT
| FLOAT_LIT
| STRING_LIT
| function_literal
| call
// | reference
| block
;
reference: IDENTIFIER (DOT IDENTIFIER)*;
call: (reference | function | function_literal) '(' args? ')';
args: arguments+=argMap (COMMA SPACE arguments+=argMap)*;
argMap: (IDENTIFIER COLON SPACE (reference | literal)) | reference;
eos:
(SEMI (SPACE | NEWLINE)) | NEWLINE
| EOF
;