JavaCC multiline comment in custom NetBeans plugin - netbeans

I am having a problem with comments in creating custom file in NetBeans. I got two types of multiline comment types:
starting with /* and ending */
starting with <!-- and ending -->
MORE :
{
"/*": XSCRIPT_COMMENT
|
"<!--": XML_COMMENT
}
<XSCRIPT_COMMENT>
TOKEN :
{
<X_SCRIPT_COMMENT_END: "*/" > : DEFAULT
}
<XML_COMMENT>
TOKEN :
{
<XML_COMMENT_END: "-->" > : DEFAULT
}
<XSCRIPT_COMMENT,XML_COMMENT>
MORE :
{
< ~[] >
}
the problem is, that both multiline comments throws TokenMgrError when I write the initial part of comment (/* or <!--). The error occurs only when there is no ending part and lexer reaches end of file.
My goal is to create multiline comments which works similar to other comment types (When only initial part is written, the rest of document is comment type text).
Please excuse my english, not my native language.

For me, MartinZ's aswer also resolve an JavaCC lexical problem.
{ <COMMENT: "/*" (~["*"])* |
"/*" (~["*"])* "*" (~["/"])* |
"/*" (~["*"])* "*" (~["/"])* "/" > }

One way to do it is to use a single regular expression to match comments. For example a /* .. */
multiline comment can be matched by
"/*" (("*")* ~["*"])* ("*" ("*")* "/"?)?
Here I made the final "*/" optional. (The best way to come up with this sort of regular expression, in my experience, is to convert an NDFA to an RE, if you know how to do that.)
Another way to do it is to allow an empty string to end a comment. Add these two rules.
<XML_COMMENT> TOKEN : { <XML_COMMENT_END: "" > : DEFAULT }
<XSCRIPT_COMMENT> TOKEN : { <X_SCRIPT_COMMENT_END: "" > : DEFAULT }

Solved by different regular expression. First I created deterministic automaton just with pen and paper, but graphic view is always the best.
<XSCRIPT_COMMENT:
"/*" (~["*"])*
|
"/*" (~["*"])* "*" (~["/"])*
|
"/*" (~["*"])* "*" (~["/"])* "/"
>
<XML_COMMENT:
"<!--" (~["-"])*
|
"<!--" (~["-"])* "-" (~["-"])*
|
"<!--" (~["-"])* "-" (~["-"])* "-" (~[">"])*
|
"<!--" (~["-"])* "-" (~["-"])* "-" (~[">"])* ">"
>
I realize that both expressions aren't from minimized DFA, but like this it is easier to understand.

Related

Make a dump of a session on fiddler without modification of Fiddler Rules

I want to do this things :
select a session
make a dump of this session (the issue is here)
Plus, I want to do that without modification of Fiddler Rules. I have done this with a modification of Fiddler Rules but the program will be used on several machines and it can be difficult to change Fiddler Rules in every machines.
I don't know if it is possible.
The code to do that with the modification of the fiddler Rules is :
PowerShell :
$filePath = "...\nameFile.txt" # file which contain the names of fiddler ZIP files
$file = Get-Content $filePath # content of nameFile
foreach ($line in $file) {
start $line # open the file
Write-Host "File : $line open"
Start-Sleep -s 1
}
& "...\Fiddler\ExecAction.exe" "failuresselection" # select all failures and make another file (see Fiddler Rules)
Fiddler Rules :
static function OnExecAction(sParams: String[]): Boolean {
[...]
// Select all failures and put them in a new ZIP file
case "failuresselection":
var path = "...\\Newlogs";
UI.actSelectSessionsWithResponseCode(449);
if (UI.GetFirstSelectedSession() != null){
UI.actSaveSessionsToZip(path+"\\Logs" + 449 + ".saz");
}
// Confirmation
FiddlerObject.StatusText = "Dumped all failures sessions to " + path;
UI.actExit();
return true;
[...]
}
I try this but it doesn't worked :
& "...\Fiddler\ExecAction.exe" "FiddlerApplication.UI.actSelectAll();"
It's to select all line but I think that ExecAction.exe replace QuickExec.
In summary, I am searching a way to do the same thing without modification of Fiddler Rules.

Prevent API URL from redirection. (Nginx - Website redirection)

I have to redirect users from website to mobile. I have added the following code for this -
set $mobile_rewrite do_not_perform;
## chi http_user_agent for mobile / smart phones ##
if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino") {
set $mobile_rewrite perform;
}
if ($http_user_agent ~* "^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-)") {
set $mobile_rewrite perform;
}
## redirect to m-development.abc.com ##
if ( $mobile_rewrite = perform) {
rewrite ^ http://m-development.abc.com$request_uri? redirect;
break;
}
The problem is it redirects the API as well. In order to prevent this, I added the following code -
location ~* /api.*$/ { set $mobile_rewrite do_not_perform; }
Above the line ## redirect to m-development.abc.com ##
But this does not work.
Can someone suggest the modification required in this line?
I would recommend nested location and avoid the if statement.
Especially since
If Is Evil
Handle the redirect inside the location - there is an excellent explanation here nginx url rewriting: difference between break and last and use the Negated Regular Expressions in location.
Define your configuration file as such -
location ~ "/example*" { # location include the cases you want to redirect
location ~ "!?/api/*" {
#do regular opperation
}
#redirect the way you want
}
Good Luck!

