标签: syntax-error

为什么程序会出现"非法启动类型"错误?

这是相关的代码片段:

public static Rand searchCount (int[] x) 
{
    int a ; 
    int b ; 
    int c ; 
    int d ; 
    int f ; 
    int g ;
    int h ; 
    int i ; 
    int j ;
    Rand countA = new Rand () ;
        for (int l= 0; l<x.length; l++) 
        {
            if (x[l] = 0) 
            a++ ;
            else if (x[l] = 1) 
            b++ ;
        }
    }
    return countA ;

}
Run Code Online (Sandbox Code Playgroud)

(Rand是此方法所在类的名称)

编译时收到此错误消息:

Rand.java:77: illegal start of type
        return countA ;
        ^
Run Code Online (Sandbox Code Playgroud)

这里出了什么问题?这个错误信息是什么意思?

java syntax return syntax-error

5
推荐指数
1
解决办法
9万
查看次数

另一个存储过程语法错误 - IF-THEN-ELSE

使用postgresql 8.4,我正在尝试编写一个函数,它看起来像这样:

CREATE OR REPLACE FUNCTION addorupdate( smallint, varchar(7) ) RETURNS void AS
$$
BEGIN
 IF EXISTS (SELECT * FROM consist WHERE slave = $1) THEN
   UPDATE consist SET
    master = $2
    where slave = $1;
 ELSE
   INSERT INTO consist(slave, master) VALUES ( $2, $1 );
 END IF;
END;
$$
LANGUAGE SQL;
Run Code Online (Sandbox Code Playgroud)

但是,它失败了:

ERROR:  syntax error at or near "IF"
LINE 4:  IF EXISTS (SELECT * FROM consist WHERE slave = $1) THEN
Run Code Online (Sandbox Code Playgroud)

...而且我一直在浪费太多的时间和咖啡因来弄清楚为什么并且可以用新鲜的眼睛来帮助我.

如果我不清楚我想要实现什么:奴隶是一列独特的价值观.如果存在,请使用当前主服务器更新它.如果没有,请插入.

更新: 将语言更改为plpgsql,现在抛出:

ERROR:  language "plpgsql" …
Run Code Online (Sandbox Code Playgroud)

postgresql triggers stored-procedures syntax-error plpgsql

5
推荐指数
1
解决办法
3036
查看次数

"{} === null"在开发人员控制台中抛出语法错误

为什么当我输入{} === null控制台时它会抛出

SyntaxError:意外的令牌===

null === {} 按预期给我假.

javascript syntax-error

5
推荐指数
1
解决办法
99
查看次数

二进制/十六进制浮点输入

为什么基数10只允许小数点?为什么以下引发语法错误?

0b1011101.1101
Run Code Online (Sandbox Code Playgroud)

我打字的号码有些含糊不清吗?看起来没有可能的数字,字符串可以表示除了93.8125

同样的问题也适用于其他基地:

0x5d.d
Run Code Online (Sandbox Code Playgroud)

我可以用一个相当简单的函数来编程:

def base_float(number_string, base):
    n = number_string.split('.')
    number = int(n[0], base)
    if len(n) > 1 and len(n[1]):
        frac_part = float(int(n[1], base)) / base**len(n[1])
        if number < 0:
            frac_part = -frac_part
        number += frac_part
    return number
Run Code Online (Sandbox Code Playgroud)

它给了我预期的代表性:

>>> base_float('0b1011101.1101', 2)
93.8125
Run Code Online (Sandbox Code Playgroud)

int接受任意基数,但没有小数点,并float接受小数点但没有任意基数.为什么?

python floating-point numbers syntax-error python-2.7

5
推荐指数
1
解决办法
382
查看次数

访问表单 - 查询表达式中的语法错误(缺少运算符)

我在查询中创建的表单中收到语法错误.我创建了表单来限制对更改记录的访问.在尝试在表单上设置过滤器时,我会收到我尝试过滤的所有属性的语法错误.我相信这与()查询代码中内部连接的缺乏有关,但对我来说奇怪的是我可以毫无问题地过滤查询.以下是查询代码:

SELECT CUSTOMER.[Product Number], SALESPERSON.[Salesperson Number],
SALESPERSON.[Salesperson Name], SALESPERSON.[Email Address]
FROM SALESPERSON INNER JOIN CUSTOMER ON
SALESPERSON.[Salesperson Number] = CUSTOMER.[Salesperson Number];
Run Code Online (Sandbox Code Playgroud)

任何想法为什么只有表单会产生语法错误,或如何解决这个问题?

forms ms-access syntax-error access-vba

5
推荐指数
3
解决办法
12万
查看次数

不适当的I/O控制操作

我的问题很简单.但无法解决执行我的Perl脚本后收到的"不适当的I/O控制操作"错误.

#!C:/Perl/bin/perl.exe -w
use strict;

my $file = "D:/file.csv";
open(my $data, '<', $file) or die "Could not open '$file' $!\n";
while (my $line = <$data>) {
    chomp $line; 
    my @fields = split "," , $line;
    print $fields[1]."\n";
}
Run Code Online (Sandbox Code Playgroud)

任何想法,我做错了什么?我在Windows7上的ActiveState perl上运行此脚本

perl syntax-error

5
推荐指数
1
解决办法
5792
查看次数

将值推送到数组AngularJS

我试图用.push();将数据值推送到AngularJS中的数组,但我总是收到此错误消息:

Error: $scope.test.push is not a function
Run Code Online (Sandbox Code Playgroud)

这是我的HTML:

