Re: [fpc-pascal] Breaking Pascal source lines
2013/9/6 Mark Morgan Lloyd > I'm sure there isn't a single "right" answer to this question, but if > transferring Pascal source to a system that enforces short lines (e.g. 78 > chars + CRLF) what's the best automatic breaking rule? > > One possibility is obviously to break after the rightmost space, but is it > valid to break after e.g. . (if not followed by a digit), ^ and possibly > others? > > Syntax errors are acceptable. Truncation isn't. > Yes. You could also split after ] and := and ; More tricky, you could recognize < < <> <= and <= But your splitter must be able to know when it is inside a string (no splitting) and outside. Which means your splitter should be able to recognize the right quote too and split after it if suitable. -- Frederic Da Vitoria (davitof) Membre de l'April - « promouvoir et défendre le logiciel libre » - http://www.april.org ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Breaking Pascal source lines
Howard Page-Clark wrote: On 06/09/2013 14:10, Mark Morgan Lloyd wrote: I'm sure there isn't a single "right" answer to this question, but if transferring Pascal source to a system that enforces short lines (e.g. 78 chars + CRLF) what's the best automatic breaking rule? One possibility is obviously to break after the rightmost space, but is it valid to break after e.g. . (if not followed by a digit), ^ and possibly others? Syntax errors are acceptable. Truncation isn't. Is it valid...? Yes. The compiler largely ignores line endings and line breaks (since they're inserted mainly for formatting, not syntax purposes). One exception is string constants, so your parser will have to track the "'" character and ensure a corresponding later match within the short line, or else insert a forced concatenation. The code Also single-line comments are obviously broken by wrap, i.e. preceded by // I can cope without trying to parse for strings etc., since I think that in all cases compiling a broken string would result in a syntax error. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Breaking Pascal source lines
Bernd Oppolzer wrote: Am 06.09.2013 18:16, schrieb Bernd Oppolzer: To keep the syntax correct, you can break after every symbol, that is: not inside identifiers, not inside numbers (including floating point constants) not inside quoted strings but anywhere else I am using a Pascal pretty print program, that knows about the syntax (a little) and outputs the source in lines of 72 chars at most - this limit can be modified via parameter, IIRC. But: at the moment it accepts only classical Pascal syntax (my extension of Stanford P4) - no FPC. So it makes not much sense to share it. But I compiled it with FPC recently, and it ran without problems on Windows. Kind regards Bernd it's not quite correct; if there are symbols like := that consist of more than one char, you must not break in the middle. In particular things like += which might not be expected by people used to other dialects. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Breaking Pascal source lines
On 06/09/2013 14:10, Mark Morgan Lloyd wrote: I'm sure there isn't a single "right" answer to this question, but if transferring Pascal source to a system that enforces short lines (e.g. 78 chars + CRLF) what's the best automatic breaking rule? One possibility is obviously to break after the rightmost space, but is it valid to break after e.g. . (if not followed by a digit), ^ and possibly others? Syntax errors are acceptable. Truncation isn't. Is it valid...? Yes. The compiler largely ignores line endings and line breaks (since they're inserted mainly for formatting, not syntax purposes). One exception is string constants, so your parser will have to track the "'" character and ensure a corresponding later match within the short line, or else insert a forced concatenation. The code type PInteger = ^ integer; has readability shortcomings, but compiles without a murmur. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Breaking Pascal source lines
Am 06.09.2013 18:16, schrieb Bernd Oppolzer: To keep the syntax correct, you can break after every symbol, that is: not inside identifiers, not inside numbers (including floating point constants) not inside quoted strings but anywhere else I am using a Pascal pretty print program, that knows about the syntax (a little) and outputs the source in lines of 72 chars at most - this limit can be modified via parameter, IIRC. But: at the moment it accepts only classical Pascal syntax (my extension of Stanford P4) - no FPC. So it makes not much sense to share it. But I compiled it with FPC recently, and it ran without problems on Windows. Kind regards Bernd it's not quite correct; if there are symbols like := that consist of more than one char, you must not break in the middle. Kind regards Bernd ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Breaking Pascal source lines
Am 06.09.2013 15:10, schrieb Mark Morgan Lloyd: I'm sure there isn't a single "right" answer to this question, but if transferring Pascal source to a system that enforces short lines (e.g. 78 chars + CRLF) what's the best automatic breaking rule? One possibility is obviously to break after the rightmost space, but is it valid to break after e.g. . (if not followed by a digit), ^ and possibly others? Syntax errors are acceptable. Truncation isn't. To keep the syntax correct, you can break after every symbol, that is: not inside identifiers, not inside numbers (including floating point constants) not inside quoted strings but anywhere else I am using a Pascal pretty print program, that knows about the syntax (a little) and outputs the source in lines of 72 chars at most - this limit can be modified via parameter, IIRC. But: at the moment it accepts only classical Pascal syntax (my extension of Stanford P4) - no FPC. So it makes not much sense to share it. But I compiled it with FPC recently, and it ran without problems on Windows. Kind regards Bernd ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Breaking Pascal source lines
I'm sure there isn't a single "right" answer to this question, but if transferring Pascal source to a system that enforces short lines (e.g. 78 chars + CRLF) what's the best automatic breaking rule? One possibility is obviously to break after the rightmost space, but is it valid to break after e.g. . (if not followed by a digit), ^ and possibly others? Syntax errors are acceptable. Truncation isn't. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal