peterzheng98 / compiler-2020 Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
10.2 双目运算符
增加:++ 和 -- 不返回值。
欢迎大家在这里写下自己想用的语言,评测Base:Ubuntu 18.04/16.04。
支持的语言列表:
C++(C++98、C++11、C++14,使用 gcc 7.4.0 或 clang 7.0.0 构建)
Java(OpenJDK 11.0.6,使用 Javac 构建)
Swift(Swift 5.1.3,使用 Swift 构建)
Python3(Python 3.6.9,使用 Python3 执行)Python2 is deprecated.
NASM(NASM 2.13.02,使用 NASM 构建并使用 gcc 链接)(测试中)
以下是可能的支持列表,这意味着如果有同学提出要求则会测试尝试搭建。
Go(go1.13.6,使用 go 构建)
suppose A is a user-defined class
How many times will sentence A[] a = new A [10]; call constructor A() ?
In sema test array-4 (Verdict: Fail), we have the following pattern:
int[] a = new int[1][][1];
It is definitely wrong due to assigning int[][][] to [], but what is the behavior of "new int[1][][1]" (CE or something else)? Actually, the length of dimension after a dimension without length is meaningless.
Similar case appears in basic-36 (Verdict: Fail):
int [][][][][][][][][][][][][][][][][][][][] a = new int [1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][][l][][][]
Note that the 17-th dimension is l
rather than 1
, which cannot be resolved as any symbol in that scope.
Similar cases seemingly do not exist it other test cases, so the correctness of "the length of dimension after a dimension without length" is actually not tested by any test case.
Are the two behaviors below valid?
For example, consider the following code. Are these two behaviors valid?
int main() {
a = 0; // Use variable "a" before its declaration.
int a;
func(); // Call function "func" before its definition.
}
void func() {
println("Hello world!");
}
I had spent a whole night just to find to print to "output.s" but not stdout.
PLZ UPDATE YOUR FUCKING README
The first line is expected to be
O . . . . . . .
But the given output has
O . . . . . . .
Which lacks one space.
According to section 11, the expression if (1 == 1) foo(bar);
is invalid but this kind of expression was used in section 13.
Do code blocks in conditional expressions necessarily contains { <code> }
?
7.1 基础类型 7.2 数组类型
注:该部分的****指的是类型,可以是基础类型也可以是类。
需要排除void类型。
增加:类名和变量名重复是未定义的。
7.2 数组
允许数组静态定义,此时数组是Null。对Null的数组进行下表访问是非法的。
Hi! Is the operation undefined if any of the operands is a negative number in shift left/right operator?
For example, both -1 << 1
and 1 << -1
are undefined behaviors.
I think this should be undefined.
Thanks!
9.3 函数返回值
对返回值为void类型的函数,单独使用return代表立即退出函数。在return后接任何内容都视为语法错误。
语句可以只有一个单目表达式。
10.2 双目运算表达式
增加:对bool对象只能进行==和!=的比较,出现< > <= >=的比较是语法错误的。
I found several problems about sema testcases.
int
.(有一些函数的返回值类型为 int
,但函数没有 return statement)
string
.(有一些函数的返回值类型为 string
,但函数没有 return statement)
point
类,但函数无 return statement)++a
的值作为左值,与 Section 15 不符)
(++(++a))++;
++++a;
;
" is required.(行末漏写一个分号)for (int i = p - k; i <= p + k; i++)
is invalid(初始化语句多了个声明)!flag
is invalid since flag
is not bool type. (flag
是int
类型,不能作为 condition)a++
的返回值,与 Section 10.2 不符)
idx = countA++
, Line 51, Line 61 (misc-12.mx the same)i = i++
and Line 33What's the behavior of the following global variable declarations? (CE, Correct or UB)
(initialize with const value)
int a = 123;
(initialize with const expression)
int a = 123 ^ 789;
(initialize with decidable value, but complicated)
int f(int a, int b) { return a ^ b; }
int a = f(123, 789);
(initialize with non-decidable value, a function must be called run-time)
int a = getInt();
for (init; condition; incr) {
<Expressions and Statements if true>
}
Caninit
andincr
be code blocks?
7.1 基础类型
补充:任何形式的类型转换在本语言中是未定义的。
9.1 函数定义
增加:函数名和类名重复是未定义的。
class main{
int m;
};
int main(){
class main _main;
}
basic-57: Lack of '[]' or '"' or ";"?
basic-70: in Comment "No main function"
In class-14, we have the following code fragment:
class b {
int a;
int b() { this.a = a }
};
And it is considered compilation fail due to "Constructor Type Error".
However, it is more likely to resolve this function as a member function, rather than a constructor, as there is 2 tokens (limited to primitive types and identifiers, and in this case, int and b) before the brackets, while constructors always have only one.
Therefore, this may not be a proper case to test "Constructor Type Error".
Besides that, there currently seems to be no more cases testing "Constructor Type Error", and the following case is not tested in any test case:
class A {};
class B {
A() {}
};
13.1 作用域规则
补充:for语句即使没有大括号也会引入一个作用域。
void test(){
int a = 0;
for(;;) int a = 0;
}
可通过编译。
13.1 作用域规则条目3
错别字:所用->所有
My code at commit cd1aa8 can pass the semantic case set in provided local judge, but it accept the following code fragment: (obviously, a CE is expected)
int[] a = new int[false];
Another version (which I did not commit) even does not check the expression (and can pass the semantic case set in provided local judge) including further recursive type check, therefore even accepting the following code fragment:
int[] a = new int[1 < false];
Is there any test cases testing the type of expressions passed to array constructor?
In t22.mx, t24.mx, t31.mx and t64.mx, there may be some non-void functions having no return values in some cases.
If there is a line containing only one number, does getInt()
consume the end-of-line? (This may affect next getString()
)
Does the result of getString()
contain the end-of-line?
Some cases miss a space in the output session
Case | Where |
---|---|
t21 | at the end |
t2 | at the start of the first line |
t4 | at the end |
e1 | at the end |
Besides, case t12 should exit 0, but given exit 55
foo.foo.foo.(foo).foo.foo.foo.g().foo.b = getString().length();
I can't understand the .(foo)
usage of .
.
In doc 8.3 it should be <ClassObjectIdentifier>.<Identifier>
, I think there's no bracket allowed.
Addtionally, I found following code CE using different versions of g++ with message expected unqualified-id before ‘(’ token
class test {
public:
int a;
};
int main() {
test a;
a.(a) = 1;
}
Following code CE using Java 8 with message error: need<Identifier>
public class test {
public String a;
public static void main(String[] args) {
test A = new test();
A.(a);
}
}
8.1 类成员变量
添加说明:访问未赋初值的类成员变量为未定义行为。
6.2 章节整数常量:
首位为0的整数常量未定义
修改为
首位为0的整数常量未定义(0除外)
use [git clone %s .] instead
in c ,-2 / 3 = 0, -2 % 3 = -2.
in python, -2 / 3 = -1, -2 % 3 = 1.
in mx, -2 / 3 = ? , -2 % 3 = ?
how to define / and % when it involves negative numbers?
judge/src/dockerTools.py:21: build(path=)
judge/src/core.py:211: The position of the dockerfile
According to 8., class declaration should have a semicolon after it.
But in several test data (i.e. basic-48), there's no semicolon after it. Surprisingly all those data fail with other reasons but not the semicolon.
So is there a must to have a semicolon after class declaration (like C++)? Or like Java the semicolons are parsed as empty statement.
If there's no such method, does it mean that every program with 'new' operations will cause a memory leak?
Hello, I have a question about basic-2.mx which is inconsistent with the manual.
/* basic-2.mx */
void AA() {}
class B {};
int main() {
int A;
B C = new B;
AA();
A = 10;
int B;
}
In Line 8, we declare int B;
with B be the identifier.
Note that in basic-2.mx, B
is also the name of a class.
However, in Section 14 of the manual, it says
所有符号共享一个命名空间,所以在同一个作用域里,变量,函数,和class,都不能同名如果重名视为语法错误,注意作用域规则。
So it seems that the declaration int B;
is invalid due to the quote above, or we need to modify the rules in Section 14 of the manual so that the rules of naming are more precise.
Thanks!
pindex[] is used without initializing
8.1 类成员变量
对于类成员变量,要求必须在构造函数中赋初值。对于没有赋值的成员变量的访问是未定义行为
The oj url in README seems to contain an extra 。
, is it intended or a mistake?
int getPrime(int N) {
int count;
int i;
count = 2;
for (i = 2; i <= N; i = i + 1) {
if (b[i] == 1) {
tmp[0] = tmp[0] + 1;
prime[tmp[0]] = i;
gps[i] = tmp[0];
}
while (i * count <= N) {
b[i * count] = 0;
count = count + 1;
}
count = 2;
}
}
The getPrime function has no return statement, same error in printF in misc-30.
It's not explicitly mentioned.
In my opinion, the array should be able to compare equality with the arrays of the same base type and dimension, since it can be assigned.
docker add command error on core.py
If use a simulator to run RISCV code, how to implement input, output and dynamically allocate memory ? These operations seem to depend on the operating system.
Is there any limitation on the length of input string, or it can be arbitrarily long?
Also, is it a must that the size of allocated memory for the result should fit the length of the input string, or I can allocate a large amount of memory even for a short input string?
t65 is deprecated, but it's still in judgelist.txt
10.2 双目运算符
删去后缀加定义
后缀加的返回值是void
The judge only fetch the user when it start up.
如果在Judge过程中添加用户无法正常响应。
In scope-6.mx
it creates with A a = new A();
, while in class-5.mx
it uses Cat cat; cat = new Cat;
, and in class-11.mx
it simply uses A b; int c = b.a;
. All of these 3 tests are marked with 'Success' verdict.
Are these all valid statements to create an instance?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.