TSE: <TSE>\mac\compile.s: Is capturing of multi-line error messages possible?

8 views
Skip to first unread message

knud van eeden

unread,
Feb 22, 2023, 5:40:22 PM2/22/23
to SemWare TSE Pro Text Editor, S.E. Mitchell
Sammy,

1. Single line error messages can be captured out of the box in the native TSE macro compile.s

2. But quite a few computer languages have in their output multiple error lines, thus more than one.

3. So do you know if by design using TSE <TSE>\mac\compile.s those multiple error message lines are possible to capture?

4. For example here the error output from Microsoft PowerShell for 1 error:

----
At C:\temp\helloworld.ps1:3 char:4
+ 1/0-adfasdfasdfasdll
+    ~~~~~~~~~~~~~~~~~
Unexpected token '-adfasdfasdfasdll' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken
---

5. One sees thus besides the error filename, error line and error column these multiple (=5) additional error lines:

+ 1/0-adfasdfasdfasdll
+    ~~~~~~~~~~~~~~~~~
Unexpected token '-adfasdfasdfasdll' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

6. But standard out of the box one will possibly only output to using the %6 parameter 
   and catch in TSE e.g. one line (of those total 5 lines).

Thanks
with friendly greetings
Knud van Eeden

Carlo Hogeveen

unread,
Feb 24, 2023, 9:36:56 PM2/24/23
to Semware @ GoogleGroups

Knud,

> 1. Single line error messages can be captured
> out of the box in the native TSE macro compile.s
> 2. But quite a few computer languages have in
> their output multiple error lines, thus more than one.
> 3. So do you know if by design using TSE <TSE>\mac\compile.s
> those multiple error message lines are possible to capture?

I researched this, and I got three times "no".

The first no:
TSE's compiler set-up identifies each error's message to be shown in the error window by using one regular expression, and in TSE one regular expression cannot capture multiple lines.

The second no:
For example, if your PowerShell example error output is representative for all PowerShell error output, then the first useful error line will not be the first error line, but the first following line that does not start with a "+".
For this you can define a message-rule in TSE's compiler setup.
A compilation from TSE would then not show the error's line number, but the useful error line.
The error's line number is less relevant anyway, because the source file will be positioned on that line.
I tested this with another compiler (see further on), and this worked.
That said, in general this only works with very specific compiler output, and the error window still only shows one line per error, albeit a more useful one.

The third no:
TSE's compiler set-up pretends to allow us to define a "user macro" to compose our own error message per error.
In theory we might use such a user macro to concatenate (parts of) several error lines into one error line.
So, the error window would still show one line per error, but we could scroll that line to the right to see more info.
In practice this "user macro" needs to be a public proc in Semware's "compiler-helper" macro, which is distributed with and might be overwritten by new TSE versions.
Also, "compiler-helper" and the required format and actions of the "user macro" are not documented.
In reality the configurable "user macro" is therefore a Semware macro.

Given these serious disadvantages, if someone really needed multi-line compiler errors in TSE, it would make the more sense that someone, not you of course, would program a new TSE compiler handler.

Aside, fun:
With TSE I created a FizzBuzzCompiler executable, and then set it up in TSE as a compiler for .fizzbuzz files.
(A compiler to check the output of a children's game is not a real-world thing, just a programmer's version of fun.)
For each line it tests that it only contains the line number or "fizz" or "buzz" or "fizzbuzz" in the right line, and otherwise outputs a compiler error.
https://en.wikipedia.org/wiki/Fizz_buzz
Because this gives me complete control of this compiler's error format, I could test all the scenarios that I needed.

Carlo




knud van eeden

unread,
Feb 25, 2023, 8:47:14 AM2/25/23
to sem...@googlegroups.com, Carlo Hogeveen

Carlo wrote


>The error's line number is less relevant anyway, because the source file will be positioned on that line.

Command line programming languages if error create typically almost always an

1. filename in which the error occurs
e.g. foobar.cpp

2. error line number
e.g. 10

3. error column
e.g. 5

(As an analogy  these are like Cartesian coordinates to be able to pinpoint exactly where in that file that/those specific error(s) occur(s)).

further

4. only one line error messages (e.g. in TSE)
or 
multiline error messages (e.g. in Powershell)

further

5. only 1 error is shown per each compilation 
or 
more than 1 errors are shown  per each compilation

For example TSE SAL shows a filename, an error line and an error column, it shows only 1 error per each compilation, it shows only 1-liner errors.

For example Borland C++ shows a filename, an error line and an error column, it shows multiple errors per each compilation, it shows only 1-liner errors

FYIO
therefore is knowing the line numbers relevant e.g. in case of e.g. Borland C++ because TSE will / can jump automatically to those individual error lines.

