LCC-Win32, TextPad & RegEx

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
David Guy

LCC-Win32, TextPad & RegEx

Post by David Guy »

Hi,

I'm using the Lcc-Win32 compiler and I want TextPad to jump to the file and line number contained in warning/error messages, but I can't get the RE right.

The captured output looks like so:

Error c:\filename.c: 147 error description is here
Warning c:\filename.c: 156 warning description is here

My last attempt looked something like this:

^\(Error\|Warning\) \(.^:+\): \([0-9]+\)

The way I see it:

^\(Error\|Warning\) ==> 'Error' or 'Warning'

\(.^:+\) ==> 'c:\filename.c'

\([0-9]+\) ==> 147 or 156

But its not working. :( I just get the "can not jump location under cursor" message.

I've searched thru the forum and see several people have asked a similar question, and looked at the TextPad docs, but having absolutely no passed experience with RE's its all wonderfully confusing. :)

Much Thanks In Advance,
David
Randall McDougall

Re: LCC-Win32, TextPad & RegEx

Post by Randall McDougall »

Have you got the file register and line register values set to 2 & 3 respectively? (the error/warning check is expression 1) ... there are some examples in the Help under find&Replace/Regular Expressions to Match Compilation Errors ...
David Guy

Re: LCC-Win32, TextPad & RegEx

Post by David Guy »

Hi,

Thanks for the input, Randall, but I figured it out. :)

What I wound up doing was coping several warning/ error messages into the TextPad editor and using a regular expression search to locate the relevant parts.

A correct RE for the warning/ error messages spit out by the Lcc-Win32 compiler:

Error c:\path\filename.c: 123 Error description
Warning c:\path\filename.c: 456 Warning description

is (drum roll please):


^\(Error\|Warning\)_\(.:[^:]+\):_\([0-9]+\)


(NOTE: Underscores are used to denote spaces, they are not part of the expression!)

The expression from (roughly) inside-out and left-to-right reads:

1) Start at the beginning of the line: '^'
2) Find the word 'Error' or 'Warning': 'Error\|Warning'
3) Store the word in TextPad register one: '\(...\)'
3) Match & Discard a single space: ('_')
4) Find a single character (any character), a semi-colon, and then one or more characters up until but not including a semi-colon: '.:[^:]+'
5) Store the found characters in TextPad register two: '\(...\)'
6) Match & Discard a semi-colon and a single space: ':_'
7) Find one or more digits, from 0 to 9 inclusive: '[0-9]+'
8) Store the found digits in TextPad Register Three: '\(...\)'
9) Rest of line is ignored.
(Whew!)

Looking back at my previous attempt, I see was muffing up step 4.

BTW, if any more knowledgeable see anything amiss with my explanation above, please correct me! :) I just wanted to be very explicit, to help out any poor soul who may run into a similar problem in the future!

David
Andreas

Re: LCC-Win32, TextPad & RegEx

Post by Andreas »

Your explanation for step 4 and step 6 is wrong. You are talking about semikolons ;;;;;; (a comma with a dot above it) but you mean colons ::::::: (two dots, one above the other).

Otherwise, everything seems to be correctly explained.

Andreas
David Guy

Re: LCC-Win32, TextPad & RegEx

Post by David Guy »

LOL!

Oh man, that's embarassing! :)

Would you believe, I've only been reading and writing english for 30+ years! :)

Thanks for the correction, Andreas! :)

David
Bee Yang

Re: LCC-Win32, TextPad & RegEx

Post by Bee Yang »

Could you please help me configure Textpad to work with lcc compiler?
Thanks.
David Guy

Re: LCC-Win32, TextPad & RegEx

Post by David Guy »

Hi,

When you say "lcc compiler", do you mean the original lcc compiler by Christopher W. Fraser and David R. Hanson, or the Lcc-Win32 complier by Jacob Navia?

If you mean the original lcc, then sorry I can't help you: never used it.

If you mean the Lcc-Win32 compiler, then sure... I'll step you thru the setup. :)

David
Bee Yang

Re: LCC-Win32, TextPad & RegEx

Post by Bee Yang »

Yes, yes.. it is the lcc-win32, thanks a lot, David.

(sorry for replying late, the home connection's been down for the whole week, i'm using my school's pc now...)
David Guy

Re: LCC-Win32, TextPad & RegEx

Post by David Guy »

Ok,

I'll assume you have Lcc-Win32 installed on you system somewhere. Mine is installed in 'C:\Lcc-Win32', so that is the directory I will be using during this setup.

I'll will explain how to setup the Lcc-Win32 Make utility, as this utility uses the makefile output by Lcc-Win32, calling the compiler and linker as needed (makes building programs a lot simpler):

1) First, load up TextPad

