Post by Grog on Jun 6, 2014 4:16:02 GMT -5
Now that I might have to face doing HLASM coding at work in an IDE (as opposed to using a 3270 session) I'd like to have the HLASM syntax highlighting working for real in that scenario as well. (The IDE can invoke an external editor.) This means basing it on the statement syntax rather than matching strings to elements in lists of known language statement types.
While syntax highlighting makes the code more readable, its real power lies (I think) in its ability to detect and highlight syntax mistakes as the code is being written, saving on testing time down the track, and improving code quality.
Now, the syntax of some languages can be quite daunting to emulate in code, but 360/370/390/z assembler - and JCL for that matter - have a simple (old fashioned, I'm sure) column based syntax that can be simple to analyze in code. If implemented, it would remove any need to maintain word lists containing the instruction mnemonics as well as instructions for the assembler itself, not to mention any macros that might get used.
I imagine logic would be something like:
1. If column 1 is blank then there is no label, otherwise the first expression is the label.
2. The first non-blank expression which does not start in column 1 is the instruction.
3. The first expression following the instruction is the operand specification.
4. Any non-blanks after the operand specification are comments.
(For bonus points:)
5. If a non-blank is present in column 72 then the statement is continued on the next line.
6. If this line is a continuation the the first 15 columns must be blanks.
Internally, each line can have end-of-line status flags indicating
1. Is the statement continued?
2. Is the statement ending still in a comment?
3. Is the statement ending still in a quoted string?
The flags would set the initial conditions when commencing the parse of the following record.
Some or all of these flags could also be used in general to add support for block comments in other languages.
If you wanted to use this scheme for JCL, you would have to check for the // in columns 1 and 2, and use column 3 to check for the presence of a label. Since JCL has so few statement types, you could even highlight invalid JCL statement types.
Back to assembler, you also have to suppress starting a quoted string for item attributes such as L, N, K, O, T - er, that's all I remember at the moment. L for length is the most commonly used, of course - the others appear more in macros.
Considering the complexity of the product at the moment, I'd hazard that the above could be achieved in only a couple of multi-hour hack attacks. The hardest part would be deciding how to request it for a file type extension in the PROFILE/AUTO spec.
Of course, you probably have your own ideas on how to do it which are far superior to the above.
BTW, I'm not keen on paying hundreds of dollars each year to license SlickEdit just for this feature.
:/
Thanks!
While syntax highlighting makes the code more readable, its real power lies (I think) in its ability to detect and highlight syntax mistakes as the code is being written, saving on testing time down the track, and improving code quality.
Now, the syntax of some languages can be quite daunting to emulate in code, but 360/370/390/z assembler - and JCL for that matter - have a simple (old fashioned, I'm sure) column based syntax that can be simple to analyze in code. If implemented, it would remove any need to maintain word lists containing the instruction mnemonics as well as instructions for the assembler itself, not to mention any macros that might get used.
I imagine logic would be something like:
1. If column 1 is blank then there is no label, otherwise the first expression is the label.
2. The first non-blank expression which does not start in column 1 is the instruction.
3. The first expression following the instruction is the operand specification.
4. Any non-blanks after the operand specification are comments.
(For bonus points:)
5. If a non-blank is present in column 72 then the statement is continued on the next line.
6. If this line is a continuation the the first 15 columns must be blanks.
Internally, each line can have end-of-line status flags indicating
1. Is the statement continued?
2. Is the statement ending still in a comment?
3. Is the statement ending still in a quoted string?
The flags would set the initial conditions when commencing the parse of the following record.
Some or all of these flags could also be used in general to add support for block comments in other languages.
If you wanted to use this scheme for JCL, you would have to check for the // in columns 1 and 2, and use column 3 to check for the presence of a label. Since JCL has so few statement types, you could even highlight invalid JCL statement types.
Back to assembler, you also have to suppress starting a quoted string for item attributes such as L, N, K, O, T - er, that's all I remember at the moment. L for length is the most commonly used, of course - the others appear more in macros.
Considering the complexity of the product at the moment, I'd hazard that the above could be achieved in only a couple of multi-hour hack attacks. The hardest part would be deciding how to request it for a file type extension in the PROFILE/AUTO spec.
Of course, you probably have your own ideas on how to do it which are far superior to the above.
BTW, I'm not keen on paying hundreds of dollars each year to license SlickEdit just for this feature.
:/
Thanks!