Skip to content

Maxcode123/classic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

classic - classic - κλασσική

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.

Grammar - Grammatica - Γραμματική

Terminals - Terminales - Τερματικά

ID = [a-zA-Z_][a-zA-Z0-9_]*
INT = [-]?[0-9]+
DUPL = [-+]?[0-9]+.?[0-9]*

Non-terminals - Non-terminales - Ἀτέρμονα

  1. program = classdefs , funcs
  2. classdefs = classdef-list
  3. classdef-list = [ non-empty-classdef-list ]
  4. non-empty-classdef-list = classdef , { "," , classdef }
  5. classdef = 'exemp' , ";" , custom-type , "{" , class-body , "}"
  6. custom-type = ID
  7. class-body = attr-decl-list | attr-decl-list , func-list
  8. attr-decl-list = [ non-empty-attr-decl-list ]
  9. non-empty-attr-decl-list = attr-decl , { "," , attr-decl }
  10. attr-decl = type , ID , ";"
  11. type = 'int' | 'dupl' | 'str' | custom-type
  12. funcs = initus-func | func-list , initus-func
  13. initus-func = 'oper' , ":" , 'int' , 'initus' , "(" , ")" , "{" func-body , "}"
  14. func-list = func , { "," , func }
  15. func = 'oper' , ":" , exodus-type , func-id , "(" , param-list , ")" , "{" , func-body , "}"
  16. func-id = ID
  17. exodus-type = 'anef' | type
  18. param-list = [ non-empty-param-list ]
  19. non-empty-param-list = param , { "," , param }
  20. param = type , param-id
  21. param-id = ID
  22. func-body = statement , exodus-stm
  23. exodus-stm = 'exodus' , exp , ";"
  24. statement = [ non-empty-stm ]
  25. non-empty-stm = compound-stm | assign-stm | exp
  26. compound-stm = assign-or-exp-stm , ";" , assign-or-exp-stm , ";" | compound-stm , assign-or-exp-stm , ";"
  27. assign-or-exp-stm = assign-stm | exp
  28. assign-stm = ids , "=" , exp
  29. ids = ID
  30. exp = "(" , exp , ")" | binop-exp | func-call | literal | variable
  31. binop-exp = exp , "+" , exp | exp , "-" , exp | exp , "/" , exp | exp , "*" , exp
  32. func-call = ids , "(" , arg-list , ")"
  33. arg-list = [ non-empty-arg-list ]
  34. non-empty-arg-list = arg , { "," , arg }
  35. arg = arg-id , "=" , exp
  36. literal = INT | DUPL | 'anef'
  37. variable = ID

Current state - Current status - Τρέχουσα κατάστασις

  • lexical analysis ✅
  • syntax analysis ✅
  • semantic analysis
  • intermediate representation
  • code production

Requirements - Necessaria - Προαπαιτούμενα

Usage - Usus - Χρήσις

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  

Documentation - Documentum - Ἐγχειρίδιον

All commands mentioned should be executed from the root directory.

Lexer

The lexer is documented in src/lexical

Parser

The parser is documented in src/syntax.

Tests

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.