Does anyone know if there is a way to add inline comments to InnoSetup source files?
I've done some experiments:
; a comment (allowed)
[Setup]
AppName=MyApp // a comment (allowed)
AppVersion=1.2.3.4 ; a comment (allowed)
DefaultDirName="{pf}\My App" seems you can have anything at all here (allowed)
[Dirs]
Name: "{userdocs}\My App"
Name: {userdocs}\MyApp // a comment (allowed)
Name: "{userdocs}\My App" // a comment (not allowed)
Name: {userdocs}\MyApp ; // a comment (not allowed)
Name: "{userdocs}\My App" ; // a comment (not allowed)
and (I think) I've found that a comment is allowed anywhere where the compiler isn't expecting any more operands, but I would prefer to use a more rigid syntax, if one exists.
How to comment in the script part of the source ?
In the script part of the source (which includes all the sections except the [Code] one), a semicolon at the beginning of a line separates a comment. It's described in the Script Format Overview topic as (emphasized by me):
You can put "comments" in the script (which are ignored by the
compiler) by placing a semicolon at the beginning of a line. For
example:
; This is a comment. I could put reminders to myself here...
So, that's about the script comment separator (for sections except [Code] one). Now, let's think about why we can't inline comments to any of those sections.
Why comments cannot be inlined in name value sections ?
In the name value sections like e.g. [Setup], [Messages] or similar, you cannot inline comments for their entries because the value portion is everything what follows the equal sign, no matter what it is. So, there is no comment in the following example section. Instead, the directives got pretty long and quite exotic values:
[Setup]
AppName=MyApp // a comment (allowed)
AppVersion=1.2.3.4 ; a comment (allowed)
DefaultDirName="{pf}\My App" seems you can have anything at all here (allowed)
Correct way to comment them would be to use separate lines starting with semicolons:
[Setup]
; comment for AppName
AppName=MyApp
; comment for AppVersion
AppVersion=1.2.3.4
; comment for DefaultDirName
DefaultDirName={pf}\My App
Why comments cannot be inlined in semicolon separated sections ?
For sections with semicolon separated parameters should not be possible to inline semicolon separated comment, just because of their separator. If that is possible in some condition, I would consider that as a (minor) bug caused by the compiler parser's laziness.
Related
I run JMP 15.2.0 and my jsl script includes this section of code, which has a minor bug:
for each row(
if (:ColumnA == 99, ColumnA = .)
);
The 2nd ColumnA should have a leading : in order to replace 99's with null. But for some reason this works, despite the bug, when run via JMP as a script, yet not when installed as an "Add-In".
Why would the exact same script work (i.e., 99's get nullified as intended) when run as a script, but not as an "Add-In" (99's remain and no error appears in the log)?
Shouldn't jsl be interpreted the same whether run through JMP as a script or as an "Add-In"? Could my JMP instance be somehow set to use different engines for different modes? Has anyone else observed this confounding JMP strangeness?
The reason this happens is due to how JMP handles scope. When you give an unscoped variable (is not of the form ns:var, :var, ::var), then JMP has a sequence to try to find the proper scope for the variable of interest. It goes something like this
Check local namespace -- if found, done
Check Current Data Table columns, if found, done
Check here namespace -- if found, done
Check global namespace -- if found, done
Since you did not define "Column A" anywhere in your script, the only valid name for which "Column A" applies is the column name.
Inside of a "For Each Row" statement the order is to check column names first (higher precedence than any other scope).
Update:
Note that the above list is for explicitly unscoped variables without any 'unscoped variable handling' -- that is, no "Names Default to Here( 1 )" line. Note that if you have that line starting the script then it does not affect the data table, as the unscoped "ColumnA" variable only ever gets placed within the Here namespace. JMP doesn't do scope-walking to see if it can find a "ColumnA" variable in the various listed namespaces above.
I've included a picture of the most common way of attaching a script to an addin -- this is what I'm assuming you're doing. Notice that by default the line 'Use the "Here" namespace for unqualified JSL variable names' is checked -- unqualified means has no colon (unscoped). This check-box is forcing JMP to only look at Here:ColumnA when seeing the unscoped variable. You need to run the script without any automatic scope control to work as it does when run as a standalone.
Addin scripts by default link unscoped variables to the "Here" namespace, making it so that unscoped column names don't work
Current data table(dt);
for each row(dt,
if (: ColumnA == 99, :ColumnA = .););
I'm trying to model a YAML-like DSL in Xtext. In this DSL, I need some Multiline String as in YAML.
description: |
Line 1
line 2
...
My first try was this:
terminal BEGIN:
'synthetic:BEGIN'; // increase indentation
terminal END:
'synthetic:END'; // decrease indentation
terminal MULTI_LINE_STRING:
"|"
BEGIN ANY_OTHER END;
and my second try was
terminal MULTI_LINE_STRING:
"|"
BEGIN
((!('\n'))+ '\n')+
END;
but both of them did not succeed. Is there any way to do this in Xtext?
UPDATE 1:
I've tried this alternative as well.
terminal MULTI_LINE_STRING:
"|"
BEGIN ->END
When I triggered the "Generate Xtext Artifacts" process, I got this error:
3492 [main] INFO nerator.ecore.EMFGeneratorFragment2 - Generating EMF model code
3523 [main] INFO clipse.emf.mwe.utils.GenModelHelper - Registered GenModel 'http://...' from 'platform:/resource/.../model/generated/....genmodel'
error(201): ../.../src-gen/.../parser/antlr/lexer/Internal..Lexer.g:236:71: The following alternatives can never be matched: 1
error(3): cannot find tokens file ../.../src-gen/.../parser/antlr/internal/Internal...Lexer.tokens
error(201): ../....idea/src-gen/.../idea/parser/antlr/internal/PsiInternal....g:4521:71: The following alternatives can never be matched: 1
This slide deck shows how we implemented a whitespace block scoping in an Xtext DSL.
We used synthetic tokens called BEGIN corresponding to an indent, and END corresponding to an outdent.
(Note: the language was subsequently renamed to RAPID-ML, included as a feature of RepreZen API Studio.)
I think your main problem is, that you have not defined when your multiline token is ending. Before you come to a solution you have to make clear in your mind how an algorithm should determine the end of the token. No tool can take this mental burdon from you.
Issue: There is no end marking character. Either you have to define such a character (unlike YAML) or define the end of the token in anather way. For example through some sort of semantic whitespace (I think YAML does it like that).
The first approach would make the thing very easy. Just read content until you find the closing character. The sescond approach would probably be manageable using a custom lexer. Basically you replace the generated lexer with your own implemented solution that is able to cound blanks or similar.
Here are some starting points about how this could be done (different approaches thinkable):
Writing a custom Xtext/ANTLR lexer without a grammar file
http://consoliii.blogspot.de/2013/04/xtext-is-incredibly-powerful-framework.html
Is there a way to comment M code / comment out lines or blocks of code?
M supports two different types of comments:
Single line comments can be started with //
You can comment out multiple lines or comment out text in the middle of a line using /* */ (e.g. = 1 + /* some comment */ 2)
Comments might seem to disappear in the formula bar if they are at the end of the line, but they are still there. You can verify this by looking at your code in the Advanced Editor.
Say I have code like this
some_line_of_code
some_line_of_code
/* some comment about code */
some_line_of_code
some_line_of_code
and i would like to comment out a whole block like this
/*
some_line_of_code
some_line_of_code
/* some comment about code */
some_line_of_code
some_line_of_code
*/
As you can see even SO code parser will not consider last 2 lines of code comments. Is it possible to comment out blocks of code that contain comments?
edit :
To clarify, I need this to be able to comment out large sections of code to check if a function I changed can compile in a package that otherwise can't be compiled until all changes have been done.
In SQL Developer, I highlight all lines of PL/SQL that I want commented and use Ctrl + /.
Obviously, you would like a way to comment and uncomment multiple lines quickly. This will put -- in front of each line you have highlighted. Do the same command to uncomment.
you can assign a function key through Tools > Preferences > Key Configuration (Edit / Selection / Comment Lines).
Shortcut to comment a line:
Command + Option + /
(in Mac)
As was stated by #Acroneos, there is no way. This is common behaviour of most programming languages. Comments as well as oher tokens are recognized by lexers. And lexers work with context-free grammars. i.e. lexes usually can recognize only reqular expressions.
You can still use C/C++ approach (#if 0/#endif). See Conditional compilation. But it does not look "so nice".
begin
something1;
$if false $then
something2;
$endif;
endl;
you can use --
so this code :
some_line_of_code
some_line_of_code
-- some comment about code
some_line_of_code
some_line_of_code
will be :
--some_line_of_code
--some_line_of_code
---- some comment about code
--some_line_of_code
--some_line_of_code
No, because everything between first delimiter until the next last delimiter will be recognized as comment (=not processed by compiler). Thats how multiline-comments work: If first delimiter (/ * ) is recognized, compiler will ignore anything until the very next last delimiter ( * /) is recognized. Now as you know this, you should be able to understand, why your second / * will never be recognized as a comment-delimiter by the compiler.
However, you can mark comments with special characters or concatenations within the multiline-comment-sector to line out comments into different sections.
in sql developer ; default shortcut is : ctrl + shift + c
In Sql Developer,You can use the following commands...
For Commenting Sql Statements...
ctl and / keys
For un-commenting Sql Statements...
ctl and / keys again
Additionally, to format sql statement
ctl and F7
In C#, is there a reason why multi-line /* */ comments can't overlap? This also applies to HTML (and I'm sure lots of other languages) too.
e.g.
/*
int a = SomeFunction();
/* int i = 0; */
int b = SomeFunction();
*/
won't compile.
When writing code I often want to quickly check the logic, and isolate certain parts by removing a section using multi-line comments, but then have to go through the code block replacing all multi-line comments with single line ones //.
I don't like using single line comments to comment-out code blocks (even though Visual Studio provides shortcuts to do this) as these then affect text comments when it comes to removing all comments in the block using the shortcut.
Is there a reason why the multi-line comment cannot mean: 'ignore everything between here'?
I'm afraid this is the way how it's designed.
I think you should use single line comments as much as possible. It's also much clearer when you are viewing the history of a file in source control. If you commented an entire method with /* */ then only two lines will appear changed, otherwise the entire method will have been changed (// added).