Code processor (not preprocessor, nompiler... POCESSOR!)

Started by
17 comments, last by aftermath 21 years, 2 months ago
When you see a word you don''t understand, it''s often helpful to google for it:
quote:
Sed (streams editor) isn''t really a true text editor or text processor. Instead, it is used to filter text, i.e., it takes text input and performs some operation (or set of operations) on it and outputs the modified text. Sed is typically used for extracting part of a file using pattern matching or substituting multiple occurances of a string within a file.


Think Liberally..
Advertisement
Dogh!

I thought it was some underground word that says “this guy is a jerk” or something like that. You know, like “pleh” or something.

I guess the AP should have been just a BIT more descriptive… sorry, or “my bad, dog!” as they say it.

dynamic sigs are fresh!
Rate me up.
Perl is nice for processing text...

Do you use Visual C++? If you do, then, in the Find/Replace dialog box, you can check "Regular expressions". This is a really powerful feature which lets you do really neat text replacements. I dunno if you''re familiar with regular expressions, if not then here''s some info..

Regular expressions let you search for complex patterns. For example:

To find a capital letter, you''d say:
[A-Z]

To find a string of lowercase letters you''d say:
[a-z]+

To find an identifier (some word which could potentially be used as a variable in some programming language):
\:i

To find a character which isn''t #:
[^#]

To turn a bunch of functions which look like:
void SetAlpha(int alpha)

into:

void Graphics::SetAlpha(int alpha)

You could say:

Find:
void \(\:i\)(\(\:i\))

Replace with:
void Graphics::\1(\2)

Once you get used to it, it''s pretty easy to spit out huge expressions like the ones above, so when you have some really repetitive text editing task, it can be quite handy..

Raj
Bump.

Perl and Python are currently on my list. I am trying to distinguish witch one to buy a book on. Any suggestions, with one is, um, better (please don’t start a war) ?

dynamic sigs are fresh!
Rate me up.
Python: should be plenty of introductory info on their site. However, it''s not the best at stream processing; that''s not what it was meant for. PERL, on the other hand, was originally designed for data processing and modification, and is somewhat easier to do this stuff in. Good info is available everywhere, but the O''Reilly books on Perl are by far the best.

Don''t listen to me. I''ve had too much coffee.
Try awk.
I was going to suggest awk, but it''s really more appropriate for files which are line-oriented -- C++ is not. You could separate by semicolons, but even that is very chancy (think about for statements). Also, awk is more useful for situations where the output does not closely resemble the input.

Still, awk is a great language to know; it''s perfect for implementing many one-off processing scripts.

Don''t listen to me. I''ve had too much coffee.
AWK -> Arranging Without Knowledge. Use ed.
I''m going to attempt a jump from flordia. I should end up in a pile of cheese in no time!
Please accept my radio signal!!

This topic is closed to new replies.

Advertisement