When I tried to compile it using make keyword it is giving me an error of:
premature end of file in lex.l file in line no 17.
%option noyywrap
%{
#include "grammer.tab.h"
%}
name ([0-9])
whitespace [ \r\t\v\f]
linefeed \n
%%
{name} { return NAME; }
":" { return COLON; }
"->" { return RIGHT_ARROW; }
"{" { return LEFT_BRACE;}
"}" { return RIGHT_BRACE;}
";" { return SEMICOLON;}
{whitespace}
{linefeed} ++yylineno;
%%
So someone kindly help me.
Error:-
Tail:-
enter image description here
You usually get this error from lex (or flex) when the last line is not terminated by a newline.
To resolve the error just put a blank line at the end of the file.
(The same is also true for yacc/bison)
I also note you have a missing action for the pattern {whitespace}. I suggest you might try:
{whitespace} ; /* No action */
%%
/* End of the file */
Related
I am new to Magento 2. I am testing a class with PhpUnit.
When I run the test I obtain this error:
ArgumentCountError : Too few arguments to function Magenio\Todo\Test\Unit\Service\TaskRepositoryTest::testGetList(), 0 passed in /opt/project/vendor/phpunit/phpunit/src/Framework/TestCase.php on line 1414 and exactly 1 expected
I checked the TestCase.php file and the line 1414 and related lines are those:
protected function runTest()
{
if (\trim($this->name) === '') {
throw new Exception(
'PHPUnit\Framework\TestCase::$name must be a non-blank string.'
);
}
$testArguments = \array_merge($this->data, $this->dependencyInput);
$this->registerMockObjectsFromTestArguments($testArguments);
try {
$testResult = $this->{$this->name}(...\array_values($testArguments));
} catch (\Throwable $exception) {
if (!$this->checkExceptionExpectations($exception)) {
throw $exception;
}
I didn't understand the syntax in this line:
$testResult = $this->{$this->name}(...\array_values($testArguments));
Can anyone explain me what the previous line means, please?
I forgot to ask another thing: what does mean ...\ before array_values?
This question is based on my previous one where my entire TYPO3 website didn't work.
Now, after adjusting the php-version (5.6.17) the website itself works, but one fe-plugin of my extbase extension doesn't work - even though it's identical to the one on a copy of the website where everything works. The other fe-plugin from the same extension directly worked out of the box.
I get the following error in the frontend whenever I call a page that contains this plugin and I don't know where to start searching for the cause.
(I changed my domain to <mydomain> and my plugin name to tx_myfeplugin_nameexte in the following error snippet):
#1: PHP Warning: rawurlencode() expects parameter 1 to be string, object given in /var/www/vhosts/<my-domain>/typo3/sysext/core/Classes/Utility/GeneralUtility.php line 1641 (More information)
TYPO3\CMS\Core\Error\Exception thrown in file
/var/www/vhosts/<my-domain>/typo3/sysext/core/Classes/Error/ErrorHandler.php in line 101.
49 TYPO3\CMS\Core\Error\ErrorHandler::handleError(2, "rawurlencode() expects parameter 1 to be string, object given", "/var/www/vhosts/<my-domain>…po3/sysext/core/Classes/Utility/GeneralUtility.php", 1641, array)
48 rawurlencode(TYPO3\CMS\Extbase\Persistence\Generic\QueryResult)
/var/www/vhosts/<my-domain>/typo3/sysext/core/Classes/Utility/GeneralUtility.php:
01639: } else {
01640: if (!$skipBlank || (string)$AVal !== '') {
01641: $str .= '&' . ($rawurlencodeParamName ? rawurlencode($thisKeyName) : $thisKeyName) . '=' . rawurlencode($AVal);
01642: }
01643: }
47 TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl("tx_myfeplugin_nameexte", array, "", boolean, boolean)
/var/www/vhosts/<my-domain>/typo3/sysext/core/Classes/Utility/GeneralUtility.php:
01636: $thisKeyName = $name ? $name . '[' . $Akey . ']' : $Akey;
01637: if (is_array($AVal)) {
01638: $str = self::implodeArrayForUrl($thisKeyName, $AVal, $str, $skipBlank, $rawurlencodeParamName);
01639: } else {
01640: if (!$skipBlank || (string)$AVal !== '') {
Did someone have the same error before or has an idea what I should try to do to fix this?
Thanks to the answer I guess I fixed it, because the error is not appearing any longer, by adding the following lines at line 1707 in file GeneralUtility.php:
if ($AVal instanceof \TYPO3\CMS\Extbase\Persistence\Generic\QueryResult) {
$AVal = $AVal->toArray();
}
lets have a look to the source:
foreach ($theArray as $Akey => $AVal) {
$thisKeyName = $name ? $name . '[' . $Akey . ']' : $Akey;
if (is_array($AVal)) {
$str = self::implodeArrayForUrl($thisKeyName, $AVal, $str, $skipBlank, $rawurlencodeParamName);
} else {
if (!$skipBlank || (string)$AVal !== '') {
$str .= '&' . ($rawurlencodeParamName ? rawurlencode($thisKeyName) : $thisKeyName . '=' . rawurlencode($AVal);
}
}
}
The array you give has to be a multidimensional array as it represents the parts of the url. Every element is testet being an array, so you could debug $AVal being an object but an array.
I guess that there could be an stdObject from any conversion you made before. Debugging will help you.
Second, what is the reporting you set in the install tool. Set it to production, will ist work then?
I am trying to create an associative array of associative arrays in gawk, and what I initially tried was:
options[key][subkey] = 1
However, when it got to this line, I unceremoniously received the error fatal: attempt to use scalar 'option["Declaration"]' as an array ("Declaration" being one of the main keys that my program uses, although I presume the exact value is irrelevant. At this particular point in the program, there was no "Declaration" entry assigned, although there were entries which had "Declaration" as a subkey on other entries, which may be meaningful).
So with a bit of googling, I found another stackoverflow question that looked like it answered my issue, so I put the following code immediately above it:
if (typeof(options[key])!="array") {
options[key] = 0;
delete options[key];
split("",options[key]);
}
However, this does not work either, instead now giving me the error: fatal: split: second argument is not an array
What am I doing wrong?
EDIT: Note, that I cannot use a basic 2-dimensional array here... for what I am doing, it is important that I am using one associative array to another because I need to be able to later identify the subkeys that were used on a given key.
Pursuant to requests below, I am posting the relevant functions that use the associative array, which may help clarify what is going on.
function add_concrete(key, concrete) {
if (key == concrete) {
return;
}
if (length(options[key])>0) {
for(i in options[key]) {
add_concrete(i, concrete);
}
}
contains[key][concrete] = 1
}
function add_options(name, value) {
subkey = trim(name);
if (subkey == "") {
return;
}
if (match(value, ";") > 0) {
exporting = 0;
}
split(value, args, /[ |;]*/);
for (i in args) {
key = trim(args[i]);
if (key != "") {
print("Adding " name " to " key);
options[key][subkey] = 1
if (concrete[key]) {
add_concrete(subkey, key);
}
}
}
}
Sorry, cooking at the same time. As you didn't post much, don't have much to work with, but with no "initialization":
$ awk 'BEGIN {
options[key] = 0;
delete options[key];
# options[key][1] # cant see me
split("",options[key]);
}'
awk: cmd. line:5: fatal: split: second argument is not an array
But with "initialization":
$ awk 'BEGIN {
options[key] = 0;
delete options[key];
options[key][1] # can see me
split("",options[key]);
}'
$_ # see this cursor happily blinking without any error
I need to make sure there's copyrights notice at the beginning of each file.
How can I use grunt to fail my build in case the copyrights statement is missing?
First of all, I'm assuming you are referring to *.js or *.html or other similar work files, and not to graphic or binary files.
This can be done, with a grunt.registerTask which will:
1. loop through all relevant files
2. Read and compare first line to copyright line
3. If different - re-write file but a new first line which will be the copyright info
Pretty simple. Again - this will not work on binary files. I wrote this for you but it seems very useful, I might consider adding it as a plugin. Field tested:
run it by grunt verifyCopyright and also make sure that if your files are in a different directory your change it, and also if you want to process other files add them to the list as well. good luck...
grunt.registerTask('verifyCopyright', function () {
var fileRead, firstLine, counter = 0, fileExtension, commentWrapper;
copyrightInfo = 'Copyright by Gilad Peleg #2013';
//get file extension regex
var re = /(?:\.([^.]+))?$/;
grunt.log.writeln();
// read all subdirectories from your modules folder
grunt.file.expand(
{filter: 'isFile', cwd: 'public/'},
["**/*.js", ['**/*.html']])
.forEach(function (dir) {
fileRead = grunt.file.read('public/' + dir).split('\n');
firstLine = fileRead[0];
if (firstLine.indexOf(copyrightInfo > -1)) {
counter++;
grunt.log.write(dir);
grunt.log.writeln(" -->doesn't have copyright. Writing it.");
//need to be careful about:
//what kind of comment we can add to each type of file. i.e /* <text> */ to js
fileExtension = re.exec(dir)[1];
switch (fileExtension) {
case 'js':
commentWrapper = '/* ' + copyrightInfo + ' */';
break;
case 'html':
commentWrapper = '<!-- ' + copyrightInfo + ' //-->';
break;
default:
commentWrapper = null;
grunt.log.writeln('file extension not recognized');
break;
}
if (commentWrapper) {
fileRead.unshift(commentWrapper);
fileRead = fileRead.join('\n');
grunt.file.write( 'public/' + dir, fileRead);
}
}
});
grunt.log.ok('Found', counter, 'files without copyright');
})
Instead of checking to see if it's there and failing, why not just have a task that automatically injects it? See grunt-banner.
https://github.com/thekua/grunt-regex-check could be what you want. You define the regex to check for and if it finds it then the task fails.
I'm sending back a bunch of image tags via JSON in my .ashx response.
I am not sure how to format this so that the string comes back with real tags. I tried to HtmlEncode and that sort of fixed it but then I ended up with this stupid \u003c crap:
["\u003cimg src=\"http://www.sss.com/image/65.jpg\" alt=\"\"\u003e\u003c/li\u003e","\u003cimg src=\"http://www.xxx.com/image/61.jpg\" alt=\"\"\u003e\u003c/li\u003e"]
What the heck is \u003c ?
here's my code that created the JSON for response to my .ashx:
private void GetProductsJSON(HttpContext context)
{
context.Response.ContentType = "text/plain";
int i = 1;
...do some more stuff
foreach(Product p in products)
{
string imageTag = string.Format(#"<img src=""{0}"" alt=""""></li>", WebUtil.ImageUrl(p.Image, false));
images.Add(imageTag);
i++;
}
string jsonString = images.ToJSON();
context.Response.Write(HttpUtility.HtmlEncode(jsonString));
}
the toJSON is simply using the helper method outlined here:
http://weblogs.asp.net/scottgu/archive/2007/10/01/tip-trick-building-a-tojson-extension-method-using-net-3-5.aspx
\u003c is an escaped less-than character in unicode (Unicode character 0x003C).
The AJAX response is fine. When that string is written to the DOM, it will show up as a normal "<" character.
You are returning JSON array. Once parsed using eval("("+returnValue+")") it is in readily usable condition.
EDIT: This code is from jquery.json.js file:
var escapeable = /["\\\x00-\x1f\x7f-\x9f]/g;
var meta = { // table of character substitutions
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'\\': '\\\\'
};
$.quoteString = function(string)
// Places quotes around a string, inteligently.
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.
{
if (escapeable.test(string))
{
return '"' + string.replace(escapeable, function (a)
{
var c = meta[a];
if (typeof c === 'string') {
return c;
}
c = a.charCodeAt();
return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
}) + '"';
}
return '"' + string + '"';
};
Hope this gives you some direction to go ahead.
all you need to do is to use javascript eval function to get a pure HTML (XML) markup on the front end.
i.e. in a ajax call to a webservice, this can be the success handler of tha call,
the service returns a complex html element:
...
success: function(msg) {$(divToBeWorkedOn).html(**eval(**msg**)**);alert(eval(msg));},
...