Frank Heckenbach wrote:
Adriaan van Os wrote:
Do we have a way to qualify built-in routines, e.g. "program.round"
No, we don't (except by explicit wrappers, as others have described).
(as "system.round" refers to a "system" unit) ?
Yes, it refers to a `System' unit. But built-in identifiers are not declared in a `System' unit (which would violate EP where `System' is not a special name), but at "level 0" as Chuck calls it (I don't know if the standard has a term for it, I think it just talks of "required procedures and functions" and that they have a "definingpoint not contained by the programblock").
One could consider whether to add such a facility, but especially for built-in routines with special syntax (such as `WriteLn') this will probably not be easy, so I don't really like the idea.
Frank
Special syntax make this feature valuable: there is no way to emulate built-in syntax via wrappers. Also, it is one of biggest remaining BP incompatibilities.
Concerning implementation: I do not see how to do really nice implementation. But IMHO there are two reasonbly easy ways.
One is to check for "magic" module name in the lexer and then do a lookahead for dot and routine name. If there is a match generate apropriate "builtin" token. Of course, one needs an extra state machine in the lexer to avoid false positives. And extra logic in the parser to reject such names in places were qualified names are not allowed
Another way is to put GLR parser to an extreme: remove special treatment for builtins from the lexer and generate both normal parse and a parse as a builtion. Then use merge action to choose correct one.
As I write this yet another idea: parse everthing like `writeln' (it seem to be the most general form of a call) and then check in sematic actions if the routine identifier resolve to built-in. If no then reject calls using extended syntax. Structured value constructors work in similar way. Such approach can even make the compiler simpler then it is now.