GithubHelp home page GithubHelp logo

compiler-2020's People

Contributors

engineev avatar peterzheng98 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

christsun

compiler-2020's Issues

About supported language

欢迎大家在这里写下自己想用的语言,评测Base:Ubuntu 18.04/16.04。
支持的语言列表:
C++(C++98、C++11、C++14,使用 gcc 7.4.0clang 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 构建)

Questions about array constructors

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.

About functions and variables

Are the two behaviors below valid?

  • Use a variable before its declaration.
  • Call a function before its definition.

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!");
}

out-of-date README

I had spent a whole night just to find to print to "output.s" but not stdout.

PLZ UPDATE YOUR FUCKING README

t2.mx has wrong output

The first line is expected to be

 O . . . . . . .

But the given output has

O . . . . . . .

Which lacks one space.

About conditional/loop expressions

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> } ?

Section 7 Variables

7.1 基础类型 7.2 数组类型
注:该部分的****指的是类型,可以是基础类型也可以是类。
需要排除void类型。

Sect. 7 Variables

7.2 数组
允许数组静态定义,此时数组是Null。对Null的数组进行下表访问是非法的。

Negative Operands for Shift Left/Right Operator

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!

Sect. 9 Function

9.3 函数返回值
对返回值为void类型的函数,单独使用return代表立即退出函数。在return后接任何内容都视为语法错误。

Sect. 10 Expressions

10.2 双目运算表达式
增加:对bool对象只能进行==和!=的比较,出现< > <= >=的比较是语法错误的。

Some problems about testcases

I found several problems about sema testcases.

  • There is no return statement and the return type is int.(有一些函数的返回值类型为 int,但函数没有 return statement)
    • basic-41.mx
    • basic-56.mx
    • class-2.mx
    • misc-24.mx
    • misc-33.mx
    • misc-29.mx Line 32 and Line 64
  • There is no return statement and the return type is string.(有一些函数的返回值类型为 string,但函数没有 return statement)
    • misc-34.mx Line 9
  • No return statement
    • misc-8.mx Line 37 and Line 42(该两个函数的返回值类型为 point 类,但函数无 return statement)
  • Lvalue (++a的值作为左值,与 Section 15 不符)
    • basic-66.mx (++(++a))++;
    • expression-2.mx ++++a;
  • CodeForces testcases
    • 71A.mx, Line 17, ";" is required.(行末漏写一个分号)
    • 399A.mx Line 17, for (int i = p - k; i <= p + k; i++) is invalid(初始化语句多了个声明)
    • 1145A.mx Line 18, !flag is invalid since flag is not bool type. (flagint类型,不能作为 condition)
  • Use the return value of postfix "++" (用到了 a++ 的返回值,与 Section 10.2 不符)
    • misc-3.mx, Line 20, idx = countA++, Line 51, Line 61 (misc-12.mx the same)
    • misc-14.mx, Line 31 i = i++ and Line 33
    • misc-16.mx, Line 37, Line 40, Line 43, Line 45
    • misc-24.mx, Line 18, Line 20
    • misc-25.mx, Line 22, Line 24
    • misc-29.mx, Line 24, Line 26 (misc-30.mx the same)

Questions about global variable

What'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();

About loop expressions

for (init; condition; incr) {
<Expressions and Statements if true>
}
Can init and incr be code blocks?

Section 7 Variable

7.1 基础类型
补充:任何形式的类型转换在本语言中是未定义的。

Sect.9 Functions

9.1 函数定义
增加:函数名和类名重复是未定义的。
class main{
int m;
};

int main(){
class main _main;
}

Errors in dataset

basic-57: Lack of '[]' or '"' or ";"?
basic-70: in Comment "No main function"

Questions about sema/class-14

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() {}
};

Section 13 Scopes

13.1 作用域规则
补充:for语句即使没有大括号也会引入一个作用域。
void test(){
int a = 0;
for(;;) int a = 0;
}
可通过编译。

Test cases about array constructor arguments

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?

Questions about input

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?

Issues in codegen testcases

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

Question about data set : basic-66

    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);
	}
}

Section 8 Class

8.1 类成员变量
添加说明:访问未赋初值的类成员变量为未定义行为。

Section 6 Integer Constant

6.2 章节整数常量:
首位为0的整数常量未定义
修改为
首位为0的整数常量未定义(0除外)

questions about / and %

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?

Is there a must to have a semicolon after class declaration?

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.

Question about data set: basic-2.mx

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!

Sect. 8 Classes

8.1 类成员变量
对于类成员变量,要求必须在构造函数中赋初值。对于没有赋值的成员变量的访问是未定义行为

About oj url

The oj url in README seems to contain an extra , is it intended or a mistake?

Some error in misc-30.mx!

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.

Can int[] compare equality with int[]?

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.

Questions about builtin function GetString

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?

Flow error in new user

The judge only fetch the user when it start up.
如果在Judge过程中添加用户无法正常响应。

How to create an instance of a class?

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.