Catalog · How the catalog works
Comment-Remover
This is a useful program for any programmer who does not want to have comments in their code.
- ★ 2 on GitHub
Anyone may press Interesting, signed in or not. It helps others find this project.
README
:computer: Comment-Remover:
</br>


</br>
In computer programming, a comment is text embedded in source code that a translator (compiler or interpreter) ignores. Generally, a comment is an annotation intended to make the code easier for a programmer to understand – often explaining an aspect that is not readily apparent in the program (non-comment) code. For this article, comment refers to the same concept in a programming language, markup language, configuration file and any similar context. Some development tools, other than a source code translator, do parse comments to provide capabilities such as API document generation, static analysis, and version control integration. The syntax of comments varies by programming language yet there are repeating patterns in the syntax among languages as well as similar aspects related to comment content.
The flexibility supported by comments allows for a wide degree of content style variability. To promote uniformity, style conventions are commonly part of a programming style guide. But, best practices are disputed and contradictory.
:wrench: Features:
- Remove Comments : Pascal, C/C++, JavaScript, HTML, Python, TypeScript, Go, Rust, Swift, C#/Sharp, Powershell, Ruby, Ada, R, Matlab
- Highlight Code in different Styles
- Compress Code
</br>
</br>
Languages
| Name | Command | Description |
|---|---|---|
| Pascal | // (*..*) {..} |
Pascal is an imperative and procedural programming language, designed by Niklaus Wirth as a small, efficient language intended to encourage good programming practices using structured programming and data structuring. It is named after French mathematician, philosopher and physicist Blaise Pascal. |
| C/C++ | // /*..*/ |
C/C++ is a general-purpose programming language created in the 1970s by Dennis Ritchie. By design, C gives the programmer relatively direct access to the features of the typical CPU architecture, customized for the target instruction set. |
| JavaScript | // /*..*/ |
JavaScript (JS) is a programming language and core technology of the Web, alongside HTML and CSS. Created by Brendan Eich in 1995,[6] it is maintained by Ecma International's TC39 technical committee, with related Web APIs maintained by W3C and WHATWG. |
| HTML | `````` | Hypertext Markup Language (HTML) is the standard markup language for documents designed to be displayed in a web browser. It defines the content and structure of web content. It is often assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScript. |
| Python | # """..""" |
Python is a high-level, general-purpose programming language that emphasizes code readability, simplicity, and ease-of-writing with the use of significant indentation, an extensive ("batteries-included") standard library, and garbage collection. Python supports multiple programming paradigms but with an emphasis on object-oriented programming and dynamic typing. |
| TypeScript | // /*..*/ |
TypeScript (TS) is a high-level programming language that adds static typing with optional type annotations to JavaScript. It is designed for developing large applications. It transpiles to JavaScript. It is developed by Microsoft as free and open-source software released under an Apache License 2.0. |
| Go | // /*..*/ |
Go is a high-level, general-purpose programming language that is statically typed and compiled. It is known for the simplicity of its syntax and the efficiency of development that it enables through the inclusion of a large standard library supplying many needs for common projects. |
| Rust | // /*..*/ |
Rust is a general-purpose programming language which emphasizes performance, type safety, concurrency, and memory safety. |
| Swift | // /*..*/ /**...*/ |
Swift is a high-level general-purpose, multi-paradigm, compiled programming language created by Chris Lattner in 2010 for Apple Inc. and maintained by the open-source community. Swift compiles to machine code and uses an LLVM-based compiler. |
| C#, CSharp | // /*..*/ /// |
C# is a general-purpose high-level programming language supporting multiple paradigms. |
| Powershell | # <#..#> |
PowerShell is a shell program developed by Microsoft for task automation and configuration management. As is typical for a shell, it provides a command-line interpreter for interactive use and a script interpreter for automation via a language defined for it. |
| Ruby | # |
Ruby is a general-purpose programming language designed with an emphasis on programming productivity and simplicity. In Ruby, everything is an object, including primitive data types. Development of the language began in the mid-1990s by Yukihiro "Matz" Matsumoto in Japan. |
| Ada | -- |
Ada is a structured, statically typed, imperative, and object-oriented high-level programming language, inspired by Pascal and other languages. It has built-in language support for design by contract (DbC), extremely strong typing, explicit concurrency, tasks, synchronous message passing, protected objects, and non-determinism. |
| R | # |
R is a programming language for statistical computing and data visualization. It has been widely adopted in the fields of data mining, bioinformatics, data analysis, and data science. |
| Matlab | % %{..%} |
MATLAB (Matrix Laboratory) is a proprietary multi-paradigm programming language and numeric computing environment developed by MathWorks. MATLAB allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages. |
</br>
Support for code comments is defined by each programming language. The features differ by language, but there are several common attributes that apply throughout.
Most languages support multi-line block (a.k.a. stream) and/or single line comments. A block comment is delimited with text that marks the start and end of comment text. It can span multiple lines or occupy any part of a line. Some languages allow block comments to be recursively nested inside one another, but others do not. A line comment ends at the end of the text line. In modern languages, a line comment starts with a delimiter but some older languages designate a column at which subsequent text is considered comment. Many languages support both block and line comments – using different delimiters for each. For example, C, C++ and their many derivatives support block comments delimited by /* and */ and line comments delimited by //. Other languages support only one type of comment.
C++ Example:
</br>
</br>
Comments can explain the author's intent – why the code is as it is. Some contend that describing what the code does is superfluous. The need to explain the what is a sign that it is too complex and should be re-worked.
- "Don't document bad code – rewrite it."
- "Good comments don't repeat the code or explain it. They clarify its intent. Comments should explain, at a higher level of abstraction than the code, what you're trying to do."
Line comment for Languages:
| Symbol | Languages |
|---|---|
| C | Fortran I to Fortran 77 (C in column 1) |
| Rem | BASIC, Batch files, Visual Basic |
| :: | Batch files, COMMAND.COM, cmd.exe |
| NB. | J; from the (historically) common abbreviation Nota bene, the Latin for "note well". |
| ⍝ | APL; the mnemonic is that the glyph (jot overstruck with shoe-down) resembles a desk lamp, and hence "illuminates" the foregoing. |
| # | Boo, Bourne shell and other UNIX shells, Cobra, Perl, Python, Ruby, Seed7, PowerShell, PHP, R, Make, Maple, Elixir, Julia, Nim |
| % | TeX, Prolog, MATLAB, Erlang, S-Lang, Visual Prolog, PostScript |
| // | ActionScript, Boo, C (C99), C++, C#, D, F#, Go, Java, JavaScript, Kotlin, Object Pascal (Delphi), Objective-C, PHP, Rust, Scala, Sass, Swift, Xojo, V (Vlang), Zig |
| ' | Monkey, Visual Basic, VBScript, Small Basic, Gambas, Xojo |
| ! | Factor, Fortran, Basic Plus, Inform, Pick Basic |
| ; | Most assembly languages, AutoHotkey, AutoIt, Lisp, Common Lisp, Clojure, PGN, Rebol, Red, Scheme |
| -- | Euphoria, Haskell, SQL, Ada, AppleScript, Eiffel, Lua, VHDL, SGML, PureScript, Elm |
| * | Assembler S/360 (* in column 1), COBOL I to COBOL 85, PAW, Fortran IV to Fortran 77 (* in column 1), Pick Basic, GAMS (* in column 1) |
| " | Vimscript, ABAP |
| \ | Forth |
| *> | COBOL 90 |
</br>
Delimiter:
In computing, a delimiter is a character or a sequence of characters for specifying the boundary between separate, independent regions in data such as a text file or data stream. For context, data boundaries can be indicated via other means. For example, declarative notation indicates the length of a field at the start of the field instead of relying on delimiters.
Delimiters are used for a wide range of purposes. The following examples demonstrate a small fraction of their applicability.
Bracket delimiters:
Bracket delimiters, also called block delimiters, region delimiters, or balanced delimiters, mark the start and end of a region of text. Commonly used bracket delimiters include:
| Delimiters | Description |
|---|---|
| ( ) | Parentheses; Lisp code is cited as recognizable by its use of parentheses |
| { } | Braces; also called curly brackets |
| [ ] | Square brackets; commonly used to denote a subscript |
| < > | Angle brackets |
| " " | Double quote; commonly used to denote a string literal |
| ' ' | Single quote; commonly used to denote a string literal or character literal |
| <? ?> | Used in XML to denote a processing instruction |
| /* */ | Used in many [programming languages]}(https://en.wikipedia.org/wiki/Programming_languagee to denote a comment |
| <% %> | Used in some web templates to specify a language boundary |
</br>
How can I integrate my own programming language:
To add an additional programming language, a few steps are required.
- Create a *.pas file named, for example,
VisualBasic.pasand copy the contents of thepascalDeleter.pasfile into your file and renames the unit. - Then the procedure and the function must be renamed.
procedure PAS_SetProgression(Eventer:TPurifyEvent);
function PAS_NoComments(RE:TStrings):real;
.. in ..
procedure PAS_SetProgressionVisualBasic(Eventer:TPurifyEvent);
function PAS_NoCommentsVisualBasic(RE:TStrings):real;Which must be called in the main unit
- Then the comments must be added to the characters that should be deleted
// Here everything in the area of the bracket with a star is deleted
if L2='(*' then
begin
r:=L1;
Comment:=true;
Key:=true;
Continue;
end;
if Key then
L2:=Copy(s,x-1,2);
if (Comment) and (L2='*)') then
begin
Comment:=false;
Key:=false;
r:=L1;
Continue;
end;
// Here everything after the specified string is deleted, in this case //
if L2='//' then
begin
CmtLine:=true;
r:=L1;
Continue;
end;- The command must then be renamed and executed in the main unit.
PAS_SetProgressionVisualBasic(Progression);
PerCent := PAS_NoCommentsVisualBasic(RichEdit1.Lines);</br>
How can I change the highlight colors:
To change the highlight colors, open the Highlight.pas file and modify the following sections.
In these sections, you can define the symbols or commands for highlighting.
Note: When adding or removing commands, the loop in the lower part of the code must add up to the same number of commands.
// symbols...
CodeC1: array[0..20] of String = ('#','$','(',')','*',',',
'.','/',':',';','[',']','{','}','<','>',
'-','=','+','''','@');
// These entries are highlighted by the style..
// If there is a change, the loop must be adjusted
CodeC2: array[0..44] of String = ('and','as','begin',
'case','char','class','const','downto',
'else','end','except','finally','for',
'forward','function','if','implementation','interface',
'is','nil','or','private','procedure','public','raise',
'repeat','string','to','try','type','unit','uses','var',
'while','external','stdcall','do','until','array','of',
'in','shr','shl','cos','div');Adjust this loop with the number
// Highlight all functions defined as arrays.
// When adding or removing words,
// the number of loops must be adjusted.
for i := 0 to 44 do
begin
with RichE do
begin
RichE.Lines.BeginUpdate;
StartPos := 0;
ToEnd := Length(Text) - StartPos;
FoundAt := FindText(CodeC2[i], StartPos, ToEnd, [stWholeWord]);
while (FoundAt <> -1) do
begin
SelStart := FoundAt;
SelLength := Length(CodeC2[i]);
SelAttributes.Color := C3;
SelAttributes.Style := [fsBold];
StartPos := FoundAt + Length(CodeC2[i]);
FoundAt := FindText(CodeC2[i], StartPos, ToEnd, [stWholeWord]);
end;
RichE.Lines.EndUpdate;
end;
end;Then your style name must be entered in the ComboBox of the main unit to call up the colors.
Back in the highlight unit, the name and colors must then be entered
// Styles
case Form1.ComboBox1.ItemIndex of
0 : style := 'Twilight';
1 : style := 'Default';
2 : style := 'Ocean';
3 : style := 'Classic';
4 : style := 'Oldskool';
end;
if Style = 'Twilight' then
begin
// Colors for the basic setting
BackC := clWhite; // Background Color
FontC := clBlack; // Font Color
C1 := clBlack; // Integer Color
C2 := clBlack; // Comments Color
C3 := clBlack; // function Color
strC := clBlue; // parameter Color
strC1 := clGreen; // brace Color
Gray := clGray; // Comment Color
end</br>
Here are some examples of how to integrate the characters:
// Coloring all comments that are behind a "//" up to the line break
Startpos := 0;
with RichE do
begin
RichE.Lines.BeginUpdate;
FoundAt := FindText('//', StartPos, Length(Text), []);
while FoundAt <> -1 do
begin
SelStart := FoundAt;
Startpos := FoundAt+1;
FoundAt := FindText(#13#10, StartPos, Length(Text), []);
if FoundAt <> -1 then
begin
SelLength := (FoundAt - selstart)+1;
SelAttributes.Style := [];
SelAttributes.Color := clGray;
StartPos := FoundAt+1;
FoundAt := FindText('//', StartPos, Length(Text), []);
end;
end;
RichE.Lines.EndUpdate;
end;
// Color all characters inside the curly bracket
Startpos := 0;
with RichE do
begin
RichE.Lines.BeginUpdate;
FoundAt := FindText('{', StartPos, Length(Text), []);
while FoundAt <> -1 do
begin
SelStart := FoundAt;
Startpos := FoundAt+1;
FoundAt := FindText('}', StartPos, Length(Text), []);
if FoundAt <> -1 then
begin
SelLength := (FoundAt - selstart)+1;
SelAttributes.Style := [];
SelAttributes.Color := strC1;
StartPos := FoundAt+1;
FoundAt := FindText('{', StartPos, Length(Text), []);
end;
end;
RichE.Lines.EndUpdate;
end;
// Coloring all strings within the commercial
Startpos := 0;
with RichE do
begin
RichE.Lines.BeginUpdate;
FoundAt := FindText('''', StartPos, Length(Text), []);
while FoundAt <> -1 do
begin
SelStart := FoundAt;
Startpos := FoundAt+1;
FoundAt := FindText('''', StartPos, Length(Text), []);
if FoundAt <> -1 then
begin
SelLength := (FoundAt - selstart)+1;
SelAttributes.Style := [];
SelAttributes.Color := strC1;
StartPos := FoundAt+1;
FoundAt := FindText('''', StartPos, Length(Text), []);
end;
end;
RichE.Lines.EndUpdate;
end;
// Color all strings within the brackets and star
Startpos := 0;
with RichE do
begin
RichE.Lines.BeginUpdate;
FoundAt := FindText('(*', StartPos, Length(Text), []);
while FoundAt <> -1 do
begin
SelStart := FoundAt;
Startpos := FoundAt+1;
FoundAt := FindText('*)', StartPos, Length(Text), []);
if FoundAt <> -1 then
begin
SelLength := (FoundAt - selstart)+1;
SelAttributes.Style := [];
SelAttributes.Color := clGray;
StartPos := FoundAt+1;
FoundAt := FindText('(*', StartPos, Length(Text), []);
end;
end;
RichE.Lines.EndUpdate;
end;
// Color all strings within the corner brackets
Startpos := 0;
with RichE do
begin
RichE.Lines.BeginUpdate;
FoundAt := FindText('[', StartPos, Length(Text), []);
while FoundAt <> -1 do
begin
SelStart := FoundAt;
Startpos := FoundAt+1;
FoundAt := FindText(']', StartPos, Length(Text), []);
if FoundAt <> -1 then
begin
SelLength := (FoundAt - selstart)+1;
SelAttributes.Style := [];
SelAttributes.Color := strC;
StartPos := FoundAt+1;
FoundAt := FindText('[', StartPos, Length(Text), []);
end;
end;
RichE.Lines.EndUpdate;
end;</br>