2) Choose the 'Configure' menu option, and select 'Preferences'. This will show the 'Preferences' Dialog.

3) On the left side of this Dialog, you will see a list of options. The bottom one is named 'Tools'. Select it, and the right side of the Dialog will change. At the top will be an 'Add' button. Below that will be some text ("Use this form to add, delete ... ").

4) Press the 'Add' button, and a drop-down list will appear. Select 'Program' from the list.

5) A file browser window, with the title 'Select a File', will pop-up. Use this window to navigate to the Lcc-Win32 Make utility. It's called 'MAKE.EXE'. On my system is is located in 'c:\Lcc-Win32\bin'.

6) Select the make utility. It's name should appear in the text box labeled 'File name' at the bottom of the window. Press the button labeled 'Open' to the right of this text box.

7) This will take you back to the Perference dialog. There should now be an option in the large center text field called 'Make'. NOTE: to change the name to something else, just select it with the left mouse button, and hold the button down for a second or two. When you release the button, the option will change to a edit field, allowing you to change the name.

8) Select the 'Apply' button at the bottom of the 'Preferences' dialog. The 'Tools' option on the left side of the dialog should now have a small '[+]' next to it. Press the small '[+]'.

9) This will show a sub-list of options. One should be named 'Make'. Select the option named 'Make'. The right side of the 'Preferences' dialog should change. There will be three text-edit fields at the top labeled 'Command', 'Parameters' and 'Initial Folder'

In the field 'Command' there should be the location and name of the Lcc-Win32 make utility. On my system this box contains 'C:\Lcc-Win32\bin\make.exe'

--------------------
Now, from this point, how you fill in the rest of this dialog, that is to say, what you put in the 'Prameters' and 'Initial Folder' text-fields and which of the six check boxes you select, depends on how you plan to use the Lcc-Win32 and TextPad. I'll explain how I have it setup:

When I want create a new Lcc-Win32 Project, I:

A) create a directory with the name of the project.
B) create an empty source file, and place it in that directory.
C) open up Wedit, and create a new project, giving the project the SAME NAME as the directory created in step 'A'.
D) Add the empty source file to the new project.

After the project is created, inside the directory created in step 'A' above, is a sub-directory called 'lcc' and in that sub-directory is a file called 'makefile'. This file contains all the instructions needed for the make utility to 'Make' your program.

Next I create a TextPad workspace, located in the directory created in step 'A' above. I give the workspace the SAME NAME as the directory. Any time I want to work on a Lcc-Win32 project, I open up the TextPad Workspace.

NOTE: if you need help on setting up Lcc-Win32 projects or TextPad workspaces, I'm sorry but, I'm going to have to refer you to their respective sets of documentation. Neither is hard to setup, it's just more than I want to explain here. Sorry.
-----------------

I will now explain how to setup the rest of the 'Preferences' dialog to work with the way I have my system setup:

10) In there is any text in the 'Paremeters' edit-field, remove all of it.

11) In the 'Initial folder' edit-field type the following: "$WspDir\lcc". This tells TextPad to use the sub-directory named '\lcc' as the working location.

12) Select the 'Capture Output' check-box. This tells TextPad to collect any output from the make utitliy and display in a text window. This makes it easy to examine any error or warning messages.

13) The next section is labeled 'Regular expression to match output'. This is where you tell TextPad about the format of error and/or messages, so that by simply double-clicking on them, TextPad will take you to the file and line that generated the error/warning.

In the text-edit field just below the label, enter the below expression EXACTLY as shown:

^\(Error\|Warning\) \(.:[^:]+\): \([0-9]+\)

14) In the next section labeled 'Registers' there are three fields. In the 'File' field put a '2'. In the 'Line' field put a '3'. Leave the 'Column' field empty.

15) Press the 'Ok' button, and the 'Preferences' dialog will close.

If you select the 'Tools' menu options, you should see an option named 'Make'.

Now, everything is setup and ready to go! If you create a Lcc-Win32 project as I specified above, and create a TextPad workspace as I specified above, then open that TextPad workspace and type some code, when you select the 'Make' option, the code will be turned into a executable file that can be run (assuming no errors of course.)

Now as I said above, if you need more help with setting up project files, workspaces, etc. I'm going to have to direct you to the documentaion for both programs. Both sets of documentaion are very through and well written and contain all the information you'll need. Also, both TextPad and Lcc-Win32 have help forums that you can asked questions on. You've already found the TextPad help forum. The Lcc-Win32 one is at 'http://www.q-software-solutions.com/lccwin32/'

Well I hope all this has helped more that it has confused! :)

Good luck!

David
Post Reply