Repository navigation
Closed
Labels
converterSemantic checks and typed IR (src/converter)Semantic checks and typed IR (src/converter)enhancementNew feature or requestNew feature or requestfront-endLexer, pre-parser, parser, ASTLexer, pre-parser, parser, AST
Description
A program cannot be split into several files yet: the compiler takes several .kr (compiler -x a.kr b.kr), but each one must have its own main (lib.kr:1:1: the program has no main), and a file cannot call a function of another one.
To call a function defined in another file, the current file needs a declaration of it without a body, a header:
정수를 반환하는 더하다(정수 가, 정수 나)
Design
외부 stays for the libc; a function without a body and without 외부 is a Krc function defined elsewhere.
| Declaration | Name | Symbol |
|---|---|---|
외부 정수를 반환하는 printf(문자 주소 형식, …) |
latin | C, the name as is |
정수를 반환하는 더하다(정수 가) { … } |
verb in 다 |
Krc, mangled: 더하다$int |
정수를 반환하는 더하다(정수 가) |
verb in 다 |
Krc, mangled: defined in another file |
main |
the only latin name with a body | C |
To do
- Grammar:
Function → FunctionHead ( Parameters )without aBlock. After the), a{starts the body, anything else ends the declaration; check that the LR(1) table has no conflict (see Parser: report LR(1) conflicts and expected tokens #22: conflicts are not reported yet) -
Function(src/parser/postparser/structs.rs): a field such asexternal: bool, since no body no longer means libc - Decide the symbol from
external || name == "main", not frombody.is_none(), in the three places that do it today:src/parser/postparser/postparser.rs,is_libcinfunctionsrc/converter/functions.rs,get_all_functions(and theshortcut:that refuses a외부with a non-latin name, Converter: function names are not checked (다 for a verb, latin for 외부) #12)src/converter/expressions.rs,is_mangled
- Only one file may have
main; the others are libraries - A header and the definition of the same function in one file: decide (allowed and checked against each other, or refused)
- Samples with two files: a call through a header, a header whose types differ from the definition (link error or check)
Metadata
Metadata
Assignees
Labels
converterSemantic checks and typed IR (src/converter)Semantic checks and typed IR (src/converter)enhancementNew feature or requestNew feature or requestfront-endLexer, pre-parser, parser, ASTLexer, pre-parser, parser, AST
Activity
feat: declare a function of another file without a body
docs: USE_OF_AI for November 7 and 8 (issues #33, #4, #12, #44)