Otherwise one does not have enough information to be able to know where these different error lines are.

with friendly greetings 
Knud van Eeden


Sent from Yahoo Mail on Samsung Galaxy S23 Ultra 512 gigabytes

--

---
You received this message because you are subscribed to the Google Groups "SemWare TSE Pro text editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to semware+unsub...@googlegroups.com.

knud van eeden

unread,
Feb 25, 2023, 9:02:55 AM2/25/23
to TSE Pro Support
Carlo wrote:

> The third no:
TSE's compiler set-up pretends to allow us to define a "user macro" to compose our own error message per error.
In theory we might use such a user macro to concatenate (parts of) several error lines into one error line.
So, the error window would still show one line per error, but we could scroll that line to the right to see more info.
In practice this "user macro" needs to be a public proc in Semware's "compiler-helper" macro, which is distributed with and might be overwritten by new TSE versions.
Also, "compiler-helper" and the required format and actions of the "user macro" are not documented.
In reality the configurable "user macro" is therefore a Semware macro.

--

That is really a brilliant observation to point to.

Thanks for that.

There is indeed that concept of user TSE macro.

Not looked into that further but it could certainly be looked into as a workaround.

There is at least one example used in the default compile.dat file, I plan to have a look at that.

Then creating for each computer language such a user TSE macro in order to keep it general and uniform, used or not.

The idea of concatenating multiple error lines to one liner error lines instead occurred also to me as a workaround

But I was thinking to use my .bat files to do that concatenation. This by using intercepting the output to the TSE err.file.

instead of this in the .bat file:

1. ... >%6

using something like this:tiple error lines

1. ... >myerrorfile 

2. edit myerrorfile and concatenate the multiple error lines to 1 error line

3. then
type myerrorfile >%6

note: here %6 stands for the default TSE err.file.

Using a user TSE macro might thus be a more easy and streamlined solution or workaround.

Thanks
with friendly greetings 
Knud van  Eeden



Sent from Yahoo Mail on Samsung Galaxy S23 Ultra 512 gigabytes



On Sat, Feb 25, 2023 at 3:37, Carlo Hogeveen

knud van eeden

unread,
Feb 25, 2023, 9:11:04 AM2/25/23
to TSE Pro Support

> Carlo wrote 
> In practice this "user macro" needs to be a public proc in Semware's "compiler-helper" macro, which is distributed with and might be overwritten by new TSE versions.
Also, "compiler-helper" and the required format and actions of the "user macro" are not documented.
In reality the configurable "user macro" is therefore a Semware macro.

That would thus imply that only Semware (=Sammy) can give more information about that and clarify the details and or what shows to be possible...

with friendly greetings
Knud van Eeden

Sent from Yahoo Mail on Samsung Galaxy S23 Ultra 512 gigabytes

knud van eeden

unread,
Feb 25, 2023, 10:58:57 AM2/25/23
to Semware @ GoogleGroups
> Carlo wrote:
> Aside, fun:
> With TSE I created a FizzBuzzCompiler executable, and then set it up in TSE as a compiler for .fizzbuzz files.
(A compiler to check the output of a children's game is not a real-world thing, just a programmer's version of fun.)
For each line it tests that it only contains the line number or "fizz" or "buzz" or "fizzbuzz" in the right line, and otherwise outputs a compiler error.
Because this gives me complete control of this compiler's error format, I could test all the scenarios that I needed.

-Does the compiler also output executable code?

Or is it (only) a lexical analyser / parser?

-As can be seen it is further used in programmer hire interviews 

-Note: One could also do this mental exercise for themselves, e.g. keep on counting starting from 1 and determining (very quickly)
if it is fizz (=/3), buzz (=/5) or fizzbuzz (=/3 and /5). Then write down the result and checking e.g. with a table or computer program if it is indeed correct. Easy with low numbers, but less easy with larger number I guess.

But there are rules in mathematics about divisibility of any integer:

-A NUMBER IS DIVISIBLE BY 3 when the sum of the digits is divisible
 by 3.
 e.g.
 478917 is divisible by 3 because 4+7+8+9+1+7=36 is divisible by 3.

 Proof: substitute 3.3+1 for 10, use binomium Newton and look for pattern

---

-A NUMBER IS DIVISIBLE BY 5^n, if the number made by the last n digits of
 that number is divisible by 5^n

 e.g.

 852875 is divisible by 5^2=25 because 75 is divisible by 5^2.

 Proof: substitute 5+5 for 10 and work out via the binomium of Newton.

knud van eeden

unread,
Feb 25, 2023, 11:19:25 AM2/25/23
to Semware @ GoogleGroups
From this one can conclude very quickly in the head that:

1, 2, 3, ...

1. If the whole integer number digit sum is divisible by 3, thus ALWAYS at least FIZZ.

