Search in sources :

Example 1 with SyntaxLexer

use of priv.bajdcc.LL1.syntax.lexer.SyntaxLexer in project jMiniLang by bajdcc.

the class TestSyntaxLexer method main.

public static void main(String[] args) {
    try {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        SyntaxLexer lexer = new SyntaxLexer();
        lexer.setContext(str);
        Token token;
        for (; ; ) {
            token = lexer.nextToken();
            if (token.kToken == TokenType.EOF) {
                break;
            }
            System.out.println(token.toString());
        }
        scanner.close();
    } catch (RegexException e) {
        System.err.println(e.getPosition() + "," + e.getMessage());
        e.printStackTrace();
    }
}
Also used : Scanner(java.util.Scanner) SyntaxLexer(priv.bajdcc.LL1.syntax.lexer.SyntaxLexer) RegexException(priv.bajdcc.util.lexer.error.RegexException) Token(priv.bajdcc.LL1.syntax.token.Token)

Example 2 with SyntaxLexer

use of priv.bajdcc.LL1.syntax.lexer.SyntaxLexer in project jMiniLang by bajdcc.

the class TestSyntaxLexer method main.

public static void main(String[] args) {
    try {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        SyntaxLexer lexer = new SyntaxLexer();
        lexer.setContext(str);
        Token token;
        for (; ; ) {
            token = lexer.nextToken();
            if (token.kToken == TokenType.EOF) {
                break;
            }
            System.out.println(token.toString());
        }
        scanner.close();
    } catch (RegexException e) {
        System.err.println(e.getPosition() + "," + e.getMessage());
        e.printStackTrace();
    }
}
Also used : Scanner(java.util.Scanner) SyntaxLexer(priv.bajdcc.LALR1.syntax.lexer.SyntaxLexer) RegexException(priv.bajdcc.util.lexer.error.RegexException) Token(priv.bajdcc.LALR1.syntax.token.Token)

Aggregations

Scanner (java.util.Scanner)2 RegexException (priv.bajdcc.util.lexer.error.RegexException)2 SyntaxLexer (priv.bajdcc.LALR1.syntax.lexer.SyntaxLexer)1 Token (priv.bajdcc.LALR1.syntax.token.Token)1 SyntaxLexer (priv.bajdcc.LL1.syntax.lexer.SyntaxLexer)1 Token (priv.bajdcc.LL1.syntax.token.Token)1