MSL Socket Script displaying html and body tag

When ever the mirc radio bot announces the song playing and the ammount of listeners a stray html and body tag show up as seen below.
The code for the radio bot is as follows
#announcer on
ctcp *:*:*:{
if ($1 == SRstats) {
set %sctat.chan $chan
sockclose scstat
sockopen scstat 149.202.90.221 8132
}
}
on *:SOCKOPEN:scstat:{
sockwrite -n $sockname GET /7.html HTTP/1.0
sockwrite -n $sockname User-Agent: Mozilla
sockwrite -n $sockname $crlf
}
on *:sockread:scstat:{
if ($sockerr > 0) return
:nextread
sockread -f %scasttemp
if ($sockbr == 0) return
if (%scasttemp == $null) %scasttemp = empty
set %scasttemp $remove(%scasttemp,<html><head><meta http-equiv="Pragma" content="no-cache"></head><body>,</body></html>)
if ((HTTP/1.* !iswm %scasttemp) && (content-type* !iswm %scasttemp) && (%scasttemp != empty)) {
set %scstat.song.temp $gettok(%scasttemp,7-,44)
set %scstat.bitrate $gettok(%scasttemp,6,44)
set %scstat.listeners $gettok(%scasttemp,1,44)
set %scstat.maxlist $gettok(%scasttemp,4,44)
set %scstat.peak $gettok(%scasttemp,3,44)
if ($gettok(%scasttemp,2,44) == 1) set %scstat.livedj connected
else set %scstat.livedj not connected
; changing some of the html codes back to regular characters
set %scast.song $replace(%scast.song,&,$chr(38),',$chr(39))
}
goto nextread
}
on *:sockclose:scstat:{
if (( %scstat.song.temp == %scstat.song ) || ( %scstat.song.temp == Line Recording )) { goto scstat.end }
else {
set %scstat.song %scstat.song.temp
set %song.msg 6,0 $+ %dj_nick is playing 6 : 12 %scstat.song $+ . 0,1 Tune into Radio-Airwaves, type !radiohelp/4 %scstat.listeners $+ --listeners are tuned in.
; set %chans $chan(0)
; while %chans {
/scid -a msg #Radio-Airwaves-Lounge %song.msg
; dec %chans
; }
:scstat.end
}
}
on *:TEXT:!playing:#: msg $chan %song.msg
#announcer end
I thought the first fix should be changing the , between the body tags to html number code but that just displayed the number code and not the actually comma. I also maybe there were mismatched tags/stray tags so I check for that. I didn't find any. I've yet to see the cause of the stray tags appearing when the accouner is on. Any help would be greatly appericated.
The line your trying to extract the information from, <html><body> at the start and end of the retrieved text.
You can solve this by setting %scasttemp using several techniques.
Strip the Html tags using $nohtml a like script. - Recomended
Staticly Substring from $right(%text, -12)
Dynamically find the first occurrence after body**>** and substring the rest of the text.
Use Regular Expressions
And many more..
$nohtml
alias nohtml { var %x,%y = $regsub($1-,/(<[^>]+>)/g,$null,%x) | return %x }
Additionally, when handling sockread i would use Tokenize to handle $1.. identifier instead of tokens.
if (!$sockbr || !%scasttemp) {
return
}
tokenize 32 $nohtml(%scasttemp)
;;; Comment out the below line if you still want to use the old variable, otherwise you should change the rest of the code.
;;;set %scasttemp $1-
;;; Identify the data we wish to extract the information, else return.
if ($numtok($1-, 44) < 7) {
return
}
;;; Rest of the code here..
Sending to server header request suggesting to close the connection after the information received is a good practice.
sockwrite -n $sockname Connection: close
Also adding the sockclose after all information received is a good convention instead of letting the sockets to hang around. (If Connection: close was not requested)
goto nextread
sockclose $sockname

How can I use a String in an URL?

I'm trying to create Web Service where I can send a stardog request using a HTTP GET method. My problem is that the stardog request are using a few symbol that aren't allowed in a URL, like ? or ; and I'm trying to not force the user to manually convert it to %3F or %3B.
So I want my URL to look like this :
localhost:8080/WebServiceTest/query?select="SELECT * WHERE {?s ?p ?o}"
My Jersey annotations are the following:
#GET
#Path("/query")
#Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public String execQuery(#QueryParam("select") String selectQuery, #QueryParam("update") String updateQuery) {
Does anyone know if this is possible? And if it is, how can I do that?
If you use Javascript/ECMAScript 5.1++ on client side you can convert a string to a uri string format. Use the method
encodeURIComponent(str);
which is explained here.
It is also possible to replace the ? ; chars by their %-represetation. (In the case of using cUrl)
(SPACE) ! " # $ % & ' ( ) * + , / : ;
%20 %21 %22 %23 %24 %25 %26 %27 %28 %29 %2A %2B %2C %2F %3A %3B
= ? # [ ]
%3D %3F %40 %5B %5D

Can I suppress vacuous 'More...' links on Doxygen class reference pages?

A Doxygen class reference page consists primarily of lists of class members, each followed by its brief description (if such exists). The member proper is a link to a details page for that member. Invariably the brief description is followed by a 'More...' link. The content of this link is identical to that of the member proper. This 'More...' link suggests - at least to me - that a more extended description is available at the other end of that link. This is misleading when the member has only a brief description. In that case the link points to a page which simply repeats that brief description and then states "Definition at line NN of file abcxyz.ext."
Is there anyway to get Doxygen to suppress these frustratingly vacuous 'More...' links?
Experimental patch for doxygen 1.8.10, which allows you to remove the "More..." links by using "USE_MORE_LINK = NO" in Doxyfile.
<!-- language: diff -->
=== modified file 'src/classdef.cpp'
--- src/classdef.cpp 2015-07-06 11:29:12 +0000
+++ src/classdef.cpp 2015-07-06 11:37:57 +0000
## -1802,12 +1802,14 ##
// HTML only
ol.pushGeneratorState();
- ol.disableAllBut(OutputGenerator::Html);
- ol.docify(" ");
- ol.startTextLink(getOutputFileBase(),
- anchor.isEmpty() ? QCString("details") : anchor);
- ol.parseText(theTranslator->trMore());
- ol.endTextLink();
+ if (Config_getBool("USE_MORE_LINK")) {
+ ol.disableAllBut(OutputGenerator::Html);
+ ol.docify(" ");
+ ol.startTextLink(getOutputFileBase(),
+ anchor.isEmpty() ? QCString("details") : anchor);
+ ol.parseText(theTranslator->trMore());
+ ol.endTextLink();
+ }
ol.popGeneratorState();
if (!anchor.isEmpty())
=== modified file 'src/config.xml'
--- src/config.xml 2015-07-06 11:29:12 +0000
+++ src/config.xml 2015-07-06 11:57:09 +0000
## -366,6 +366,13 ##
]]>
</docs>
</option>
+ <option type='bool' id='USE_MORE_LINK' defval='1'>
+ <docs>
+<![CDATA[
+ Experimental parameter, which allows you to remove the "More..." links by using USE_MORE_LINK = NO.
+]]>
+ </docs>
+ </option>
<option type='list' id='ABBREVIATE_BRIEF' format='string'>
<docs>
<![CDATA[
=== modified file 'src/filedef.cpp'
--- src/filedef.cpp 2015-07-06 11:29:12 +0000
+++ src/filedef.cpp 2015-07-06 11:31:41 +0000
## -373,8 +373,8 ##
ol.writeString(" \n");
ol.enable(OutputGenerator::RTF);
- if (Config_getBool("REPEAT_BRIEF") ||
- !documentation().isEmpty()
+ if ( (Config_getBool("REPEAT_BRIEF") || !documentation().isEmpty() ) &&
+ Config_getBool("USE_MORE_LINK")
)
{
ol.disableAllBut(OutputGenerator::Html);
=== modified file 'src/memberdef.cpp'
--- src/memberdef.cpp 2015-07-06 11:29:12 +0000
+++ src/memberdef.cpp 2015-07-06 11:37:48 +0000
## -1805,22 +1805,24 ##
{
static bool separateMemberPages = Config_getBool("SEPARATE_MEMBER_PAGES");
ol.pushGeneratorState();
- ol.disableAllBut(OutputGenerator::Html);
- //ol.endEmphasis();
- ol.docify(" ");
- if (separateMemberPages ||
- (m_impl->group!=0 && gd==0) ||
- (m_impl->nspace!=0 && nd==0)
- ) // forward link to the page or group or namespace
- {
- ol.startTextLink(getOutputFileBase(),anchor());
- }
- else // local link
- {
- ol.startTextLink(0,anchor());
- }
- ol.parseText(theTranslator->trMore());
- ol.endTextLink();
+ if (Config_getBool("USE_MORE_LINK")) {
+ ol.disableAllBut(OutputGenerator::Html);
+ //ol.endEmphasis();
+ ol.docify(" ");
+ if (separateMemberPages ||
+ (m_impl->group!=0 && gd==0) ||
+ (m_impl->nspace!=0 && nd==0)
+ ) // forward link to the page or group or namespace
+ {
+ ol.startTextLink(getOutputFileBase(),anchor());
+ }
+ else // local link
+ {
+ ol.startTextLink(0,anchor());
+ }
+ ol.parseText(theTranslator->trMore());
+ ol.endTextLink();
+ }
//ol.startEmphasis();
ol.popGeneratorState();
}
(Tentative answer as this particular case is not something I've ever needed to do.)
In the case that you want to remove all detailed descriptions (and thus, presumably, the links to it) you might be able to modify the 'layout' file to make that section invisible.
Reference: http://www.doxygen.nl/manual/customize.html#layout
Alternatively..
From your description it sounds like REPEAT_BRIEF is set on. If there really is no description beyond the first full stop then you may find that turning REPEAT_BRIEF off will remove the link, as the text there will truly be vacuous.
It might be a bit late but I faced the same problem and solved it easily, with the following doxyfile configuration:
ALWAYS_DETAILED_SEC = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = NO
EXTRACT_ALL = NO
# Since EXTRACT_ALL is NO, configure the following as you wish. In my case
EXTRACT_PRIVATE = YES
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = YES
I hope that helps.