Commit a5ae04a9 authored by uwdkn's avatar uwdkn

Merge branch 'lexer-testcases' into 'master'

Lexer Test Cases (Group 2)

See merge request !2
parents dec73056 20bff4a3
public class Summator {
public int sum(int[] array, int len) {
int sum = 0;
int i = 0;
while(i < len) {
sum += array[i];
i += 1;
}
return sum;
}
public static void main(String[] args) {
acc = new Summator();
int arrayLen = System.in.read();
int[] array = new int[arrayLen];
int i = 0;
while(i < arrayLen) {
array[i] = System.in.read();
i += 1;
}
int arraySum = acc.sum(array, arrayLen);
System.out.write(arraySum);
System.out.flush();
}
}
public
class
identifier Summator
{
public
int
identifier sum
(
int
[
]
identifier array
,
int
identifier len
)
{
int
identifier sum
=
integer literal 0
;
int
identifier i
=
integer literal 0
;
while
(
identifier i
<
identifier len
)
{
identifier sum
+=
identifier array
[
identifier i
]
;
identifier i
+=
integer literal 1
;
}
return
identifier sum
;
}
public
static
void
identifier main
(
identifier String
[
]
identifier args
)
{
identifier acc
=
new
identifier Summator
(
)
;
int
identifier arrayLen
=
identifier System
.
identifier in
.
identifier read
(
)
;
int
[
]
identifier array
=
new
int
[
identifier arrayLen
]
;
int
identifier i
=
integer literal 0
;
while
(
identifier i
<
identifier arrayLen
)
{
identifier array
[
identifier i
]
=
identifier System
.
identifier in
.
identifier read
(
)
;
identifier i
+=
integer literal 1
;
}
int
identifier arraySum
=
identifier acc
.
identifier sum
(
identifier array
,
identifier arrayLen
)
;
identifier System
.
identifier out
.
identifier write
(
identifier arraySum
)
;
identifier System
.
identifier out
.
identifier flush
(
)
;
}
}
EOF
/*
class Test {
public static void main(String[] args) {
return;
}
public boolean test() {
return true;
}
}
*/
public static void illegalIdentifier$() {}
System.out.println("Hello world!");
class Prog1 { public static void main(String[] args) {} }
class
identifier Prog1
{
public
static
void
identifier main
(
identifier String
[
]
identifier args
)
{
}
}
EOF
/* Comment (outer) /* Comment (still outer, nested comments not supported) */
public void method() {}
/* Code above should be included in lexed input */
public
void
identifier method
(
)
{
}
EOF
= == != < <= > >= + += - -= * *= / /= % %= ++ -- ! || && ? : ~ & &= | |= ^ ^= << <<= >> >>= >>> >>>= ( ) { } [ ] ; , .
=
==
!=
<
<=
>
>=
+
+=
-
-=
*
*=
/
/=
%
%=
++
--
!
||
&&
?
:
~
&
&=
|
|=
^
^=
<<
<<=
>>
>>=
>>>
>>>=
(
)
{
}
[
]
;
,
.
EOF
/=/* A comment with operators at either side */=
()(())(()())
[{[[][]]}]
(())
(
)
(
(
)
)
(
(
)
(
)
)
[
{
[
[
]
[
]
]
}
]
(
(
)
)
EOF
(
(
)
}
(
}
[
(
]
)
EOF
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment