I'm trying to run this code in my command line. After I run this, I can type input in my command line
How do I run my input and get output? What buttons should I press?
import java.io.*;
import org.antlr.runtime.*;
public class ParseMain {
public static void main(String args[]) throws Exception {
//ProjLangLexer lexer = new ProjLangLexer(new ANTLRFileStream(args[0]));
ProjLangLexer lexer = new ProjLangLexer(new ANTLRInputStream(System.in));
CommonTokenStream tokens = new CommonTokenStream(lexer);
ProjLangParser parser = new ProjLangParser(tokens);
parser.input();
//ScanMain
Token tok = lexer.nextToken();
while (tok.getType() != Token.EOF) {
System.out.println("Lexeme = " + tok.getText() + " Token = " + tok.getType());
tok = lexer.nextToken();
}
}
Try Ctrl+Z then Enter to simulate EOF if in windows command line. If using unix, try Ctrl+D.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.