File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Assignment2/src/com/company Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 1- package com .company ;
1+ // package com.company;
22import java .util .List ;
33import java .util .Optional ;
44import java .util .Collections ;
@@ -50,6 +50,8 @@ public static List<Token> analyse(String sourceCode) throws LexicalException {
5050 tokenList .add (tokenTypeLE (s ).get ());
5151 } else if (furtherSplitList .get (i ).matches ("^[=].*" )) {
5252 tokenList .add (tokenTypeEqual (s ).get ());
53+ } else if (furtherSplitList .get (i ).matches ("^[!].*" )) {
54+ tokenList .add (tokenTypeNotEqual (s ).get ());
5355 } else {
5456 tokenList .add (tokenTypeEqual (s ).get ());
5557 }
@@ -110,6 +112,13 @@ private static Optional<Token> tokenTypeEqual(String t) {
110112 return Optional .empty ();
111113 }
112114
115+ private static Optional <Token > tokenTypeNotEqual (String t ) {
116+ Optional <Token .TokenType > type = Optional .of (Token .TokenType .NEQUAL );
117+ if (type .isPresent ())
118+ return Optional .of (new Token (type .get (), t ));
119+ return Optional .empty ();
120+ }
121+
113122 private static Optional <Token .TokenType > tokenTypeOf (String t ) {
114123 switch (t ) {
115124 case "public" :
You can’t perform that action at this time.
0 commit comments