diff --git a/Lexer/LexerOutput/PL0_code0.out b/Lexer/LexerOutput/PL0_code0.out index 4435b78..f640101 100644 --- a/Lexer/LexerOutput/PL0_code0.out +++ b/Lexer/LexerOutput/PL0_code0.out @@ -1,77 +1,77 @@ -['CONST', 'const', '-1'] -['IDENTIFIER', 'id', 'a'] -['EQUAL', '=', '-1'] -['NUMBER', 'num', '10'] -['SEMICOLON', ';', '-1'] -['VAR', 'var', '-1'] -['IDENTIFIER', 'id', 'd'] -['COMMA', ',', '-1'] -['IDENTIFIER', 'id', 'e'] -['COMMA', ',', '-1'] -['IDENTIFIER', 'id', 'f'] -['SEMICOLON', ';', '-1'] -['PROCEDURE', 'procedure', '-1'] -['IDENTIFIER', 'id', 'p'] -['SEMICOLON', ';', '-1'] -['VAR', 'var', '-1'] -['IDENTIFIER', 'id', 'g'] -['SEMICOLON', ';', '-1'] -['BEGIN', 'begin', '-1'] -['IDENTIFIER', 'id', 'd'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'a'] -['TIMES', '*', '-1'] -['NUMBER', 'num', '2'] -['SEMICOLON', ';', '-1'] -['IDENTIFIER', 'id', 'e'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'a'] -['DIVIDE', '/', '-1'] -['NUMBER', 'num', '3'] -['SEMICOLON', ';', '-1'] -['IF', 'if', '-1'] -['IDENTIFIER', 'id', 'd'] -['LESS_OR_EQUAL', '<=', '-1'] -['IDENTIFIER', 'id', 'e'] -['THEN', 'then', '-1'] -['IDENTIFIER', 'id', 'f'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'd'] -['PLUS', '+', '-1'] -['IDENTIFIER', 'id', 'e'] -['SEMICOLON', ';', '-1'] -['END', 'end', '-1'] -['SEMICOLON', ';', '-1'] -['BEGIN', 'begin', '-1'] -['READ', 'read', '-1'] -['LEFT_PARENTHESES', '(', '-1'] -['IDENTIFIER', 'id', 'e'] -['COMMA', ',', '-1'] -['IDENTIFIER', 'id', 'f'] -['RIGHT_PARENTHESES', ')', '-1'] -['SEMICOLON', ';', '-1'] -['CALL', 'call', '-1'] -['IDENTIFIER', 'id', 'p'] -['SEMICOLON', ';', '-1'] -['WHILE', 'while', '-1'] -['ODD', 'odd', '-1'] -['IDENTIFIER', 'id', 'd'] -['DO', 'do', '-1'] -['IDENTIFIER', 'id', 'e'] -['ASSIGN', ':=', '-1'] -['MINUS', '-', '-1'] -['IDENTIFIER', 'id', 'e'] -['PLUS', '+', '-1'] -['NUMBER', 'num', '1'] -['SEMICOLON', ';', '-1'] -['WRITE', 'write', '-1'] -['LEFT_PARENTHESES', '(', '-1'] -['IDENTIFIER', 'id', 'e'] -['COMMA', ',', '-1'] -['IDENTIFIER', 'id', 'f'] -['COMMA', ',', '-1'] -['IDENTIFIER', 'id', 'd'] -['RIGHT_PARENTHESES', ')', '-1'] -['SEMICOLON', ';', '-1'] -['END', 'end', '-1'] -['DOT', '.', '-1'] +['CONST', 'const', '-1'] +['IDENTIFIER', 'id', 'a'] +['EQUAL', '=', '-1'] +['NUMBER', 'num', '10'] +['SEMICOLON', ';', '-1'] +['VAR', 'var', '-1'] +['IDENTIFIER', 'id', 'd'] +['COMMA', ',', '-1'] +['IDENTIFIER', 'id', 'e'] +['COMMA', ',', '-1'] +['IDENTIFIER', 'id', 'f'] +['SEMICOLON', ';', '-1'] +['PROCEDURE', 'procedure', '-1'] +['IDENTIFIER', 'id', 'p'] +['SEMICOLON', ';', '-1'] +['VAR', 'var', '-1'] +['IDENTIFIER', 'id', 'g'] +['SEMICOLON', ';', '-1'] +['BEGIN', 'begin', '-1'] +['IDENTIFIER', 'id', 'd'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'a'] +['TIMES', '*', '-1'] +['NUMBER', 'num', '2'] +['SEMICOLON', ';', '-1'] +['IDENTIFIER', 'id', 'e'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'a'] +['DIVIDE', '/', '-1'] +['NUMBER', 'num', '3'] +['SEMICOLON', ';', '-1'] +['IF', 'if', '-1'] +['IDENTIFIER', 'id', 'd'] +['LESS_OR_EQUAL', '<=', '-1'] +['IDENTIFIER', 'id', 'e'] +['THEN', 'then', '-1'] +['IDENTIFIER', 'id', 'f'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'd'] +['PLUS', '+', '-1'] +['IDENTIFIER', 'id', 'e'] +['SEMICOLON', ';', '-1'] +['END', 'end', '-1'] +['SEMICOLON', ';', '-1'] +['BEGIN', 'begin', '-1'] +['READ', 'read', '-1'] +['LEFT_PARENTHESES', '(', '-1'] +['IDENTIFIER', 'id', 'e'] +['COMMA', ',', '-1'] +['IDENTIFIER', 'id', 'f'] +['RIGHT_PARENTHESES', ')', '-1'] +['SEMICOLON', ';', '-1'] +['CALL', 'call', '-1'] +['IDENTIFIER', 'id', 'p'] +['SEMICOLON', ';', '-1'] +['WHILE', 'while', '-1'] +['ODD', 'odd', '-1'] +['IDENTIFIER', 'id', 'd'] +['DO', 'do', '-1'] +['IDENTIFIER', 'id', 'e'] +['ASSIGN', ':=', '-1'] +['MINUS', '-', '-1'] +['IDENTIFIER', 'id', 'e'] +['PLUS', '+', '-1'] +['NUMBER', 'num', '1'] +['SEMICOLON', ';', '-1'] +['WRITE', 'write', '-1'] +['LEFT_PARENTHESES', '(', '-1'] +['IDENTIFIER', 'id', 'e'] +['COMMA', ',', '-1'] +['IDENTIFIER', 'id', 'f'] +['COMMA', ',', '-1'] +['IDENTIFIER', 'id', 'd'] +['RIGHT_PARENTHESES', ')', '-1'] +['SEMICOLON', ';', '-1'] +['END', 'end', '-1'] +['DOT', '.', '-1'] diff --git a/Lexer/LexerOutput/PL0_code1.out b/Lexer/LexerOutput/PL0_code1.out index d015c05..23dabc6 100644 --- a/Lexer/LexerOutput/PL0_code1.out +++ b/Lexer/LexerOutput/PL0_code1.out @@ -1,49 +1,49 @@ -['CONST', 'const', '-1'] -['IDENTIFIER', 'id', 'a'] -['EQUAL', '=', '-1'] -['NUMBER', 'num', '10'] -['SEMICOLON', ';', '-1'] -['VAR', 'var', '-1'] -['IDENTIFIER', 'id', 'b'] -['COMMA', ',', '-1'] -['IDENTIFIER', 'id', 'c'] -['SEMICOLON', ';', '-1'] -['PROCEDURE', 'procedure', '-1'] -['IDENTIFIER', 'id', 'p'] -['SEMICOLON', ';', '-1'] -['BEGIN', 'begin', '-1'] -['IDENTIFIER', 'id', 'c'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'b'] -['PLUS', '+', '-1'] -['IDENTIFIER', 'id', 'a'] -['END', 'end', '-1'] -['SEMICOLON', ';', '-1'] -['BEGIN', 'begin', '-1'] -['READ', 'read', '-1'] -['LEFT_PARENTHESES', '(', '-1'] -['IDENTIFIER', 'id', 'b'] -['RIGHT_PARENTHESES', ')', '-1'] -['SEMICOLON', ';', '-1'] -['WHILE', 'while', '-1'] -['IDENTIFIER', 'id', 'b'] -['NEQUAL', '#', '-1'] -['NUMBER', 'num', '0'] -['DO', 'do', '-1'] -['BEGIN', 'begin', '-1'] -['CALL', 'call', '-1'] -['IDENTIFIER', 'id', 'p'] -['SEMICOLON', ';', '-1'] -['WRITE', 'write', '-1'] -['LEFT_PARENTHESES', '(', '-1'] -['IDENTIFIER', 'id', 'c'] -['RIGHT_PARENTHESES', ')', '-1'] -['SEMICOLON', ';', '-1'] -['READ', 'read', '-1'] -['LEFT_PARENTHESES', '(', '-1'] -['IDENTIFIER', 'id', 'b'] -['RIGHT_PARENTHESES', ')', '-1'] -['SEMICOLON', ';', '-1'] -['END', 'end', '-1'] -['END', 'end', '-1'] -['DOT', '.', '-1'] +['CONST', 'const', '-1'] +['IDENTIFIER', 'id', 'a'] +['EQUAL', '=', '-1'] +['NUMBER', 'num', '10'] +['SEMICOLON', ';', '-1'] +['VAR', 'var', '-1'] +['IDENTIFIER', 'id', 'b'] +['COMMA', ',', '-1'] +['IDENTIFIER', 'id', 'c'] +['SEMICOLON', ';', '-1'] +['PROCEDURE', 'procedure', '-1'] +['IDENTIFIER', 'id', 'p'] +['SEMICOLON', ';', '-1'] +['BEGIN', 'begin', '-1'] +['IDENTIFIER', 'id', 'c'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'b'] +['PLUS', '+', '-1'] +['IDENTIFIER', 'id', 'a'] +['END', 'end', '-1'] +['SEMICOLON', ';', '-1'] +['BEGIN', 'begin', '-1'] +['READ', 'read', '-1'] +['LEFT_PARENTHESES', '(', '-1'] +['IDENTIFIER', 'id', 'b'] +['RIGHT_PARENTHESES', ')', '-1'] +['SEMICOLON', ';', '-1'] +['WHILE', 'while', '-1'] +['IDENTIFIER', 'id', 'b'] +['NEQUAL', '#', '-1'] +['NUMBER', 'num', '0'] +['DO', 'do', '-1'] +['BEGIN', 'begin', '-1'] +['CALL', 'call', '-1'] +['IDENTIFIER', 'id', 'p'] +['SEMICOLON', ';', '-1'] +['WRITE', 'write', '-1'] +['LEFT_PARENTHESES', '(', '-1'] +['IDENTIFIER', 'id', 'c'] +['RIGHT_PARENTHESES', ')', '-1'] +['SEMICOLON', ';', '-1'] +['READ', 'read', '-1'] +['LEFT_PARENTHESES', '(', '-1'] +['IDENTIFIER', 'id', 'b'] +['RIGHT_PARENTHESES', ')', '-1'] +['SEMICOLON', ';', '-1'] +['END', 'end', '-1'] +['END', 'end', '-1'] +['DOT', '.', '-1'] diff --git a/Lexer/LexerOutput/PL0_code2.out b/Lexer/LexerOutput/PL0_code2.out index 96b3663..21b3217 100644 --- a/Lexer/LexerOutput/PL0_code2.out +++ b/Lexer/LexerOutput/PL0_code2.out @@ -1,60 +1,60 @@ -['VAR', 'var', '-1'] -['IDENTIFIER', 'id', 'x'] -['COMMA', ',', '-1'] -['IDENTIFIER', 'id', 'squ'] -['SEMICOLON', ';', '-1'] -['PROCEDURE', 'procedure', '-1'] -['IDENTIFIER', 'id', 'minus'] -['SEMICOLON', ';', '-1'] -['BEGIN', 'begin', '-1'] -['IDENTIFIER', 'id', 'x'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'x'] -['PLUS', '+', '-1'] -['NUMBER', 'num', '1'] -['SEMICOLON', ';', '-1'] -['END', 'end', '-1'] -['SEMICOLON', ';', '-1'] -['PROCEDURE', 'procedure', '-1'] -['IDENTIFIER', 'id', 'square'] -['SEMICOLON', ';', '-1'] -['BEGIN', 'begin', '-1'] -['CALL', 'call', '-1'] -['IDENTIFIER', 'id', 'minus'] -['SEMICOLON', ';', '-1'] -['IDENTIFIER', 'id', 'squ'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'x'] -['TIMES', '*', '-1'] -['IDENTIFIER', 'id', 'x'] -['END', 'end', '-1'] -['SEMICOLON', ';', '-1'] -['BEGIN', 'begin', '-1'] -['IDENTIFIER', 'id', 'x'] -['ASSIGN', ':=', '-1'] -['NUMBER', 'num', '1'] -['SEMICOLON', ';', '-1'] -['WHILE', 'while', '-1'] -['IDENTIFIER', 'id', 'x'] -['LESS_OR_EQUAL', '<=', '-1'] -['NUMBER', 'num', '100'] -['DO', 'do', '-1'] -['BEGIN', 'begin', '-1'] -['CALL', 'call', '-1'] -['IDENTIFIER', 'id', 'square'] -['SEMICOLON', ';', '-1'] -['WRITE', 'write', '-1'] -['LEFT_PARENTHESES', '(', '-1'] -['IDENTIFIER', 'id', 'squ'] -['RIGHT_PARENTHESES', ')', '-1'] -['SEMICOLON', ';', '-1'] -['IDENTIFIER', 'id', 'x'] -['ASSIGN', ':=', '-1'] -['NUMBER', 'num', '2'] -['TIMES', '*', '-1'] -['IDENTIFIER', 'id', 'x'] -['PLUS', '+', '-1'] -['NUMBER', 'num', '1'] -['END', 'end', '-1'] -['END', 'end', '-1'] -['DOT', '.', '-1'] +['VAR', 'var', '-1'] +['IDENTIFIER', 'id', 'x'] +['COMMA', ',', '-1'] +['IDENTIFIER', 'id', 'squ'] +['SEMICOLON', ';', '-1'] +['PROCEDURE', 'procedure', '-1'] +['IDENTIFIER', 'id', 'minus'] +['SEMICOLON', ';', '-1'] +['BEGIN', 'begin', '-1'] +['IDENTIFIER', 'id', 'x'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'x'] +['PLUS', '+', '-1'] +['NUMBER', 'num', '1'] +['SEMICOLON', ';', '-1'] +['END', 'end', '-1'] +['SEMICOLON', ';', '-1'] +['PROCEDURE', 'procedure', '-1'] +['IDENTIFIER', 'id', 'square'] +['SEMICOLON', ';', '-1'] +['BEGIN', 'begin', '-1'] +['CALL', 'call', '-1'] +['IDENTIFIER', 'id', 'minus'] +['SEMICOLON', ';', '-1'] +['IDENTIFIER', 'id', 'squ'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'x'] +['TIMES', '*', '-1'] +['IDENTIFIER', 'id', 'x'] +['END', 'end', '-1'] +['SEMICOLON', ';', '-1'] +['BEGIN', 'begin', '-1'] +['IDENTIFIER', 'id', 'x'] +['ASSIGN', ':=', '-1'] +['NUMBER', 'num', '1'] +['SEMICOLON', ';', '-1'] +['WHILE', 'while', '-1'] +['IDENTIFIER', 'id', 'x'] +['LESS_OR_EQUAL', '<=', '-1'] +['NUMBER', 'num', '100'] +['DO', 'do', '-1'] +['BEGIN', 'begin', '-1'] +['CALL', 'call', '-1'] +['IDENTIFIER', 'id', 'square'] +['SEMICOLON', ';', '-1'] +['WRITE', 'write', '-1'] +['LEFT_PARENTHESES', '(', '-1'] +['IDENTIFIER', 'id', 'squ'] +['RIGHT_PARENTHESES', ')', '-1'] +['SEMICOLON', ';', '-1'] +['IDENTIFIER', 'id', 'x'] +['ASSIGN', ':=', '-1'] +['NUMBER', 'num', '2'] +['TIMES', '*', '-1'] +['IDENTIFIER', 'id', 'x'] +['PLUS', '+', '-1'] +['NUMBER', 'num', '1'] +['END', 'end', '-1'] +['END', 'end', '-1'] +['DOT', '.', '-1'] diff --git a/Lexer/LexerOutput/PL0_code3.out b/Lexer/LexerOutput/PL0_code3.out index 18c0775..206f4df 100644 --- a/Lexer/LexerOutput/PL0_code3.out +++ b/Lexer/LexerOutput/PL0_code3.out @@ -1,106 +1,106 @@ -['CONST', 'const', '-1'] -['IDENTIFIER', 'id', 'max'] -['EQUAL', '=', '-1'] -['NUMBER', 'num', '100'] -['SEMICOLON', ';', '-1'] -['VAR', 'var', '-1'] -['IDENTIFIER', 'id', 'arg'] -['COMMA', ',', '-1'] -['IDENTIFIER', 'id', 'ret'] -['SEMICOLON', ';', '-1'] -['PROCEDURE', 'procedure', '-1'] -['IDENTIFIER', 'id', 'isprime'] -['SEMICOLON', ';', '-1'] -['VAR', 'var', '-1'] -['IDENTIFIER', 'id', 'i'] -['COMMA', ',', '-1'] -['IDENTIFIER', 'id', 'j'] -['SEMICOLON', ';', '-1'] -['BEGIN', 'begin', '-1'] -['IDENTIFIER', 'id', 'ret'] -['ASSIGN', ':=', '-1'] -['NUMBER', 'num', '1'] -['SEMICOLON', ';', '-1'] -['IDENTIFIER', 'id', 'i'] -['ASSIGN', ':=', '-1'] -['NUMBER', 'num', '2'] -['SEMICOLON', ';', '-1'] -['WHILE', 'while', '-1'] -['IDENTIFIER', 'id', 'i'] -['LESS', '<', '-1'] -['IDENTIFIER', 'id', 'arg'] -['DO', 'do', '-1'] -['BEGIN', 'begin', '-1'] -['IF', 'if', '-1'] -['IDENTIFIER', 'id', 'arg'] -['DIVIDE', '/', '-1'] -['IDENTIFIER', 'id', 'i'] -['TIMES', '*', '-1'] -['IDENTIFIER', 'id', 'i'] -['EQUAL', '=', '-1'] -['IDENTIFIER', 'id', 'arg'] -['THEN', 'then', '-1'] -['BEGIN', 'begin', '-1'] -['IDENTIFIER', 'id', 'ret'] -['ASSIGN', ':=', '-1'] -['NUMBER', 'num', '0'] -['SEMICOLON', ';', '-1'] -['IDENTIFIER', 'id', 'i'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'arg'] -['END', 'end', '-1'] -['SEMICOLON', ';', '-1'] -['IDENTIFIER', 'id', 'i'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'i'] -['PLUS', '+', '-1'] -['NUMBER', 'num', '1'] -['SEMICOLON', ';', '-1'] -['IDENTIFIER', 'id', 'j'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'i'] -['PLUS', '+', '-1'] -['IDENTIFIER', 'id', 'j'] -['PLUS', '+', '-1'] -['NUMBER', 'num', '2'] -['END', 'end', '-1'] -['END', 'end', '-1'] -['SEMICOLON', ';', '-1'] -['PROCEDURE', 'procedure', '-1'] -['IDENTIFIER', 'id', 'primes'] -['SEMICOLON', ';', '-1'] -['BEGIN', 'begin', '-1'] -['IDENTIFIER', 'id', 'arg'] -['ASSIGN', ':=', '-1'] -['NUMBER', 'num', '2'] -['SEMICOLON', ';', '-1'] -['WHILE', 'while', '-1'] -['IDENTIFIER', 'id', 'arg'] -['LESS_OR_EQUAL', '<=', '-1'] -['IDENTIFIER', 'id', 'max'] -['DO', 'do', '-1'] -['BEGIN', 'begin', '-1'] -['CALL', 'call', '-1'] -['IDENTIFIER', 'id', 'isprime'] -['SEMICOLON', ';', '-1'] -['IF', 'if', '-1'] -['IDENTIFIER', 'id', 'ret'] -['EQUAL', '=', '-1'] -['NUMBER', 'num', '1'] -['THEN', 'then', '-1'] -['WRITE', 'write', '-1'] -['LEFT_PARENTHESES', '(', '-1'] -['IDENTIFIER', 'id', 'arg'] -['RIGHT_PARENTHESES', ')', '-1'] -['SEMICOLON', ';', '-1'] -['IDENTIFIER', 'id', 'arg'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'arg'] -['PLUS', '+', '-1'] -['NUMBER', 'num', '1'] -['END', 'end', '-1'] -['END', 'end', '-1'] -['SEMICOLON', ';', '-1'] -['CALL', 'call', '-1'] -['IDENTIFIER', 'id', 'primes'] -['DOT', '.', '-1'] +['CONST', 'const', '-1'] +['IDENTIFIER', 'id', 'max'] +['EQUAL', '=', '-1'] +['NUMBER', 'num', '100'] +['SEMICOLON', ';', '-1'] +['VAR', 'var', '-1'] +['IDENTIFIER', 'id', 'arg'] +['COMMA', ',', '-1'] +['IDENTIFIER', 'id', 'ret'] +['SEMICOLON', ';', '-1'] +['PROCEDURE', 'procedure', '-1'] +['IDENTIFIER', 'id', 'isprime'] +['SEMICOLON', ';', '-1'] +['VAR', 'var', '-1'] +['IDENTIFIER', 'id', 'i'] +['COMMA', ',', '-1'] +['IDENTIFIER', 'id', 'j'] +['SEMICOLON', ';', '-1'] +['BEGIN', 'begin', '-1'] +['IDENTIFIER', 'id', 'ret'] +['ASSIGN', ':=', '-1'] +['NUMBER', 'num', '1'] +['SEMICOLON', ';', '-1'] +['IDENTIFIER', 'id', 'i'] +['ASSIGN', ':=', '-1'] +['NUMBER', 'num', '2'] +['SEMICOLON', ';', '-1'] +['WHILE', 'while', '-1'] +['IDENTIFIER', 'id', 'i'] +['LESS', '<', '-1'] +['IDENTIFIER', 'id', 'arg'] +['DO', 'do', '-1'] +['BEGIN', 'begin', '-1'] +['IF', 'if', '-1'] +['IDENTIFIER', 'id', 'arg'] +['DIVIDE', '/', '-1'] +['IDENTIFIER', 'id', 'i'] +['TIMES', '*', '-1'] +['IDENTIFIER', 'id', 'i'] +['EQUAL', '=', '-1'] +['IDENTIFIER', 'id', 'arg'] +['THEN', 'then', '-1'] +['BEGIN', 'begin', '-1'] +['IDENTIFIER', 'id', 'ret'] +['ASSIGN', ':=', '-1'] +['NUMBER', 'num', '0'] +['SEMICOLON', ';', '-1'] +['IDENTIFIER', 'id', 'i'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'arg'] +['END', 'end', '-1'] +['SEMICOLON', ';', '-1'] +['IDENTIFIER', 'id', 'i'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'i'] +['PLUS', '+', '-1'] +['NUMBER', 'num', '1'] +['SEMICOLON', ';', '-1'] +['IDENTIFIER', 'id', 'j'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'i'] +['PLUS', '+', '-1'] +['IDENTIFIER', 'id', 'j'] +['PLUS', '+', '-1'] +['NUMBER', 'num', '2'] +['END', 'end', '-1'] +['END', 'end', '-1'] +['SEMICOLON', ';', '-1'] +['PROCEDURE', 'procedure', '-1'] +['IDENTIFIER', 'id', 'primes'] +['SEMICOLON', ';', '-1'] +['BEGIN', 'begin', '-1'] +['IDENTIFIER', 'id', 'arg'] +['ASSIGN', ':=', '-1'] +['NUMBER', 'num', '2'] +['SEMICOLON', ';', '-1'] +['WHILE', 'while', '-1'] +['IDENTIFIER', 'id', 'arg'] +['LESS_OR_EQUAL', '<=', '-1'] +['IDENTIFIER', 'id', 'max'] +['DO', 'do', '-1'] +['BEGIN', 'begin', '-1'] +['CALL', 'call', '-1'] +['IDENTIFIER', 'id', 'isprime'] +['SEMICOLON', ';', '-1'] +['IF', 'if', '-1'] +['IDENTIFIER', 'id', 'ret'] +['EQUAL', '=', '-1'] +['NUMBER', 'num', '1'] +['THEN', 'then', '-1'] +['WRITE', 'write', '-1'] +['LEFT_PARENTHESES', '(', '-1'] +['IDENTIFIER', 'id', 'arg'] +['RIGHT_PARENTHESES', ')', '-1'] +['SEMICOLON', ';', '-1'] +['IDENTIFIER', 'id', 'arg'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'arg'] +['PLUS', '+', '-1'] +['NUMBER', 'num', '1'] +['END', 'end', '-1'] +['END', 'end', '-1'] +['SEMICOLON', ';', '-1'] +['CALL', 'call', '-1'] +['IDENTIFIER', 'id', 'primes'] +['DOT', '.', '-1'] diff --git a/Lexer/LexerOutput/PL0_code4.out b/Lexer/LexerOutput/PL0_code4.out index 6cb55ec..9c181b9 100644 --- a/Lexer/LexerOutput/PL0_code4.out +++ b/Lexer/LexerOutput/PL0_code4.out @@ -1,262 +1,262 @@ -['VAR', 'var', '-1'] -['IDENTIFIER', 'id', 'x'] -['COMMA', ',', '-1'] -['IDENTIFIER', 'id', 'y'] -['COMMA', ',', '-1'] -['IDENTIFIER', 'id', 'z'] -['COMMA', ',', '-1'] -['IDENTIFIER', 'id', 'q'] -['COMMA', ',', '-1'] -['IDENTIFIER', 'id', 'r'] -['COMMA', ',', '-1'] -['IDENTIFIER', 'id', 'n'] -['COMMA', ',', '-1'] -['IDENTIFIER', 'id', 'f'] -['SEMICOLON', ';', '-1'] -['PROCEDURE', 'procedure', '-1'] -['IDENTIFIER', 'id', 'multiply'] -['SEMICOLON', ';', '-1'] -['VAR', 'var', '-1'] -['IDENTIFIER', 'id', 'a'] -['COMMA', ',', '-1'] -['IDENTIFIER', 'id', 'b'] -['SEMICOLON', ';', '-1'] -['BEGIN', 'begin', '-1'] -['IDENTIFIER', 'id', 'a'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'x'] -['SEMICOLON', ';', '-1'] -['IDENTIFIER', 'id', 'b'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'y'] -['SEMICOLON', ';', '-1'] -['IDENTIFIER', 'id', 'z'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'x'] -['TIMES', '*', '-1'] -['IDENTIFIER', 'id', 'y'] -['END', 'end', '-1'] -['SEMICOLON', ';', '-1'] -['PROCEDURE', 'procedure', '-1'] -['IDENTIFIER', 'id', 'divide'] -['SEMICOLON', ';', '-1'] -['VAR', 'var', '-1'] -['IDENTIFIER', 'id', 'w'] -['SEMICOLON', ';', '-1'] -['BEGIN', 'begin', '-1'] -['IDENTIFIER', 'id', 'r'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'x'] -['SEMICOLON', ';', '-1'] -['IDENTIFIER', 'id', 'q'] -['ASSIGN', ':=', '-1'] -['NUMBER', 'num', '0'] -['SEMICOLON', ';', '-1'] -['IDENTIFIER', 'id', 'w'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'y'] -['SEMICOLON', ';', '-1'] -['WHILE', 'while', '-1'] -['IDENTIFIER', 'id', 'w'] -['LESS_OR_EQUAL', '<=', '-1'] -['IDENTIFIER', 'id', 'r'] -['DO', 'do', '-1'] -['IDENTIFIER', 'id', 'w'] -['ASSIGN', ':=', '-1'] -['NUMBER', 'num', '2'] -['TIMES', '*', '-1'] -['IDENTIFIER', 'id', 'w'] -['SEMICOLON', ';', '-1'] -['WHILE', 'while', '-1'] -['IDENTIFIER', 'id', 'w'] -['GREATER', '>', '-1'] -['IDENTIFIER', 'id', 'y'] -['DO', 'do', '-1'] -['BEGIN', 'begin', '-1'] -['IDENTIFIER', 'id', 'q'] -['ASSIGN', ':=', '-1'] -['NUMBER', 'num', '2'] -['TIMES', '*', '-1'] -['IDENTIFIER', 'id', 'q'] -['SEMICOLON', ';', '-1'] -['IDENTIFIER', 'id', 'w'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'w'] -['DIVIDE', '/', '-1'] -['NUMBER', 'num', '2'] -['SEMICOLON', ';', '-1'] -['IF', 'if', '-1'] -['IDENTIFIER', 'id', 'w'] -['LESS_OR_EQUAL', '<=', '-1'] -['IDENTIFIER', 'id', 'r'] -['THEN', 'then', '-1'] -['BEGIN', 'begin', '-1'] -['IDENTIFIER', 'id', 'r'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'r'] -['MINUS', '-', '-1'] -['IDENTIFIER', 'id', 'w'] -['SEMICOLON', ';', '-1'] -['IDENTIFIER', 'id', 'q'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'q'] -['PLUS', '+', '-1'] -['NUMBER', 'num', '1'] -['END', 'end', '-1'] -['END', 'end', '-1'] -['END', 'end', '-1'] -['SEMICOLON', ';', '-1'] -['PROCEDURE', 'procedure', '-1'] -['IDENTIFIER', 'id', 'gcd'] -['SEMICOLON', ';', '-1'] -['VAR', 'var', '-1'] -['IDENTIFIER', 'id', 'g'] -['SEMICOLON', ';', '-1'] -['BEGIN', 'begin', '-1'] -['IDENTIFIER', 'id', 'f'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'x'] -['SEMICOLON', ';', '-1'] -['IDENTIFIER', 'id', 'g'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'y'] -['SEMICOLON', ';', '-1'] -['WHILE', 'while', '-1'] -['IDENTIFIER', 'id', 'f'] -['NEQUAL', '#', '-1'] -['IDENTIFIER', 'id', 'g'] -['DO', 'do', '-1'] -['BEGIN', 'begin', '-1'] -['IF', 'if', '-1'] -['IDENTIFIER', 'id', 'f'] -['LESS', '<', '-1'] -['IDENTIFIER', 'id', 'g'] -['THEN', 'then', '-1'] -['IDENTIFIER', 'id', 'g'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'g'] -['MINUS', '-', '-1'] -['IDENTIFIER', 'id', 'f'] -['SEMICOLON', ';', '-1'] -['IF', 'if', '-1'] -['IDENTIFIER', 'id', 'g'] -['LESS', '<', '-1'] -['IDENTIFIER', 'id', 'f'] -['THEN', 'then', '-1'] -['IDENTIFIER', 'id', 'f'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'f'] -['MINUS', '-', '-1'] -['IDENTIFIER', 'id', 'g'] -['END', 'end', '-1'] -['SEMICOLON', ';', '-1'] -['IDENTIFIER', 'id', 'z'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'f'] -['END', 'end', '-1'] -['SEMICOLON', ';', '-1'] -['PROCEDURE', 'procedure', '-1'] -['IDENTIFIER', 'id', 'fact'] -['SEMICOLON', ';', '-1'] -['BEGIN', 'begin', '-1'] -['IF', 'if', '-1'] -['IDENTIFIER', 'id', 'n'] -['GREATER', '>', '-1'] -['NUMBER', 'num', '1'] -['THEN', 'then', '-1'] -['BEGIN', 'begin', '-1'] -['IDENTIFIER', 'id', 'f'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'n'] -['TIMES', '*', '-1'] -['IDENTIFIER', 'id', 'f'] -['SEMICOLON', ';', '-1'] -['IDENTIFIER', 'id', 'n'] -['ASSIGN', ':=', '-1'] -['IDENTIFIER', 'id', 'n'] -['MINUS', '-', '-1'] -['NUMBER', 'num', '1'] -['SEMICOLON', ';', '-1'] -['CALL', 'call', '-1'] -['IDENTIFIER', 'id', 'fact'] -['END', 'end', '-1'] -['END', 'end', '-1'] -['SEMICOLON', ';', '-1'] -['BEGIN', 'begin', '-1'] -['READ', 'read', '-1'] -['LEFT_PARENTHESES', '(', '-1'] -['IDENTIFIER', 'id', 'x'] -['RIGHT_PARENTHESES', ')', '-1'] -['SEMICOLON', ';', '-1'] -['READ', 'read', '-1'] -['LEFT_PARENTHESES', '(', '-1'] -['IDENTIFIER', 'id', 'y'] -['RIGHT_PARENTHESES', ')', '-1'] -['SEMICOLON', ';', '-1'] -['CALL', 'call', '-1'] -['IDENTIFIER', 'id', 'multiply'] -['SEMICOLON', ';', '-1'] -['WRITE', 'write', '-1'] -['LEFT_PARENTHESES', '(', '-1'] -['IDENTIFIER', 'id', 'z'] -['RIGHT_PARENTHESES', ')', '-1'] -['SEMICOLON', ';', '-1'] -['READ', 'read', '-1'] -['LEFT_PARENTHESES', '(', '-1'] -['IDENTIFIER', 'id', 'x'] -['RIGHT_PARENTHESES', ')', '-1'] -['SEMICOLON', ';', '-1'] -['READ', 'read', '-1'] -['LEFT_PARENTHESES', '(', '-1'] -['IDENTIFIER', 'id', 'y'] -['RIGHT_PARENTHESES', ')', '-1'] -['SEMICOLON', ';', '-1'] -['CALL', 'call', '-1'] -['IDENTIFIER', 'id', 'divide'] -['SEMICOLON', ';', '-1'] -['WRITE', 'write', '-1'] -['LEFT_PARENTHESES', '(', '-1'] -['IDENTIFIER', 'id', 'q'] -['RIGHT_PARENTHESES', ')', '-1'] -['SEMICOLON', ';', '-1'] -['WRITE', 'write', '-1'] -['LEFT_PARENTHESES', '(', '-1'] -['IDENTIFIER', 'id', 'r'] -['RIGHT_PARENTHESES', ')', '-1'] -['SEMICOLON', ';', '-1'] -['READ', 'read', '-1'] -['LEFT_PARENTHESES', '(', '-1'] -['IDENTIFIER', 'id', 'x'] -['RIGHT_PARENTHESES', ')', '-1'] -['SEMICOLON', ';', '-1'] -['READ', 'read', '-1'] -['LEFT_PARENTHESES', '(', '-1'] -['IDENTIFIER', 'id', 'y'] -['RIGHT_PARENTHESES', ')', '-1'] -['SEMICOLON', ';', '-1'] -['CALL', 'call', '-1'] -['IDENTIFIER', 'id', 'gcd'] -['SEMICOLON', ';', '-1'] -['WRITE', 'write', '-1'] -['LEFT_PARENTHESES', '(', '-1'] -['IDENTIFIER', 'id', 'z'] -['RIGHT_PARENTHESES', ')', '-1'] -['SEMICOLON', ';', '-1'] -['READ', 'read', '-1'] -['LEFT_PARENTHESES', '(', '-1'] -['IDENTIFIER', 'id', 'n'] -['RIGHT_PARENTHESES', ')', '-1'] -['SEMICOLON', ';', '-1'] -['IDENTIFIER', 'id', 'f'] -['ASSIGN', ':=', '-1'] -['NUMBER', 'num', '1'] -['SEMICOLON', ';', '-1'] -['CALL', 'call', '-1'] -['IDENTIFIER', 'id', 'fact'] -['SEMICOLON', ';', '-1'] -['WRITE', 'write', '-1'] -['LEFT_PARENTHESES', '(', '-1'] -['IDENTIFIER', 'id', 'f'] -['RIGHT_PARENTHESES', ')', '-1'] -['END', 'end', '-1'] -['DOT', '.', '-1'] +['VAR', 'var', '-1'] +['IDENTIFIER', 'id', 'x'] +['COMMA', ',', '-1'] +['IDENTIFIER', 'id', 'y'] +['COMMA', ',', '-1'] +['IDENTIFIER', 'id', 'z'] +['COMMA', ',', '-1'] +['IDENTIFIER', 'id', 'q'] +['COMMA', ',', '-1'] +['IDENTIFIER', 'id', 'r'] +['COMMA', ',', '-1'] +['IDENTIFIER', 'id', 'n'] +['COMMA', ',', '-1'] +['IDENTIFIER', 'id', 'f'] +['SEMICOLON', ';', '-1'] +['PROCEDURE', 'procedure', '-1'] +['IDENTIFIER', 'id', 'multiply'] +['SEMICOLON', ';', '-1'] +['VAR', 'var', '-1'] +['IDENTIFIER', 'id', 'a'] +['COMMA', ',', '-1'] +['IDENTIFIER', 'id', 'b'] +['SEMICOLON', ';', '-1'] +['BEGIN', 'begin', '-1'] +['IDENTIFIER', 'id', 'a'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'x'] +['SEMICOLON', ';', '-1'] +['IDENTIFIER', 'id', 'b'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'y'] +['SEMICOLON', ';', '-1'] +['IDENTIFIER', 'id', 'z'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'x'] +['TIMES', '*', '-1'] +['IDENTIFIER', 'id', 'y'] +['END', 'end', '-1'] +['SEMICOLON', ';', '-1'] +['PROCEDURE', 'procedure', '-1'] +['IDENTIFIER', 'id', 'divide'] +['SEMICOLON', ';', '-1'] +['VAR', 'var', '-1'] +['IDENTIFIER', 'id', 'w'] +['SEMICOLON', ';', '-1'] +['BEGIN', 'begin', '-1'] +['IDENTIFIER', 'id', 'r'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'x'] +['SEMICOLON', ';', '-1'] +['IDENTIFIER', 'id', 'q'] +['ASSIGN', ':=', '-1'] +['NUMBER', 'num', '0'] +['SEMICOLON', ';', '-1'] +['IDENTIFIER', 'id', 'w'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'y'] +['SEMICOLON', ';', '-1'] +['WHILE', 'while', '-1'] +['IDENTIFIER', 'id', 'w'] +['LESS_OR_EQUAL', '<=', '-1'] +['IDENTIFIER', 'id', 'r'] +['DO', 'do', '-1'] +['IDENTIFIER', 'id', 'w'] +['ASSIGN', ':=', '-1'] +['NUMBER', 'num', '2'] +['TIMES', '*', '-1'] +['IDENTIFIER', 'id', 'w'] +['SEMICOLON', ';', '-1'] +['WHILE', 'while', '-1'] +['IDENTIFIER', 'id', 'w'] +['GREATER', '>', '-1'] +['IDENTIFIER', 'id', 'y'] +['DO', 'do', '-1'] +['BEGIN', 'begin', '-1'] +['IDENTIFIER', 'id', 'q'] +['ASSIGN', ':=', '-1'] +['NUMBER', 'num', '2'] +['TIMES', '*', '-1'] +['IDENTIFIER', 'id', 'q'] +['SEMICOLON', ';', '-1'] +['IDENTIFIER', 'id', 'w'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'w'] +['DIVIDE', '/', '-1'] +['NUMBER', 'num', '2'] +['SEMICOLON', ';', '-1'] +['IF', 'if', '-1'] +['IDENTIFIER', 'id', 'w'] +['LESS_OR_EQUAL', '<=', '-1'] +['IDENTIFIER', 'id', 'r'] +['THEN', 'then', '-1'] +['BEGIN', 'begin', '-1'] +['IDENTIFIER', 'id', 'r'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'r'] +['MINUS', '-', '-1'] +['IDENTIFIER', 'id', 'w'] +['SEMICOLON', ';', '-1'] +['IDENTIFIER', 'id', 'q'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'q'] +['PLUS', '+', '-1'] +['NUMBER', 'num', '1'] +['END', 'end', '-1'] +['END', 'end', '-1'] +['END', 'end', '-1'] +['SEMICOLON', ';', '-1'] +['PROCEDURE', 'procedure', '-1'] +['IDENTIFIER', 'id', 'gcd'] +['SEMICOLON', ';', '-1'] +['VAR', 'var', '-1'] +['IDENTIFIER', 'id', 'g'] +['SEMICOLON', ';', '-1'] +['BEGIN', 'begin', '-1'] +['IDENTIFIER', 'id', 'f'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'x'] +['SEMICOLON', ';', '-1'] +['IDENTIFIER', 'id', 'g'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'y'] +['SEMICOLON', ';', '-1'] +['WHILE', 'while', '-1'] +['IDENTIFIER', 'id', 'f'] +['NEQUAL', '#', '-1'] +['IDENTIFIER', 'id', 'g'] +['DO', 'do', '-1'] +['BEGIN', 'begin', '-1'] +['IF', 'if', '-1'] +['IDENTIFIER', 'id', 'f'] +['LESS', '<', '-1'] +['IDENTIFIER', 'id', 'g'] +['THEN', 'then', '-1'] +['IDENTIFIER', 'id', 'g'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'g'] +['MINUS', '-', '-1'] +['IDENTIFIER', 'id', 'f'] +['SEMICOLON', ';', '-1'] +['IF', 'if', '-1'] +['IDENTIFIER', 'id', 'g'] +['LESS', '<', '-1'] +['IDENTIFIER', 'id', 'f'] +['THEN', 'then', '-1'] +['IDENTIFIER', 'id', 'f'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'f'] +['MINUS', '-', '-1'] +['IDENTIFIER', 'id', 'g'] +['END', 'end', '-1'] +['SEMICOLON', ';', '-1'] +['IDENTIFIER', 'id', 'z'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'f'] +['END', 'end', '-1'] +['SEMICOLON', ';', '-1'] +['PROCEDURE', 'procedure', '-1'] +['IDENTIFIER', 'id', 'fact'] +['SEMICOLON', ';', '-1'] +['BEGIN', 'begin', '-1'] +['IF', 'if', '-1'] +['IDENTIFIER', 'id', 'n'] +['GREATER', '>', '-1'] +['NUMBER', 'num', '1'] +['THEN', 'then', '-1'] +['BEGIN', 'begin', '-1'] +['IDENTIFIER', 'id', 'f'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'n'] +['TIMES', '*', '-1'] +['IDENTIFIER', 'id', 'f'] +['SEMICOLON', ';', '-1'] +['IDENTIFIER', 'id', 'n'] +['ASSIGN', ':=', '-1'] +['IDENTIFIER', 'id', 'n'] +['MINUS', '-', '-1'] +['NUMBER', 'num', '1'] +['SEMICOLON', ';', '-1'] +['CALL', 'call', '-1'] +['IDENTIFIER', 'id', 'fact'] +['END', 'end', '-1'] +['END', 'end', '-1'] +['SEMICOLON', ';', '-1'] +['BEGIN', 'begin', '-1'] +['READ', 'read', '-1'] +['LEFT_PARENTHESES', '(', '-1'] +['IDENTIFIER', 'id', 'x'] +['RIGHT_PARENTHESES', ')', '-1'] +['SEMICOLON', ';', '-1'] +['READ', 'read', '-1'] +['LEFT_PARENTHESES', '(', '-1'] +['IDENTIFIER', 'id', 'y'] +['RIGHT_PARENTHESES', ')', '-1'] +['SEMICOLON', ';', '-1'] +['CALL', 'call', '-1'] +['IDENTIFIER', 'id', 'multiply'] +['SEMICOLON', ';', '-1'] +['WRITE', 'write', '-1'] +['LEFT_PARENTHESES', '(', '-1'] +['IDENTIFIER', 'id', 'z'] +['RIGHT_PARENTHESES', ')', '-1'] +['SEMICOLON', ';', '-1'] +['READ', 'read', '-1'] +['LEFT_PARENTHESES', '(', '-1'] +['IDENTIFIER', 'id', 'x'] +['RIGHT_PARENTHESES', ')', '-1'] +['SEMICOLON', ';', '-1'] +['READ', 'read', '-1'] +['LEFT_PARENTHESES', '(', '-1'] +['IDENTIFIER', 'id', 'y'] +['RIGHT_PARENTHESES', ')', '-1'] +['SEMICOLON', ';', '-1'] +['CALL', 'call', '-1'] +['IDENTIFIER', 'id', 'divide'] +['SEMICOLON', ';', '-1'] +['WRITE', 'write', '-1'] +['LEFT_PARENTHESES', '(', '-1'] +['IDENTIFIER', 'id', 'q'] +['RIGHT_PARENTHESES', ')', '-1'] +['SEMICOLON', ';', '-1'] +['WRITE', 'write', '-1'] +['LEFT_PARENTHESES', '(', '-1'] +['IDENTIFIER', 'id', 'r'] +['RIGHT_PARENTHESES', ')', '-1'] +['SEMICOLON', ';', '-1'] +['READ', 'read', '-1'] +['LEFT_PARENTHESES', '(', '-1'] +['IDENTIFIER', 'id', 'x'] +['RIGHT_PARENTHESES', ')', '-1'] +['SEMICOLON', ';', '-1'] +['READ', 'read', '-1'] +['LEFT_PARENTHESES', '(', '-1'] +['IDENTIFIER', 'id', 'y'] +['RIGHT_PARENTHESES', ')', '-1'] +['SEMICOLON', ';', '-1'] +['CALL', 'call', '-1'] +['IDENTIFIER', 'id', 'gcd'] +['SEMICOLON', ';', '-1'] +['WRITE', 'write', '-1'] +['LEFT_PARENTHESES', '(', '-1'] +['IDENTIFIER', 'id', 'z'] +['RIGHT_PARENTHESES', ')', '-1'] +['SEMICOLON', ';', '-1'] +['READ', 'read', '-1'] +['LEFT_PARENTHESES', '(', '-1'] +['IDENTIFIER', 'id', 'n'] +['RIGHT_PARENTHESES', ')', '-1'] +['SEMICOLON', ';', '-1'] +['IDENTIFIER', 'id', 'f'] +['ASSIGN', ':=', '-1'] +['NUMBER', 'num', '1'] +['SEMICOLON', ';', '-1'] +['CALL', 'call', '-1'] +['IDENTIFIER', 'id', 'fact'] +['SEMICOLON', ';', '-1'] +['WRITE', 'write', '-1'] +['LEFT_PARENTHESES', '(', '-1'] +['IDENTIFIER', 'id', 'f'] +['RIGHT_PARENTHESES', ')', '-1'] +['END', 'end', '-1'] +['DOT', '.', '-1'] diff --git a/Lexer/__pycache__/GenToken.cpython-310.pyc b/Lexer/__pycache__/GenToken.cpython-310.pyc new file mode 100644 index 0000000..ab419d1 Binary files /dev/null and b/Lexer/__pycache__/GenToken.cpython-310.pyc differ diff --git a/Lexer/__pycache__/GenToken.cpython-39.pyc b/Lexer/__pycache__/GenToken.cpython-39.pyc new file mode 100644 index 0000000..c71afaa Binary files /dev/null and b/Lexer/__pycache__/GenToken.cpython-39.pyc differ diff --git a/Lexer/__pycache__/__init__.cpython-310.pyc b/Lexer/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..343a68d Binary files /dev/null and b/Lexer/__pycache__/__init__.cpython-310.pyc differ diff --git a/Lexer/__pycache__/__init__.cpython-39.pyc b/Lexer/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..bcce87a Binary files /dev/null and b/Lexer/__pycache__/__init__.cpython-39.pyc differ diff --git a/Lexer/__pycache__/main.cpython-310.pyc b/Lexer/__pycache__/main.cpython-310.pyc new file mode 100644 index 0000000..e96da91 Binary files /dev/null and b/Lexer/__pycache__/main.cpython-310.pyc differ diff --git a/Lexer/__pycache__/main.cpython-39.pyc b/Lexer/__pycache__/main.cpython-39.pyc new file mode 100644 index 0000000..9a9164d Binary files /dev/null and b/Lexer/__pycache__/main.cpython-39.pyc differ diff --git a/Lexer/main.py b/Lexer/main.py index d1b24a5..f6b4d3b 100644 --- a/Lexer/main.py +++ b/Lexer/main.py @@ -5,8 +5,10 @@ def main(): for file in os.listdir(lexer_input_dir): - with open(lexer_input_dir + "./" + file, "r") as input_file: - output_file = lexer_output_dir + "./" + file.split(".")[0] + ".out" + # with open(lexer_input_dir + "./" + file, "r") as input_file: + with open(os.path.join(lexer_input_dir, file), "r") as input_file: + # output_file = lexer_output_dir + "./" + file.split(".")[0] + ".out" + output_file = os.path.join(lexer_output_dir, file.split(".")[0] + ".out") if os.path.exists(output_file): os.remove(output_file) line = input_file.readline() diff --git a/Parser/LR1Analysis/__pycache__/LR1Parser.cpython-310.pyc b/Parser/LR1Analysis/__pycache__/LR1Parser.cpython-310.pyc new file mode 100644 index 0000000..68aeb45 Binary files /dev/null and b/Parser/LR1Analysis/__pycache__/LR1Parser.cpython-310.pyc differ diff --git a/Parser/LR1Analysis/__pycache__/LR1Parser.cpython-39.pyc b/Parser/LR1Analysis/__pycache__/LR1Parser.cpython-39.pyc new file mode 100644 index 0000000..d3c61e0 Binary files /dev/null and b/Parser/LR1Analysis/__pycache__/LR1Parser.cpython-39.pyc differ diff --git a/Parser/LR1Analysis/__pycache__/Procedure.cpython-310.pyc b/Parser/LR1Analysis/__pycache__/Procedure.cpython-310.pyc new file mode 100644 index 0000000..33285c1 Binary files /dev/null and b/Parser/LR1Analysis/__pycache__/Procedure.cpython-310.pyc differ diff --git a/Parser/LR1Analysis/__pycache__/Procedure.cpython-39.pyc b/Parser/LR1Analysis/__pycache__/Procedure.cpython-39.pyc new file mode 100644 index 0000000..96c03ba Binary files /dev/null and b/Parser/LR1Analysis/__pycache__/Procedure.cpython-39.pyc differ diff --git a/Parser/LR1Analysis/__pycache__/__init__.cpython-310.pyc b/Parser/LR1Analysis/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..fc2d60f Binary files /dev/null and b/Parser/LR1Analysis/__pycache__/__init__.cpython-310.pyc differ diff --git a/Parser/LR1Analysis/__pycache__/__init__.cpython-39.pyc b/Parser/LR1Analysis/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..d89102d Binary files /dev/null and b/Parser/LR1Analysis/__pycache__/__init__.cpython-39.pyc differ diff --git a/Parser/LR1Analysis/__pycache__/main.cpython-310.pyc b/Parser/LR1Analysis/__pycache__/main.cpython-310.pyc new file mode 100644 index 0000000..1e4ead9 Binary files /dev/null and b/Parser/LR1Analysis/__pycache__/main.cpython-310.pyc differ diff --git a/Parser/LR1Analysis/__pycache__/main.cpython-39.pyc b/Parser/LR1Analysis/__pycache__/main.cpython-39.pyc new file mode 100644 index 0000000..74b1fe4 Binary files /dev/null and b/Parser/LR1Analysis/__pycache__/main.cpython-39.pyc differ diff --git a/Parser/LR1Table/GenTable.py b/Parser/LR1Table/GenTable.py index 1a7f4ee..dbceed4 100644 --- a/Parser/LR1Table/GenTable.py +++ b/Parser/LR1Table/GenTable.py @@ -1,7 +1,8 @@ from .Grammar import Grammar from .LR1Table import LR1Table -from PyQt5.QtWidgets import * import sys +import wx +import wx.grid as gridlib from .LR1TableUI import LR1TableUI @@ -13,9 +14,7 @@ def GenLR1Table(grammar_file): lr1_table_ = lr1_parser.parse_table return action_, goto_, lr1_table_ - def GenTableUI(action_, goto_, lr1_table_): - app = QApplication(sys.argv) - w = LR1TableUI(action_, goto_, lr1_table_) - w.show() - app.exec_() + app = wx.App(False) + w = LR1TableUI(None, action_, goto_, lr1_table_) + app.MainLoop() diff --git a/Parser/LR1Table/LR1Table.py b/Parser/LR1Table/LR1Table.py index c27be9d..5e8cb1a 100644 --- a/Parser/LR1Table/LR1Table.py +++ b/Parser/LR1Table/LR1Table.py @@ -1,5 +1,7 @@ from .Grammar import Grammar +end_sign = '#' +dot_sign = '•' def first_follow(G): def union(set_1, set_2): @@ -9,7 +11,7 @@ def union(set_1, set_2): first = {symbol: set() for symbol in G.symbols} first.update((terminal, {terminal}) for terminal in G.terminals) # first terminal 加入 follow = {symbol: set() for symbol in G.nonterminals} - follow[G.start].add('.') + follow[G.start].add(end_sign) while True: updated = False for head, bodies in G.grammar.items(): @@ -57,10 +59,12 @@ def __init__(self, G): self.Collection = self.LR1_items(self.G_prime) # 构建LR1分析表 - self.action = sorted(list(self.G_prime.terminals)) + ['.'] + self.action = sorted(list(self.G_prime.terminals)) + [end_sign] self.goto = sorted(list(self.G_prime.nonterminals - {self.G_prime.start})) self.parse_table_symbols = self.action + self.goto self.parse_table = self.LR1_construct_table() + + self.print_info() def construct_follow(self, s: tuple, extra: str) -> set: ret = set() @@ -81,22 +85,22 @@ def LR1_CLOSURE(self, dict_of_trans: dict) -> dict: item_len = len(ret) for head, bodies in dict_of_trans.copy().items(): for body in bodies.copy(): - if '.' in body[:-1]: - symbol_after_dot = body[body.index('.') + 1] + if dot_sign in body[:-1]: + symbol_after_dot = body[body.index(dot_sign) + 1] if symbol_after_dot in self.G_prime.nonterminals: - symbol_need_first_loc = body.index('.') + 2 + symbol_need_first_loc = body.index(dot_sign) + 2 if symbol_need_first_loc == len(body): # A -> ... .B for G_body in self.G_prime.grammar[symbol_after_dot]: ret.setdefault((symbol_after_dot, head[1]), set()).add( - ('.',) if G_body == ('^',) else ('.',) + G_body + (dot_sign,) if G_body == ('^',) else (dot_sign,) + G_body ) else: # A -> ... .BC for j in self.construct_follow(body[symbol_need_first_loc:], head[1]): for G_body in self.G_prime.grammar[symbol_after_dot]: ret.setdefault((symbol_after_dot, j), set()).add( - ('.',) if G_body == ('^',) else ('.',) + G_body + (dot_sign,) if G_body == ('^',) else (dot_sign,) + G_body ) if item_len == len(ret): break @@ -107,18 +111,17 @@ def LR1_GOTO(self, state: dict, c: str) -> dict: for head, bodies in state.items(): for body in bodies: - if '.' in body[:-1]: - dot_pos = body.index('.') + if dot_sign in body[:-1]: + dot_pos = body.index(dot_sign) if body[dot_pos + 1] == c: - replaced_dot_body = body[:dot_pos] + (c, '.') + body[dot_pos + 2:] + replaced_dot_body = body[:dot_pos] + (c, dot_sign) + body[dot_pos + 2:] for C_head, C_bodies in self.LR1_CLOSURE({head: {replaced_dot_body}}).items(): goto.setdefault(C_head, set()).update(C_bodies) return goto def LR1_items(self, G_prime): - # start_item == {("S'", '#'): {('.', 'S')}} - start_item = {(G_prime.start, '.'): {('.', G_prime.start[:-1])}} + start_item = {(G_prime.start, end_sign): {(dot_sign, G_prime.start[:-1])}} # 求 I0 的闭包 C = [self.LR1_CLOSURE(start_item)] while True: @@ -139,8 +142,8 @@ def LR1_construct_table(self): for i, I in enumerate(self.Collection): for head, bodies in I.items(): for body in bodies: - if '.' in body[:-1]: # CASE 2 a - symbol_after_dot = body[body.index('.') + 1] + if dot_sign in body[:-1]: # CASE 2 a + symbol_after_dot = body[body.index(dot_sign) + 1] if symbol_after_dot in self.G_prime.terminals: s = f's{self.Collection.index(self.LR1_GOTO(I, symbol_after_dot))}' @@ -150,9 +153,9 @@ def LR1_construct_table(self): parse_table[i][symbol_after_dot] += s - elif body[-1] == '.' and head[0] != self.G_prime.start: # CASE 2 b + elif body[-1] == dot_sign and head[0] != self.G_prime.start: # CASE 2 b for j, (G_head, G_body) in enumerate(self.G_indexed): - if G_head == head[0] and (G_body == body[:-1] or G_body == ('^',) and body == ('.',)): + if G_head == head[0] and (G_body == body[:-1] or G_body == ('^',) and body == (dot_sign,)): if parse_table[i][head[1]]: exit(-1) parse_table[i][head[1]] += '/' @@ -160,7 +163,7 @@ def LR1_construct_table(self): break else: # CASE 2 c - parse_table[i]['.'] = 'acc' + parse_table[i][end_sign] = 'acc' for A in self.G_prime.nonterminals: # CASE 3 j = self.LR1_GOTO(I, A) @@ -179,3 +182,16 @@ def print_info(self): print('TERMINALS', self.G_prime.terminals) print('NONTERMINALS', self.G_prime.nonterminals) print('SYMBOLS', self.G_prime.symbols) + print() + + for i, item in enumerate(self.Collection): + print("I" + str(i) + ":") + for key in item: + left_sign = key[0] + follow_sign = key[1] + candidates = item[key] + for candidate in candidates: + print(' ', left_sign, '-> ', end='') + for character in candidate: + print(character, end='') + print(',', follow_sign) diff --git a/Parser/LR1Table/LR1TableUI.py b/Parser/LR1Table/LR1TableUI.py index 58938cd..ed0363d 100644 --- a/Parser/LR1Table/LR1TableUI.py +++ b/Parser/LR1Table/LR1TableUI.py @@ -1,38 +1,42 @@ -from PyQt5.QtWidgets import * +import wx +import wx.grid as gridlib +class LR1TableUI(wx.Frame): + def __init__(self, parent, action, goto, table): + super(LR1TableUI, self).__init__(parent, title="LR1分析表", size=(860, 560)) -class LR1TableUI(QWidget): - def __init__(self, action, goto, table): - - super().__init__() - self.setWindowTitle("LR1分析表") - self.action = action - self.goto = goto - self.resize(860, 560) - self.action = sorted(self.action) - self.goto = sorted(self.goto) + self.action = sorted(action) + self.goto = sorted(goto) self.table = table - self.Table = QTableWidget(len(self.table) + 1, len(self.action) + len(self.goto) + 1) - self.Table.verticalHeader().setHidden(True) + + self.grid = gridlib.Grid(self) + self.grid.CreateGrid(len(self.table) + 1, len(self.action) + len(self.goto) + 1) + self.grid.SetRowLabelSize(0) # Hide row labels + self.initUI() + self.Centre() + self.Show() def initUI(self): - self.Table.setItem(0, 0, QTableWidgetItem('状态')) - for i in range(len(self.action) + len(self.action) - 1): + self.grid.SetCellValue(0, 0, '状态') + + for i in range(len(self.action) + len(self.goto) - 1): if i < len(self.action): - self.Table.setItem(0, i + 1, QTableWidgetItem(self.action[i])) + self.grid.SetCellValue(0, i + 1, self.action[i]) else: - self.Table.setItem(0, i + 1, QTableWidgetItem(self.goto[i - len(self.action)])) + self.grid.SetCellValue(0, i + 1, self.goto[i - len(self.action)]) + for i in range(len(self.table)): - self.Table.setItem(i + 1, 0, QTableWidgetItem(str(i))) + self.grid.SetCellValue(i + 1, 0, str(i)) for item in self.action: if self.table[i][item] != ' ': - self.Table.setItem(i + 1, self.action.index(item) + 1, QTableWidgetItem(self.table[i][item])) + self.grid.SetCellValue(i + 1, self.action.index(item) + 1, self.table[i][item]) for item in self.goto: if self.table[i][item]: - self.Table.setItem(i + 1, self.goto.index(item) + 1 + len(self.action), QTableWidgetItem(str(self.table[i][item]))) - self.Table.setItem(9, 0, QTableWidgetItem(str(9))) - mainlayout = QVBoxLayout() - mainlayout.addWidget(self.Table) - self.setLayout(mainlayout) - self.show() + self.grid.SetCellValue(i + 1, self.goto.index(item) + 1 + len(self.action), str(self.table[i][item])) + + self.grid.SetCellValue(9, 0, str(9)) + + sizer = wx.BoxSizer(wx.VERTICAL) + sizer.Add(self.grid, 1, wx.EXPAND) + self.SetSizer(sizer) diff --git a/Parser/LR1Table/__pycache__/GenTable.cpython-310.pyc b/Parser/LR1Table/__pycache__/GenTable.cpython-310.pyc new file mode 100644 index 0000000..585a066 Binary files /dev/null and b/Parser/LR1Table/__pycache__/GenTable.cpython-310.pyc differ diff --git a/Parser/LR1Table/__pycache__/GenTable.cpython-39.pyc b/Parser/LR1Table/__pycache__/GenTable.cpython-39.pyc new file mode 100644 index 0000000..cf8a6ea Binary files /dev/null and b/Parser/LR1Table/__pycache__/GenTable.cpython-39.pyc differ diff --git a/Parser/LR1Table/__pycache__/Grammar.cpython-310.pyc b/Parser/LR1Table/__pycache__/Grammar.cpython-310.pyc new file mode 100644 index 0000000..21f469d Binary files /dev/null and b/Parser/LR1Table/__pycache__/Grammar.cpython-310.pyc differ diff --git a/Parser/LR1Table/__pycache__/Grammar.cpython-39.pyc b/Parser/LR1Table/__pycache__/Grammar.cpython-39.pyc new file mode 100644 index 0000000..f06637e Binary files /dev/null and b/Parser/LR1Table/__pycache__/Grammar.cpython-39.pyc differ diff --git a/Parser/LR1Table/__pycache__/LR1Table.cpython-310.pyc b/Parser/LR1Table/__pycache__/LR1Table.cpython-310.pyc new file mode 100644 index 0000000..b5f6b1f Binary files /dev/null and b/Parser/LR1Table/__pycache__/LR1Table.cpython-310.pyc differ diff --git a/Parser/LR1Table/__pycache__/LR1Table.cpython-39.pyc b/Parser/LR1Table/__pycache__/LR1Table.cpython-39.pyc new file mode 100644 index 0000000..a25edd7 Binary files /dev/null and b/Parser/LR1Table/__pycache__/LR1Table.cpython-39.pyc differ diff --git a/Parser/LR1Table/__pycache__/LR1TableUI.cpython-310.pyc b/Parser/LR1Table/__pycache__/LR1TableUI.cpython-310.pyc new file mode 100644 index 0000000..076ab97 Binary files /dev/null and b/Parser/LR1Table/__pycache__/LR1TableUI.cpython-310.pyc differ diff --git a/Parser/LR1Table/__pycache__/LR1TableUI.cpython-39.pyc b/Parser/LR1Table/__pycache__/LR1TableUI.cpython-39.pyc new file mode 100644 index 0000000..8a8a406 Binary files /dev/null and b/Parser/LR1Table/__pycache__/LR1TableUI.cpython-39.pyc differ diff --git a/Parser/LR1Table/__pycache__/__init__.cpython-310.pyc b/Parser/LR1Table/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..1deb15b Binary files /dev/null and b/Parser/LR1Table/__pycache__/__init__.cpython-310.pyc differ diff --git a/Parser/LR1Table/__pycache__/__init__.cpython-39.pyc b/Parser/LR1Table/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..f694338 Binary files /dev/null and b/Parser/LR1Table/__pycache__/__init__.cpython-39.pyc differ diff --git a/Parser/LR1Table/__pycache__/main.cpython-310.pyc b/Parser/LR1Table/__pycache__/main.cpython-310.pyc new file mode 100644 index 0000000..e8010a4 Binary files /dev/null and b/Parser/LR1Table/__pycache__/main.cpython-310.pyc differ diff --git a/Parser/LR1Table/__pycache__/main.cpython-39.pyc b/Parser/LR1Table/__pycache__/main.cpython-39.pyc new file mode 100644 index 0000000..e2aeb9b Binary files /dev/null and b/Parser/LR1Table/__pycache__/main.cpython-39.pyc differ diff --git a/Parser/LR1Table/grammars/mygrammar.txt b/Parser/LR1Table/grammars/mygrammar.txt new file mode 100644 index 0000000..e3b35d0 --- /dev/null +++ b/Parser/LR1Table/grammars/mygrammar.txt @@ -0,0 +1,5 @@ +S -> V = E +S -> id +V -> id +V -> id [ E ] +E -> V \ No newline at end of file diff --git "a/Parser/ParserOutput\\PL0_code0.out" "b/Parser/ParserOutput\\PL0_code0.out" new file mode 100644 index 0000000..b9ed079 --- /dev/null +++ "b/Parser/ParserOutput\\PL0_code0.out" @@ -0,0 +1,43 @@ +JMP 0 20 +INI 0 4 +LIT 0 10 +LIT 0 2 +OPR 0 4 +STO 1 3 +LIT 0 10 +LIT 0 3 +OPR 0 5 +STO 1 4 +LOD 1 3 +LOD 1 4 +OPR 0 13 +JPC 0 15 +JMP 0 19 +LOD 1 3 +LOD 1 4 +OPR 0 2 +STO 1 5 +OPR 0 0 +INI 0 6 +OPR 0 16 +STO 0 4 +OPR 0 16 +STO 0 5 +CALL 0 1 +LOD 0 3 +OPR 0 6 +JPC 0 30 +JMP 0 36 +LOD 0 4 +OPR 0 1 +LIT 0 1 +OPR 0 2 +STO 0 4 +JMP 0 26 +LOD 0 4 +OPR 0 14 +LOD 0 5 +OPR 0 14 +LOD 0 3 +OPR 0 14 +OPR 0 0 diff --git "a/Parser/ParserOutput\\PL0_code1.out" "b/Parser/ParserOutput\\PL0_code1.out" new file mode 100644 index 0000000..ec2b143 --- /dev/null +++ "b/Parser/ParserOutput\\PL0_code1.out" @@ -0,0 +1,22 @@ +JMP 0 7 +INI 0 3 +LOD 1 3 +LIT 0 10 +OPR 0 2 +STO 1 4 +OPR 0 0 +INI 0 5 +OPR 0 16 +STO 0 3 +LOD 0 3 +LIT 0 0 +OPR 0 9 +JPC 0 15 +JMP 0 21 +CALL 0 1 +LOD 0 4 +OPR 0 14 +OPR 0 16 +STO 0 3 +JMP 0 10 +OPR 0 0 diff --git "a/Parser/ParserOutput\\PL0_code2.out" "b/Parser/ParserOutput\\PL0_code2.out" new file mode 100644 index 0000000..d5cd56c --- /dev/null +++ "b/Parser/ParserOutput\\PL0_code2.out" @@ -0,0 +1,33 @@ +JMP 0 14 +INI 0 3 +LOD 1 3 +LIT 0 1 +OPR 0 2 +STO 1 3 +OPR 0 0 +INI 0 3 +CALL 1 1 +LOD 1 3 +LOD 1 3 +OPR 0 4 +STO 1 4 +OPR 0 0 +INI 0 5 +LIT 0 1 +STO 0 3 +LOD 0 3 +LIT 0 100 +OPR 0 13 +JPC 0 22 +JMP 0 32 +CALL 0 7 +LOD 0 4 +OPR 0 14 +LIT 0 2 +LOD 0 3 +OPR 0 4 +LIT 0 1 +OPR 0 2 +STO 0 3 +JMP 0 17 +OPR 0 0 diff --git "a/Parser/ParserOutput\\PL0_code3.out" "b/Parser/ParserOutput\\PL0_code3.out" new file mode 100644 index 0000000..9c02a7b --- /dev/null +++ "b/Parser/ParserOutput\\PL0_code3.out" @@ -0,0 +1,61 @@ +JMP 0 58 +INI 0 5 +LIT 0 1 +STO 1 4 +LIT 0 2 +STO 0 3 +LOD 0 3 +LOD 1 3 +OPR 0 10 +JPC 0 11 +JMP 0 35 +LOD 1 3 +LOD 0 3 +OPR 0 5 +LOD 0 3 +OPR 0 4 +LOD 1 3 +OPR 0 8 +JPC 0 20 +JMP 0 24 +LIT 0 0 +STO 1 4 +LOD 1 3 +STO 0 3 +LOD 0 3 +LIT 0 1 +OPR 0 2 +STO 0 3 +LOD 0 3 +LOD 0 4 +OPR 0 2 +LIT 0 2 +OPR 0 2 +STO 0 4 +JMP 0 6 +OPR 0 0 +INI 0 3 +LIT 0 2 +STO 1 3 +LOD 1 3 +LIT 0 100 +OPR 0 13 +JPC 0 44 +JMP 0 57 +CALL 1 1 +LOD 1 4 +LIT 0 1 +OPR 0 8 +JPC 0 50 +JMP 0 52 +LOD 1 3 +OPR 0 14 +LOD 1 3 +LIT 0 1 +OPR 0 2 +STO 1 3 +JMP 0 39 +OPR 0 0 +INI 0 5 +CALL 0 36 +OPR 0 0 diff --git "a/Parser/ParserOutput\\PL0_code4.out" "b/Parser/ParserOutput\\PL0_code4.out" new file mode 100644 index 0000000..e69de29 diff --git a/Parser/__pycache__/__init__.cpython-310.pyc b/Parser/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..bf65c56 Binary files /dev/null and b/Parser/__pycache__/__init__.cpython-310.pyc differ diff --git a/Parser/__pycache__/__init__.cpython-39.pyc b/Parser/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..8dea73a Binary files /dev/null and b/Parser/__pycache__/__init__.cpython-39.pyc differ diff --git a/Simulator/__pycache__/Machine.cpython-310.pyc b/Simulator/__pycache__/Machine.cpython-310.pyc new file mode 100644 index 0000000..9494ecc Binary files /dev/null and b/Simulator/__pycache__/Machine.cpython-310.pyc differ diff --git a/Simulator/__pycache__/Machine.cpython-39.pyc b/Simulator/__pycache__/Machine.cpython-39.pyc index d0e9883..a5b0657 100644 Binary files a/Simulator/__pycache__/Machine.cpython-39.pyc and b/Simulator/__pycache__/Machine.cpython-39.pyc differ diff --git a/Simulator/__pycache__/__init__.cpython-310.pyc b/Simulator/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..feb722e Binary files /dev/null and b/Simulator/__pycache__/__init__.cpython-310.pyc differ diff --git a/Simulator/__pycache__/__init__.cpython-39.pyc b/Simulator/__pycache__/__init__.cpython-39.pyc index 3d8d700..4e22275 100644 Binary files a/Simulator/__pycache__/__init__.cpython-39.pyc and b/Simulator/__pycache__/__init__.cpython-39.pyc differ diff --git a/Simulator/__pycache__/main.cpython-310.pyc b/Simulator/__pycache__/main.cpython-310.pyc new file mode 100644 index 0000000..f557adf Binary files /dev/null and b/Simulator/__pycache__/main.cpython-310.pyc differ diff --git a/Simulator/__pycache__/main.cpython-39.pyc b/Simulator/__pycache__/main.cpython-39.pyc index 4d25617..91e61a6 100644 Binary files a/Simulator/__pycache__/main.cpython-39.pyc and b/Simulator/__pycache__/main.cpython-39.pyc differ diff --git a/__pycache__/utils.cpython-310.pyc b/__pycache__/utils.cpython-310.pyc new file mode 100644 index 0000000..08eb5c3 Binary files /dev/null and b/__pycache__/utils.cpython-310.pyc differ diff --git a/__pycache__/utils.cpython-39.pyc b/__pycache__/utils.cpython-39.pyc new file mode 100644 index 0000000..5e9312f Binary files /dev/null and b/__pycache__/utils.cpython-39.pyc differ diff --git a/main.py b/main.py index d13c836..5193284 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,6 @@ +import warnings +warnings.filterwarnings("ignore") + from Lexer import lexer from Parser import lr1_parser from Parser import lr1_table_ui @@ -32,6 +35,6 @@ def gen_lr1table_ui(grammar_file_): if __name__ == '__main__': # 执行一次预操作以生成所有PL0代码的中间代码,之后修改 parser_output_file_ 参数就可以执行其它代码 - pre_operational() + # pre_operational() gen_lr1table_ui(grammar_file) - machine(parser_output_file_) + # machine(parser_output_file_) diff --git a/utils.py b/utils.py index 9398616..3650f1a 100644 --- a/utils.py +++ b/utils.py @@ -33,12 +33,11 @@ def insert(self, cmd: str, level: int, num: int): root_path = get_project_path() grammar_file = os.path.join(root_path, "Parser", "LR1Table", - "grammars", "grammar2.pl0") + "grammars", "mygrammar.txt") lexer_input_dir = os.path.join(root_path, "Lexer", "LexerInput") lexer_output_dir = os.path.join(root_path, "Lexer", "LexerOutput") parser_output_dir = os.path.join(root_path, "Parser", "ParserOutput") - # 在过程调用时,首先在栈中开辟三个空间,存放静态链SL、动态链DL(B)和返回地址RA(P) call_init_offset = 3