<div ng-controller="Test">
<div class="container">
<div class="col-sm-9 col-sm-offset-2">

    <div class="page-header"><h1>Testar</h1></div>
    <table class="table table-striped table-condensed">
    <thead>
        <tr>
            <th>Sträcka</th>
            <th>Tid</th>
         </tr>
    </thead>
        <tr ng-repeat="info in test"><td>{{info.stracka}}</td><td>{{info.tid}}</td></tr>
    </table>

    <form name="userForm" ng-submit="submitForm(userForm.$valid)" novalidate> <!-- novalidate prevents HTML5 validation since we will be validating ourselves -->
        <div class="form-group" ng-class="{'has-error' : userForm.stracka.$invalid && !userForm.stracka.$pristine, 'has-success' : userForm.stracka.$valid }">
            <label>Sträcka(m):</label>
            <input type="text" name="stracka" class="form-control" ng-model="form.stracka" required>
            <p ng-show="userForm.stracka.$invalid && !userForm.stracka.$pristine" class="help-block">Fel sträcka</p>
        </div>

        <div class="form-group" ng-class="{'has-error' : userForm.tid.$invalid && !userForm.tid.$pristine, …
Run Code Online (Sandbox Code Playgroud)

javascript syntax-error angularjs

5
推荐指数
1
解决办法
4万
查看次数

使用https时,ASP.NET调试器会出现http错误

我真的非常需要你的帮助,因为我的程序遇到了非常不寻常的问题:

  1. 当我尝试在本地IIS服务器7.5上调试我的ASP.NET或MVC应用程序时收到此错误:"无法在Web服务器上启动调试.由于语法无效,服务器无法处理调试请求."

    在此输入图像描述

  2. 直到今天,我在谷歌中找到了我能找到的所有解决方案.我花了12个小时试图解决这个问题.没有运气.

  3. 只有这个地址出现错误:http:// localhost/AspDemo不是这个:https:// localhost/AspDemo.基本上,我可以像往常一样调试,如果我把https而不是http.

  4. https在我的本地IIS服务器上禁用:),我的意思是它被设置为忽略.

  5. 此外,我可以在IIS控制面板中使用BOTH协议打开我的网站

  6. 如果我在Visual Studio的应用程序的属性中禁用ASP.NET调试器,应用程序运行正常.

  7. 这是httperr日志中的错误:

    2014-10-30 00:23:46 :: 1%0 2977 :: 1%0 80 - - - 400 - 动词 -

  8. 我不知道究竟在哪里,但在其他日志中,我看到了类似这样的内容:错误400"错误请求 - 无效动词"

  9. 一周前,我遇到问题的所有应用程序都与visual studio的asp.net调试器完美配合,我不知道发生了什么.

  10. 我怀疑有些更新.因为最近的更新也与我的自定义引导加载程序混乱.

  11. 当我启用跟踪时 - 使用http清空日志

  12. Fiddler日志也是空的,也许我可以在Fiddler中使用一些配置来生成更多日志?(当我使用https时,它当然使用修改后的machine.config记录)

永远感谢你的帮助,如果你需要更多的日志,请不要犹豫.

我也想提一下,是的,我在这个网站上看到了类似的帖子,但没有一个描述的问题与我的相似.

/编辑

从我能够观察到的,错误发生在调试器访问machine.config文件之前,你能告诉我如何在那一刻捕获错误吗?

==== /编辑2 ====

任何人?没有人知道答案吗?最近我能够在以下位置找到完整的错误消息:C:\ Users \\ AppData\Local\Temp\Visual Studio Web Debugger.log

http://localhost/MVCDemo/debugattach.aspx

Status code=400 (Bad Request)
Protocol version=1.1
Cached=False
Connection=close
Content-Length=326
Content-Type=text/html; charset=us-ascii
Date=Fri, 31 Oct 2014 03:44:14 GMT
Server=Microsoft-HTTPAPI/2.0

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" …
Run Code Online (Sandbox Code Playgroud)

asp.net debugging syntax-error

5
推荐指数
1
解决办法
543
查看次数

右移运算符用作模板参数时的语法错误

如果我获取右移位运算符的地址并将其作为模板参数传递,则右移位符号被误读为模板参数列表的末尾,由此产生的混淆导致多个错误.

template <class T, void(T::*)(int)> struct TemplateMagic {};
struct TestStruct { void operator>> (int) {} };

int main() {
//All the errors are on this line:
    TemplateMagic<TestStruct, &TestStruct::operator>> >* ptr; 
}
Run Code Online (Sandbox Code Playgroud)

在Microsoft Visual Studio Express 2013 for Windows桌面版本12.0.31101.00 Update 4中运行此操作会出现以下错误:

错误C2143:语法错误:缺少';' 在'>'之前

错误C2275:'TestStruct':非法使用此类型作为表达式

错误C2833:'operator>'不是可识别的运算符或类型

据我所知,operator>> >符号被分开,因此它将其读作operator>,然后是终止>以关闭模板参数,并以>lulz 的备用结束.我认为这是一个错误.

有没有办法改写这个,以便它被认为是有效的?

c++ templates syntax-error

5
推荐指数
1
解决办法
195
查看次数

IF语法错误

我在遵循MySQL指南的IF语法时遇到语法错误.

我的查询是:

if 0=0 then select 'hello world'; end if;
Run Code Online (Sandbox Code Playgroud)

从逻辑上讲,这应该选择'hello world',但我得到了

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'if (0=0) then select 'hello world'' at line 1
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use …
Run Code Online (Sandbox Code Playgroud)

mysql sql syntax if-statement syntax-error

5
推荐指数
1
解决办法
1445
查看次数