I started this in another thread, but I think it deserves its own.
The question is, how does one measure syntax complexity, with the
specific case of Fortran vs. PL/I. (And ignoring syntax vs. semantics,
for now.)
I started this in another thread, but I think it deserves its own.
The question is, how does one measure syntax complexity,
with the[...]
specific case of Fortran vs. PL/I. (And ignoring syntax vs. semantics,
for now.)
One complication I see, is that syntax complexity as seen by people,
might be different from it as seen by programs.
On 2/16/23 12:08 AM, gah4 wrote:
One complication I see, is that syntax complexity as seen by people,
might be different from it as seen by programs.
How do programs recognize syntax complexity?
Number of rules and exceptions?
When I wrote that one, I was thinking about the places where Fortran uses special characters and PL/I uses words.
DO I=1,10,3
DO I = 1 TO 10 BY 3;
I think about them in a different way, such that the thought complexity is different.
A compiler doesn't "think" in that way.
I suppose I agree with the above, the length of the standard, with some assumptions on how it is written, or the length of the front end.
[Having written a couple of Fortran parsers, I can say that while the hacks to deal with ignored spaces were ugly, they weren't that hard. PL/I has a separate issue that the same token might be a keyword or a variable depending on context, and the kinds of parsers you build with bison et al don't deal very well with that. -John]
Scenario: you have a language that has a BNF. You write a statement in the language.
It is a relatively simple, basic statement. The statement conforms to the BNF.
To show its conformance, you write the derivation of the statement. Surprisingly, deriving the statement takes many, many rules.
Does that signify that the language's syntax is too complex?
Hello Compiler Experts!
Scenario: you have a language that has a BNF. You write a statement in
the language. It is a relatively simple, basic statement. The
statement conforms to the BNF. To show its conformance, you write the >derivation of the statement. Surprisingly, deriving the statement
takes many, many rules. Does that signify that the language's syntax
is too complex?
/Roger
[There are definitely things that are hard to say in BNF, even though
they're intuitively simple.
Another is floating point numbers with
optional "." and "E" but you need at least one of them. -John]
If you are restricted to BNF ... i.e. your tool does not allow
specifying precedence ... then recognizing even relatively simple
arithmetic expressions can (perhaps recursively) involve several
rules.
Of course, better than either solution is to design the language to
require that an IF-statement is terminated with, e.g., fi (Algol 68) or END (Modula-2).
Regular expression syntax is missing an operator that signifies the >intersection of the sets recognized by the operand regexps. Let's...
call this operator "&". Then this requirement for an FP number can be >expressed as:
([0-9.]*&.*[0-9].*)(E[0-9]+)?&.*[.E].*
[Wouldn't that pattern allow 1.2.3 ? -John]
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (2 / 14) |
Uptime: | 58:22:57 |
Calls: | 6,712 |
Files: | 12,243 |
Messages: | 5,355,631 |