2. If the whole integer number ends with a 5 then it is ALWAYS divisible by 5, thus ALWAYS at least BUZZ.

3. If the whole integer number ends with a 0 then it is ALWAYS divisible by 5, thus ALWAYS at least BUZZ.

4. The distance between each fizz is thus 3 - 1 = 2 numbers, as all multiples of 3.

5. The distance between each buzz is thus 5 - 1 = 4 numbers, as all multiples of 5.

6. The distance between each fizzbuzz is thus 15 - 1 = 14 numbers, as all multiples of 5 . 3 = 15

1
2
3 fizz
4
5 buzz
6 fizz
7
8
9 fizz
10 buzz                                                                     dd
11
12 fizz
13
14
15 fizzbuzz
16
17
18 fizz
19
20 buzz
21 fizz
22
23
24 fizz
25 buzz
26
27 fizz
28
29
30 fizzbuzz
31
32
33 fizz
34
35 buzz
36 fizz
37
...



--

---
You received this message because you are subscribed to the Google Groups "SemWare TSE Pro text editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to semware+u...@googlegroups.com.

To view this discussion on the web visit

knud van eeden

unread,
Feb 25, 2023, 11:49:04 AM2/25/23
to TSE Pro Support
1. There is in the latest TSE 4.49f one (and only one) 'user macro' defined:

Extension=.java
Description=Jikes Java Compiler
Command=jikes.exe -c &fn& > &output&
Output=Tee Output, Run Hidden and Don't Prompt After Shell
 -Error=
  Error: Options=
  Error: Extra line (default empty line)=
 -FileName=
  FileName: Options=
  FileName: Tag=
 -Line=
  Line: Options=
  Line: Tag=
 -Column=
  Column: Options=
  Column: Tag=
 -Message=
  Message: Options=
  Message: Tag=
User Macro=jikes

2. Doing a grep in the <TSE> main directory shows:

f:\wordproc\tse_beta Sat 25-02-23 17:33:42>grep -i0s jikes *.*
SemWare Grep v2.03 for Win32 [Mar  3 2016]
Copyright 1996-2016 SemWare Corp. All rights reserved worldwide.

File: F:\WORDPROC\tse_beta\compile.dat
File: F:\WORDPROC\tse_beta\mac\compile.s
File: F:\WORDPROC\tse_beta\mac\compiler-helper.mac
File: F:\WORDPROC\tse_beta\mac\compiler-helper.s
File: F:\WORDPROC\tse_beta\read.me

3. That read.me file says:

---------------------------------------------------------------------
Jan 20 2007  v4.40.20
---------------------------------------------------------------------

   compile - added the ability to call external macros to parse error
        messages.  Useful when there is something particularly hard to
        parse (Such as the Jikes Java compiler).

4. The compiler-helper.s handles thus only 1 example, that is the Jikes Java compiler.

...
Sample source: bad.java

class HelloWorld {
    integer i

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
    if this works, I'll be surprised
}

Sample error messages:

Found 1 lexical error in "C:/d/user/jikes_cmplr/bad.java":

     7.     if this works, I'll be surprised
                            ^--^
*** Lexical Error: Character constant not properly terminated.

Found 5 syntax errors in "C:/d/user/jikes_cmplr/bad.java":

     2.     integer i
            ^-------^
*** Syntax Error: ";" inserted to complete ClassBodyDeclarations

            <
     6.     }
     7.     if this works, I'll be surprised
        ---------->
*** Syntax Error: Type expected instead

     7.     if this works, I'll be surprised
                            ^--^
*** Syntax Error: ; expected instead of this token

     7.     if this works, I'll be surprised
                                ^----------^
*** Syntax Error: ";" inserted to complete BlockStatement

                         <
     1. class HelloWorld {
   . . .
     8. }
        >
*** Syntax Error: "}" inserted to complete ClassBody

 *************************************************************************/

/*************************************************************************
   unprocessed error buffer format is:

   line-number:8 col-number:5 fn error message

   This format is necessary so that we can sort the messages in line
   number order, before placing bookmarks.

   The compile macro expects this file to be in this format:

   fn
   line-number col-number
   error message

 *************************************************************************/

5. The file 'compiler-helper.s' is further called in 'compile.s':

integer proc call_user_rule_macro(string cur_fn, integer err_id)
    string helper[30] = "compiler-helper"
    string debug[10] = iif(dbg_enabled, "-debug", "")


6. Altogether it looks like this is an ad-hoc (one only) solution for only the Jikes Java compiler,
as a lot of special (Jikes only related) source code inside that compiler-helper.s file,
possibly not intended now in this state to be easily generalized for many different computer languages.


Reply all
Reply to author
Forward
0 new messages