A computer language inspired by classical studies (ancient Greek and Latin
literature).
Keywords are derived from Latin and Greek, e.g. the usual return
word
is exodus
(from Greek ἔξοδος = exit) in classic; a function is declared with the keyword oper
(from operatio = operation).
oper: int simple_function(int myint) {
exodus myint;
}
oper: int initus() {
exodus simple_function(myint=0);
}
initus
is the main function that gets executed.
ID = [a-zA-Z_][a-zA-Z0-9_]*
INT = [-]?[0-9]+
DUPL = [-+]?[0-9]+.?[0-9]*
- program = classdefs , funcs
- classdefs = classdef-list
- classdef-list = [ non-empty-classdef-list ]
- non-empty-classdef-list = classdef , { "," , classdef }
- classdef = 'exemp' , ";" , custom-type , "{" , class-body , "}"
- custom-type = ID
- class-body = attr-decl-list | attr-decl-list , func-list
- attr-decl-list = [ non-empty-attr-decl-list ]
- non-empty-attr-decl-list = attr-decl , { "," , attr-decl }
- attr-decl = type , ID , ";"
- type = 'int' | 'dupl' | 'str' | custom-type
- funcs = initus-func | func-list , initus-func
- initus-func = 'oper' , ":" , 'int' , 'initus' , "(" , ")" , "{" func-body , "}"
- func-list = func , { "," , func }
- func = 'oper' , ":" , exodus-type , func-id , "(" , param-list , ")" , "{" , func-body , "}"
- func-id = ID
- exodus-type = 'anef' | type
- param-list = [ non-empty-param-list ]
- non-empty-param-list = param , { "," , param }
- param = type , param-id
- param-id = ID
- func-body = statement , exodus-stm
- exodus-stm = 'exodus' , exp , ";"
- statement = [ non-empty-stm ]
- non-empty-stm = compound-stm | assign-stm | exp
- compound-stm = assign-or-exp-stm , ";" , assign-or-exp-stm , ";" | compound-stm , assign-or-exp-stm , ";"
- assign-or-exp-stm = assign-stm | exp
- assign-stm = ids , "=" , exp
- ids = ID
- exp = "(" , exp , ")" | binop-exp | func-call | literal | variable
- binop-exp = exp , "+" , exp | exp , "-" , exp | exp , "/" , exp | exp , "*" , exp
- func-call = ids , "(" , arg-list , ")"
- arg-list = [ non-empty-arg-list ]
- non-empty-arg-list = arg , { "," , arg }
- arg = arg-id , "=" , exp
- literal = INT | DUPL | 'anef'
- variable = ID
- lexical analysis ✅
- syntax analysis ✅
- semantic analysis
- intermediate representation
- code production
- g++
- Flex
- Bison
- make
- Google test (only for testing)
If you meet the requirements you can download and install the classic compiler and use it to write your own little programs.
$ git clone https://github.com/Maxcode123/classic.git && \
cd classic && \
make && \
make test && \
sudo make install
All commands mentioned should be executed from the root directory.
The lexer is documented in src/lexical
The parser is documented in src/syntax.
Google test library is used for testing.
All tests are contained in the tests
directory.
Run unit tests with make unit-test
.
Run integration tests with make integration-test
.