{"id":20815258,"url":"https://github.com/mse-org/mselang","last_synced_at":"2025-05-07T12:11:43.317Z","repository":{"id":49334314,"uuid":"173015294","full_name":"mse-org/mselang","owner":"mse-org","description":"The Pascal compiler of LLVM.","archived":false,"fork":false,"pushed_at":"2021-07-13T12:26:12.000Z","size":4209,"stargazers_count":20,"open_issues_count":1,"forks_count":3,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-05-07T12:11:37.720Z","etag":null,"topics":["compiler","fpc","llvm","llvm-bitcode","pascal","wirth"],"latest_commit_sha":null,"homepage":"","language":"Pascal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mse-org.png","metadata":{"files":{"readme":"README.TXT","changelog":null,"contributing":null,"funding":null,"license":"COPYING.LGPL","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-28T01:01:22.000Z","updated_at":"2025-02-25T10:38:27.000Z","dependencies_parsed_at":"2022-09-07T23:51:08.812Z","dependency_job_id":null,"html_url":"https://github.com/mse-org/mselang","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mse-org%2Fmselang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mse-org%2Fmselang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mse-org%2Fmselang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mse-org%2Fmselang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mse-org","download_url":"https://codeload.github.com/mse-org/mselang/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252873903,"owners_count":21817715,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","fpc","llvm","llvm-bitcode","pascal","wirth"],"created_at":"2024-11-17T21:20:43.400Z","updated_at":"2025-05-07T12:11:43.298Z","avatar_url":"https://github.com/mse-org.png","language":"Pascal","funding_links":[],"categories":[],"sub_categories":[],"readme":"MSEpas/MSElang\n\nOriginal: https://gitlab.com/mseide-msegui/mselang\n\nFork: https://github.com/mse-org/mselang\n\nRelease from fork: https://github.com/mse-org/mselang/releases\n\nCopyright (c) 2013-2018 by Martin Schreiber\n\nMSElang   2013-11-01\n=======\nIn the beginning of 2013 I decided to make an own compiler for the MSEide+MSEgui project and started to experiment.\n The reason is the development direction of Delphi since Delphi 7 which makes it less suitable for my tasks and\n knowing that Free Pascal is closely following the same direction.\n\nThe design goals\n----------------\nUltimate goal is to build the most productive universal programming environment,\n usable from programming of microcontrollers to MSEgui projects.\n\n1. Simple.\nReduce the language concepts one has to learn to the minimum, make them as orthogonal as possible.\n\n2. Readable.\nMSElang programs should read like a letter.\n\n3. Easy to learn.\nBecause of 1. and 2. it should be suitable for pupils as first programming language.\n\n4. Powerful\nAllow to go down to the bare metal, it has pointers and pointer arithmetic. ;-)\nObject orientated high level programming.\n\n5. Fast running\nState of the art optimizations.\n\n6. Fast compiling\nWhile defining the language keep in mind how it can be implemented efficiently.\n\nThe Steps\n---------\nAt the beginning MSElang will be the language currently used in MSEgui project, a subset of Delphi 7 and FPC 2.6.2.\n Later syntax changes are possible.\nIn order to develop and test the front-end there first will be an intermediate code interpreter which can be used in MSEifi projects\n and in MSEgui report generator. Most likely there will be not much effort invested to make it fast at runtime\n but compiletime must be lightning fast.\nLater native code back-ends and a simple RTL will be added.\n\nThe time frame\n--------------\n3..5 years until a usable interpreter, additional 3..5 years for one or two native backends.\n\nExperiments up to now\n---------------------\nCurrently I am experimenting how to make a fast and nonetheless easy maintainable compiler frontend . Some ideas:\n\n- There is a syntax generator program which transforms a grammar into Pascal structures. Example:\n\nstarttoken definition:\n@whitespace\n ' ',#$0d,#$0a\n\nmacro:\n{whitespace}\n\"@whitespace,\n '{$',directive-^*\n '{',comment0-^*\n '//',linecomment0-^*\"\n\nmore starttokens:\n@keywordstart\n 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p'\n 'q','r','s','t','u','v','w','x','y','z'\n 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P'\n 'Q','R','S','T','U','V','W','X','Y','Z'\n@identstart\n '_',@keywordstart\n@num\n '0','1','2','3','4','5','6','7','8','9'\n\n...\n\na contextline with branches:\nstart,nounit,\n ${whitespace} \n 'unit'.,unit0-\n\na transition context with a handler procedure:\nnounit,,handlenouniterror\n\nmore contexts:\nunit0,nounitname,handlenounitnameerror\n ${whitespace}\n @identstart,ident^*,unit1\nnounitname,,handlenounitnameerror\nunit1,unit2,setunitname\nunit2,semicolonexpected,\n ${whitespace}\n ';',start1-\n\n...\n\ntransforms to the Pascal structures:\n\nconst\n tks_none = 0;\n tks_classes = $2468ACF1;\n tks_private = $48D159E3;\n tks_protected = $91A2B3C6;\n tks_public = $2345678C;\n tks_published = $468ACF19;\n tk_unit = $8D159E33;\n tk_uses = $1A2B3C66;\n tk_implementation = $345678CD;\n tk_const = $68ACF19B;\n tk_var = $D159E337;\n tk_type = $A2B3C66E;\n...\n tokens: array[0..25] of string = ('',\n  '.classes','.private','.protected','.public','.published',\n  'unit','uses','implementation','const','var','type','procedure','begin',\n  'dumpelements','abort','end','if','then','else','record','class','private',\n  'protected','public','published');\n\n tokenids: array[0..25] of identty = (\n  $00000000,$2468ACF1,$48D159E3,$91A2B3C6,$2345678C,$468ACF19,$8D159E33,\n  $1A2B3C66,$345678CD,$68ACF19B,$D159E337,$A2B3C66E,$45678CDD,$8ACF19BB,\n  $159E3376,$2B3C66ED,$5678CDDB,$ACF19BB7,$59E3376E,$B3C66EDD,$678CDDBA,\n  $CF19BB75,$9E3376EB,$3C66EDD6,$78CDDBAD,$F19BB75B);\n\nvar\n startco: contextty = (branch: nil; handle: nil; \n               continue: false; cut: false; restoresource: false; \n               pop: false; popexe: false; nexteat: false; next: nil;\n               caption: 'start');\n nounitco: contextty = (branch: nil; handle: nil; \n               continue: false; cut: false; restoresource: false; \n               pop: false; popexe: false; nexteat: false; next: nil;\n               caption: 'nounit');\n unit0co: contextty = (branch: nil; handle: nil; \n               continue: false; cut: false; restoresource: false; \n               pop: false; popexe: false; nexteat: false; next: nil;\n               caption: 'unit0');\n nounitnameco: contextty = (branch: nil; handle: nil; \n               continue: false; cut: false; restoresource: false; \n               pop: false; popexe: false; nexteat: false; next: nil;\n               caption: 'nounitname');\n unit1co: contextty = (branch: nil; handle: nil; \n               continue: false; cut: false; restoresource: false; \n               pop: false; popexe: false; nexteat: false; next: nil;\n               caption: 'unit1');\n unit2co: contextty = (branch: nil; handle: nil; \n               continue: false; cut: false; restoresource: false; \n               pop: false; popexe: false; nexteat: false; next: nil;\n               caption: 'unit2');\n...\nconst\n bstart: array[0..5] of branchty = (\n   (flags: [bf_nt,bf_keyword,bf_eat];\n     dest: (context: @unit0co); stack: nil; \n     keyword: $8D159E33{'unit'}),\n   (flags: [bf_nt,bf_eat,bf_push,bf_setparentbeforepush];\n     dest: (context: @directiveco); stack: nil; keys: (\n    (kind: bkk_charcontinued; chars: ['{']),\n    (kind: bkk_char; chars: ['$']),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: [])\n    )),\n   (flags: [bf_nt,bf_eat,bf_push,bf_setparentbeforepush];\n     dest: (context: @linecomment0co); stack: nil; keys: (\n    (kind: bkk_charcontinued; chars: ['/']),\n    (kind: bkk_char; chars: ['/']),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: [])\n    )),\n   (flags: [bf_nt];\n     dest: (context: nil); stack: nil; keys: (\n    (kind: bkk_char; chars: [#10,#13,' ']),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: [])\n    )),\n   (flags: [bf_nt,bf_eat,bf_push,bf_setparentbeforepush];\n     dest: (context: @comment0co); stack: nil; keys: (\n    (kind: bkk_char; chars: ['{']),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: [])\n    )),\n   (flags: []; dest: (context: nil); stack: nil; keyword: 0)\n   );\n bunit0: array[0..5] of branchty = (\n   (flags: [bf_nt,bf_eat,bf_push,bf_setparentbeforepush];\n     dest: (context: @directiveco); stack: nil; keys: (\n    (kind: bkk_charcontinued; chars: ['{']),\n    (kind: bkk_char; chars: ['$']),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: [])\n    )),\n   (flags: [bf_nt,bf_eat,bf_push,bf_setparentbeforepush];\n     dest: (context: @linecomment0co); stack: nil; keys: (\n    (kind: bkk_charcontinued; chars: ['/']),\n    (kind: bkk_char; chars: ['/']),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: [])\n    )),\n   (flags: [bf_nt];\n     dest: (context: nil); stack: nil; keys: (\n    (kind: bkk_char; chars: [#10,#13,' ']),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: [])\n    )),\n   (flags: [bf_nt,bf_eat,bf_push,bf_setparentbeforepush];\n     dest: (context: @comment0co); stack: nil; keys: (\n    (kind: bkk_char; chars: ['{']),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: [])\n    )),\n   (flags: [bf_nt,bf_push,bf_setparentbeforepush];\n     dest: (context: @identco); stack: @unit1co; keys: (\n    (kind: bkk_char; chars: ['A'..'Z','_','a'..'z']),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: [])\n    )),\n   (flags: []; dest: (context: nil); stack: nil; keyword: 0)\n   );\n bunit2: array[0..5] of branchty = (\n   (flags: [bf_nt,bf_eat,bf_push,bf_setparentbeforepush];\n     dest: (context: @directiveco); stack: nil; keys: (\n    (kind: bkk_charcontinued; chars: ['{']),\n    (kind: bkk_char; chars: ['$']),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: [])\n    )),\n   (flags: [bf_nt,bf_eat,bf_push,bf_setparentbeforepush];\n     dest: (context: @linecomment0co); stack: nil; keys: (\n    (kind: bkk_charcontinued; chars: ['/']),\n    (kind: bkk_char; chars: ['/']),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: [])\n    )),\n   (flags: [bf_nt];\n     dest: (context: nil); stack: nil; keys: (\n    (kind: bkk_char; chars: [#10,#13,' ']),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: [])\n    )),\n   (flags: [bf_nt,bf_eat,bf_push,bf_setparentbeforepush];\n     dest: (context: @comment0co); stack: nil; keys: (\n    (kind: bkk_char; chars: ['{']),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: [])\n    )),\n   (flags: [bf_nt,bf_eat];\n     dest: (context: @start1co); stack: nil; keys: (\n    (kind: bkk_char; chars: [';']),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: []),\n    (kind: bkk_none; chars: [])\n    )),\n   (flags: []; dest: (context: nil); stack: nil; keyword: 0)\n   );\n...\n\n- There is a small language independent kernel function in compiler which parses the source based on the above language data structure\n  and calls the language specific handler procedures.\n  Because it is small, the kernel can be highly optimised, even coding it in assembler or implementing in an FPGA should be possible.\n\n- There is a central element hash list where the data and function structure of the program is stored. \n  Hierarchy is handled by storing the sum of the element ID's up to the root, possible collisions must be handled \n  by checking the path ID's.\n\n- The data of unit implementation sections can be released with a mark/release mechanism in order to free not anymore used elements.\n\n- Text tokens and keywords get a hash and a unique ID while reading the source.\n  The ID is a random number in order to minimize conflicts in the central element hash list.\n\n- The compiler kernel maintains a single context stack, the context handler procedures use the stack to store intermediate information\n  and the central element hash list for persistent data.\n\nThoughts for a future syntax\n----------------------------\n- records, objects and classes could be unified in a single concept.\n- instead of \"begin\"/\"end\" there could be a mandatory \"end\" in structured statements.\n\nWhat will not be implemented\n----------------------------\n- Macros.\n- Generics/templates, there will be functionality which makes them superfluous.\n- \"codepage aware AnsiStrings\". ;-)\n \nMartin\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmse-org%2Fmselang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmse-org%2Fmselang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmse-org%2Fmselang/lists"}