Commit dbb75418 authored by Maximilian Stemmer-Grabow's avatar Maximilian Stemmer-Grabow

Add some basic lexer test cases

parent dec73056
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!");
abstract assert boolean break byte case catch char class const continue default double do else enum extends false finally final float for goto if implements import instanceof interface int long native new null package private protected public return short static strictfp super switch synchronized this throws throw transient true try void volatile while
abstract
assert
boolean
break
byte
case
catch
char
class
const
continue
default
double
do
else
enum
extends
false
finally
final
float
for
goto
if
implements
import
instanceof
interface
int
long
native
new
null
package
private
protected
public
return
short
static
strictfp
super
switch
synchronized
this
throws
throw
transient
true
try
void
volatile
while
EOF
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