#!/usr/bin/python
# -*- coding: utf-8 -*-
import os, sys
import string #excutar com python -tt sintatico.py

erro = False
buffer = []

tipo_token_anterior = ""
cadeia = ""

permitidos = ['=', '+', '-', '/', '*', '%', '>', '<', '[', ']', '{', '}', '(', ')', ',' ';']
reservadas = ['e', 'escreve', 'int', 'le', 'letra', 'mainha', 'nada', 'nao', 'ou', 'real', 'se', 'senao', 'tome', 'uai', 'vaza'] 

tokens = []
tipo_tokens = [] 

for e in sys.stdin.read():
	buffer.append(e)


for caractere in buffer:
	if ( (ord(caractere) < 32 or ord(caractere) > 126) and (ord(caractere) != 9 and ord(caractere) != 10) ):
		erro = True
		break

if erro:
	print "ARQUIVO INVALIDO"
	sys.exit()

#------------------------------------------------------------------------------------------------------------------------------------------Função Principal------------------------------------------------------------------------------------------------------------------------------------------

Matriz = {
(83, "ou") : ('r', 16),
(84, "ou") : ('r', 20),
(87, "ou") : ('r', 23),
(88, "ou") : ('r', 24),
(89, "ou") : ('r', 26),
(90, "ou") : ('r', 27),
(118, "ou") : ('r', 21),
(125, "ou") : ('s', 157),
(126, "ou") : ('r', 8),
(128, "ou") : ('r', 10),
(129, "ou") : ('r', 11),
(139, "ou") : ('r', 82),
(147, "ou") : ('r', 14),
(148, "ou") : ('r', 15),
(149, "ou") : ('r', 17),
(150, "ou") : ('r', 18),
(151, "ou") : ('r', 19),
(152, "ou") : ('r', 22),
(159, "ou") : ('r', 9),
(176, "ou") : ('r', 81),
(179, "ou") : ('r', 25),
(184, "ou") : ('r', 7),
(185, "ou") : ('r', 12),
(186, "ou") : ('r', 13),
(83, "e") : ('r', 16),
(84, "e") : ('r', 20),
(87, "e") : ('r', 23),
(88, "e") : ('r', 24),
(89, "e") : ('r', 26),
(90, "e") : ('r', 27),
(118, "e") : ('r', 21),
(125, "e") : ('s', 158),
(126, "e") : ('r', 8),
(128, "e") : ('r', 10),
(129, "e") : ('r', 11),
(139, "e") : ('r', 82),
(147, "e") : ('r', 14),
(148, "e") : ('r', 15),
(149, "e") : ('r', 17),	
(150, "e") : ('r', 18),	
(151, "e") : ('r', 19),	
(152, "e") : ('r', 22),	
(159, "e") : ('r', 9),
(176, "e") : ('r', 81),
(179, "e") : ('r', 25),
(183, "e") : ('s', 158),
(184, "e") : ('r', 7),
(185, "e") : ('r', 12),
(186, "e") : ('r', 13),
(93, "nao") : ('s', 127),
(94, "nao") : ('s', 127),
(127, "nao") : ('s', 127),
(130, "nao") : ('s', 127),
(157, "nao") : ('s', 127),
(158, "nao") : ('s', 127),
(18, "(") : ('s', 22),
(19, "(") : ('s', 23),
(21, "(") : ('s', 24),
(50, "(") : ('s', 86),
(53, "(") : ('s', 93),
(54, "(") : ('s', 94),
(55, "(") : ('s', 95),
(56, "(") : ('s', 96),
(57, "(" ) : ('s', 99),
(77, "(" ) : ('s', 86),
(85, "(" ) : ('s', 86),
(86, "(" ) : ('s', 86),
(87, "(" ) : ('s', 99),
(93, "(" ) : ('s', 130),
(94, "(" ) : ('s', 130),
(96, "(" ) : ('s', 86),
(97, "(" ) : ('s', 86),
(98, "(" ) : ('s', 86),
(99, "(" ) : ('s', 86),
(113, "(" ) : ('s', 86),
(114, "(" ) : ('s', 86),
(115, "(" ) : ('s', 86),
(116, "(" ) : ('s', 86),
(117, "(" ) : ('s', 86),
(120, "(" ) : ('s', 86),
(122, "(" ) : ('s', 86),
(123, "(" ) : ('s', 86),
(127, "(" ) : ('s', 130),
(130, "(" ) : ('s', 130),
(157, "(" ) : ('s', 130),
(158, "(" ) : ('s', 130),
(162, "(" ) : ('s', 86),
(163, "(" ) : ('r', 31),
(164, "(" ) : ('r', 32),
(165, "(" ) : ('r', 33),
(166, "(" ) : ('r', 34),
(167, "(" ) : ('r', 35),
(168, "(" ) : ('r', 36),
(171, "(" ) : ('s', 86),
(177, "(" ) : ('s', 86),
(192, "(" ) : ('s', 86),
(22, ")" ) : ('s', 25),
(23, ")" ) : ('s', 27),
(24, ")" ) : ('s', 32),
(26, ")" ) : ('s', 34),
(28, ")" ) : ('r', 90),
(31, ")" ) : ('s', 39),
(38, ")" ) : ('r', 91),
(66, ")" ) : ('r', 89),
(83, ")" ) : ('r', 16),
(84, ")" ) : ('r', 20),
(87, ")" ) : ('r', 23),
(88, ")" ) : ('r', 24),
(89, ")" ) : ('r', 26),
(90, ")" ) : ('r', 27),
(99, ")" ) : ('s', 139),
(106, ")" ) : ('r', 92),
(118, ")" ) : ('r', 21),
(119, ")" ) : ('s', 152),
(124, ")" ) : ('s', 156),
(125, ")" ) : ('r', 6),
(126, ")" ) : ('r', 8),
(128, ")" ) : ('r', 10),
(129, ")" ) : ('r', 11),
(132, ")" ) : ('s', 169),
(133, ")" ) : ('s', 170),
(134, ")" ) : ('s', 172),
(135, ")" ) : ('s', 173),
(138, ")" ) : ('s', 176),
(139, ")" ) : ('r', 82),
(140, ")" ) : ('r', 29),
(141, ")" ) : ('r', 30),
(147, ")" ) : ('r', 14),
(148, ")" ) : ('r', 15),
(149, ")" ) : ('r', 17),
(150, ")" ) : ('r', 18),
(151, ")" ) : ('r', 19),
(152, ")" ) : ('r', 22),
(159, ")" ) : ('r', 9),
(160, ")" ) : ('s', 185),
(161, ")" ) : ('s', 152),
(176, ")" ) : ('r', 81),
(179, ")" ) : ('r', 25),
(183, ")" ) : ('r', 5),
(184, ")" ) : ('r', 7),
(185, ")" ) : ('r', 12),
(186, ")" ) : ('r', 13),
(193, ")" ) : ('r', 28),
(199, ")" ) : ('s', 205),
(82, "+") : ('s', 113),
(83, "+") : ('r', 16),
(84, "+") : ('r', 20),
(87, "+") : ('r', 23),
(88, "+") : ('r', 24),
(89, "+") : ('r', 26),
(90, "+") : ('r', 27),
(110, "+") : ('s', 113),
(118, "+") : ('r', 21),
(119, "+") : ('s', 113),
(131, "+") : ('s', 113),
(134, "+") : ('s', 113),
(136, "+") : ('s', 113),
(137, "+") : ('s', 113),
(139, "+") : ('r', 82),
(141, "+") : ('s', 113),
(147, "+") : ('r', 14),
(148, "+") : ('r', 15),
(149, "+") : ('r', 17),
(150, "+") : ('r', 18),
(151, "+") : ('r', 19),
(152, "+") : ('r', 22),
(153, "+") : ('s', 113),
(154, "+") : ('s', 113),
(155, "+") : ('s', 113),
(161, "+") : ('s', 113),
(176, "+") : ('r', 81),
(179, "+") : ('r', 25),
(186, "+") : ('s', 113),
(189, "+") : ('s', 113),
(200, "+") : ('s', 113),
(50, "-") : ('s', 85),
(77, "-") : ('s', 85),
(82, "-") : ('s', 114),
(83, "-") : ('r', 16),
(84, "-") : ('r', 20),
(85, "-") : ('s', 85),
(86, "-") : ('s', 85),
(87, "-") : ('r', 23),
(88, "-") : ('r', 24),
(89, "-") : ('r', 26),
(90, "-") : ('r', 27),
(93, "-") : ('s', 85),
(94, "-") : ('s', 85),
(96, "-") : ('s', 85),
(97, "-") : ('s', 85),
(98, "-") : ('s', 85),
(99, "-") : ('s', 85),
(110, "-") : ('s', 114),
(113, "-") : ('s', 85),
(114, "-") : ('s', 85),
(115, "-") : ('s', 85),
(116, "-") : ('s', 85),
(117, "-") : ('s', 85),
(118, "-") : ('r', 21),
(119, "-") : ('s', 114),
(120, "-") : ('s', 85),
(122, "-") : ('s', 85),
(123, "-") : ('s', 85),
(127, "-") : ('s', 85),
(130, "-") : ('s', 85),
(131, "-") : ('s', 114),
(134, "-") : ('s', 114),
(136, "-") : ('s', 114),
(137, "-") : ('s', 114),
(139, "-") : ('r', 82),
(141, "-") : ('s', 114),
(147, "-") : ('r', 14),
(148, "-") : ('r', 15),
(149, "-") : ('r', 17),
(150, "-") : ('r', 18),
(151, "-") : ('r', 19),
(152, "-") : ('r', 22),
(153, "-") : ('s', 114),
(154, "-") : ('s', 114),
(155, "-") : ('s', 114),
(157, "-") : ('s', 85),
(158, "-") : ('s', 85),
(161, "-") : ('s', 114),
(162, "-") : ('s', 85),
(163, "-") : ('r', 31),
(164, "-") : ('r', 32),
(165, "-") : ('r', 33),
(166, "-") : ('r', 34),
(167, "-") : ('r', 35),
(168, "-") : ('r', 36),
(171, "-") : ('s', 85),
(176, "-") : ('r', 81),
(177, "-") : ('s', 85),
(179, "-") : ('r', 25),
(186, "-") : ('s', 114),
(189, "-") : ('s', 114),
(192, "-") : ('s', 85),
(200, "-") : ('s', 114),
(83, "*") : ('s', 115),
(84, "*") : ('r', 20),
(87, "*") : ('r', 23),
(88, "*") : ('r', 24),
(89, "*") : ('r', 26),
(90, "*") : ('r', 27),
(118, "*") : ('r', 21),
(139, "*") : ('r', 82),
(147, "*") : ('s', 115),
(148, "*") : ('s', 115),
(149, "*") : ('r', 17),
(150, "*") : ('r', 18),
(151, "*") : ('r', 19),
(152, "*") : ('r', 22),
(176, "*") : ('r', 81),
(179, "*") : ('r', 25),
(83, "/" ) : ('s', 116),
(84, "/" ) : ('r', 20),
(87, "/" ) : ('r', 23),
(88, "/" ) : ('r', 24),
(89, "/" ) : ('r', 26),
(90, "/" ) : ('r', 27),
(118, "/" ) : ('r', 21),
(139, "/" ) : ('r', 82),
(147, "/" ) : ('s', 117),
(148, "/" ) : ('s', 117),
(149, "/" ) : ('r', 17),
(150, "/" ) : ('r', 18),
(151, "/" ) : ('r', 19),
(152, "/" ) : ('r', 22),
(176, "/" ) : ('r', 81),
(179, "/" ) : ('r', 25),
(83, "%") : ('s', 117),
(84, "%") : ('r', 20),
(87, "%") : ('r', 23),
(88, "%") : ('r', 24),
(89, "%") : ('r', 26),
(90, "%") : ('r', 27),
(118, "%") : ('r', 21),
(139, "%") : ('r', 82),
(147, "%") : ('s', 117),
(148, "%") : ('s', 117),
(149, "%") : ('r', 17),
(150, "%") : ('r', 18),
(151, "%") : ('r', 19),
(152, "%") : ('r', 22),
(176, "%") : ('r', 81),
(179, "%") : ('r', 25),
(7, "id") : ('r', 49),
(8, "id") : ('s', 19),
(9, "id") : ('r', 50),
(10, "id") : ('r', 51),
(11, "id") : ('r', 52),
(17, "id") : ('s', 21),
(29, "id") : ('s', 38),
(30, "id") : ('r', 49),
(33, "id") : ('s', 57),
(36, "id") : ('s', 57),
(41, "id") : ('s', 57),
(42, "id") : ('s', 57),
(43, "id") : ('r', 75),
(44, "id") : ('r', 65),
(45, "id") : ('r', 66),
(46, "id") : ('r', 67),
(47, "id") : ('r', 68),
(48, "id") : ('r', 69),
(50, "id") : ('s', 87),
(52, "id") : ('s', 92),
(58, "id") : ('r', 53),
(59, "id") : ('r', 54),
(60, "id") : ('r', 55),
(62, "id") : ('s', 57),
(64, "id") : ('s', 57),
(65, "id") : ('s', 57),
(68, "id") : ('s', 57),
(71, "id") : ('r', 56),
(72, "id") : ('r', 57),
(73, "id") : ('r', 58),
(74, "id") : ('r', 59),
(75, "id") : ('r', 60),
(77, "id") : ('s', 87),
(79, "id") : ('r', 74),
(80, "id") : ('r', 70),
(81, "id") : ('r', 71),
(85, "id") : ('s', 87),
(86, "id") : ('s', 87),
(91, "id") : ('r', 73),
(93, "id") : ('s', 87),
(94, "id") : ('s', 87),
(95, "id") : ('s', 133),
(96, "id") : ('s', 87),
(97, "id") : ('s', 87),
(98, "id") : ('s', 87),
(99, "id") : ('s', 87),
(101, "id") : ('s', 57),
(102, "id") : ('s', 57),
(104, "id") : ('s', 57),
(108, "id") : ('r', 61),
(109, "id") : ('r', 62),
(111, "id") : ('r', 64),
(112, "id") : ('r', 72),
(113, "id") : ('s', 87),
(114, "id") : ('s', 87),
(115, "id") : ('s', 87),
(116, "id") : ('s', 87),
(117, "id") : ('s', 87),
(120, "id") : ('s', 87),
(121, "id") : ('r', 76),
(122, "id") : ('s', 87),
(123, "id") : ('s', 87),
(127, "id") : ('s', 87),
(130, "id") : ('s', 87),
(143, "id") : ('s', 57),
(146, "id") : ('r', 63),
(157, "id") : ('s', 87),
(158, "id") : ('s', 87),
(162, "id") : ('s', 87),
(163, "id") : ('r', 31),
(164, "id") : ('r', 32),
(165, "id") : ('r', 33),
(166, "id") : ('r', 34),
(167, "id") : ('r', 35),
(168, "id") : ('r', 36),
(171, "id") : ('s', 87),
(174, "id") : ('r', 79),
(177, "id") : ('s', 87),
(180, "id") : ('r', 77),
(182, "id") : ('s', 57),
(187, "id") : ('s', 57),
(188, "id") : ('r', 45),
(190, "id") : ('r', 47),
(191, "id") : ('r', 48),
(192, "id") : ('s', 87),
(194, "id") : ('r', 78),
(195, "id") : ('r', 37),
(196, "id") : ('s', 57),
(197, "id") : ('r', 43),
(198, "id") : ('s', 57),
(201, "id") : ('r', 38),
(203, "id") : ('r', 39),
(204, "id") : ('r', 44),
(206, "id") : ('r', 80),
(207, "id") : ('s', 57),
(208, "id") : ('r', 40),
(209, "id") : ('r', 46),
(210, "id") : ('r', 41),
(211, "id") : ('s', 57),
(212, "id") : ('r', 42),
(38, "[") : ('s', 67),
(57, "[") : ('s', 98),
(87, "[") : ('s', 120),
(92, "[") : ('s', 123),
(133, "[") : ('s', 171),
(67, "]") : ('s', 106),
(83, "]") : ('r', 16),
(84, "]") : ('r', 20),
(87, "]") : ('r', 23),
(88, "]") : ('r', 24),
(89, "]") : ('r', 26),
(90, "]") : ('r', 27),
(118, "]") : ('r', 21),
(137, "]") : ('s', 175),
(139, "]") : ('r', 82),
(147, "]") : ('r', 14),
(148, "]") : ('r', 15),
(149, "]") : ('r', 17),
(150, "]") : ('r', 18),
(151, "]") : ('r', 19),
(152, "]") : ('r', 22),
(153, "]") : ('s', 179),
(155, "]") : ('s', 181),
(176, "]") : ('r', 81),
(179, "]") : ('r', 25),
(189, "]") : ('s', 199),
(50, "numero") : ('s', 89),
(77, "numero") : ('s', 89),
(85, "numero") : ('s', 89),
(86, "numero") : ('s', 89),
(93, "numero") : ('s', 89),
(94, "numero") : ('s', 89),
(96, "numero") : ('s', 89),
(97, "numero") : ('s', 89),
(98, "numero") : ('s', 89),
(99, "numero") : ('s', 89),
(113, "numero") : ('s', 89),
(114, "numero") : ('s', 89),
(115, "numero") : ('s', 89),
(116, "numero") : ('s', 89),
(117, "numero") : ('s', 89),
(120, "numero") : ('s', 89),
(122, "numero") : ('s', 89),
(123, "numero") : ('s', 89),
(127, "numero") : ('s', 89),
(130, "numero") : ('s', 89),
(157, "numero") : ('s', 89),
(158, "numero") : ('s', 89),
(162, "numero") : ('s', 89),
(163, "numero") : ('r', 31),
(164, "numero") : ('r', 32),
(165, "numero") : ('r', 33),
(166, "numero") : ('r', 34),
(167, "numero") : ('r', 35),
(168, "numero") : ('r', 36),
(171, "numero") : ('s', 89),
(177, "numero") : ('s', 89),
(192, "numero") : ('s', 89),
(50, "char") : ('s', 90),
(77, "char") : ('s', 90),
(85, "char") : ('s', 90),
(86, "char") : ('s', 90),
(93, "char") : ('s', 90),
(94, "char") : ('s', 90),
(96, "char") : ('s', 90),
(97, "char") : ('s', 90),
(98, "char") : ('s', 90),
(99, "char") : ('s', 90),
(113, "char") : ('s', 90),
(114, "char") : ('s', 90),
(115, "char") : ('s', 90),
(116, "char") : ('s', 90),
(117, "char") : ('s', 90),
(120, "char") : ('s', 90),
(122, "char") : ('s', 90),
(123, "char") : ('s', 90),
(127, "char") : ('s', 90),
(130, "char") : ('s', 90),
(157, "char") : ('s', 90),
(158, "char") : ('s', 90),
(162, "char") : ('s', 90),
(163, "char") : ('r', 31),
(164, "char") : ('r', 32),
(165, "char") : ('r', 33),
(166, "char") : ('r', 34),
(167, "char") : ('r', 35),
(168, "char") : ('r', 36),
(171, "char") : ('s', 90),
(177, "char") : ('s', 90),
(192, "char") : ('s', 90),
(28, ",") : ('s', 37),
(38, ",") : ('r', 91),
(83, ",") : ('r', 16),
(84, ",") : ('r', 20),
(87, ",") : ('r', 23),
(88, ",") : ('r', 24),
(89, ",") : ('r', 26),
(90, ",") : ('r', 27),
(106, ",") : ('r', 92),
(118, ",") : ('r', 21),
(139, ",") : ('r', 82),
(140, ",") : ('s', 177),
(141, ",") : ('r', 30),
(147, ",") : ('r', 14),
(148, ",") : ('r', 15),
(149, ",") : ('r', 17),
(150, ",") : ('r', 18),
(151, ",") : ('r', 19),
(152, ",") : ('r', 22),
(176, ",") : ('r', 81),
(179, ",") : ('r', 25),
(83, ">" ) : ('r', 16),
(84, ">" ) : ('r', 20),
(87, ">" ) : ('r', 23),
(88, ">" ) : ('r', 24),
(89, ">" ) : ('r', 26),
(90, ">" ) : ('r', 27),
(118, ">" ) : ('r', 21),
(131, ">" ) : ('s', 163),
(139, ">" ) : ('r', 82),
(147, ">" ) : ('r', 14),
(148, ">" ) : ('r', 15),
(149, ">" ) : ('r', 17),
(150, ">" ) : ('r', 18),
(151, ">" ) : ('r', 19),
(152, ">" ) : ('r', 22),
(161, ">" ) : ('s', 163),
(176, ">" ) : ('r', 81),
(179, ">" ) : ('r', 25),
(83, ">=") : ('r', 16),
(84, ">=") : ('r', 20),
(87, ">=") : ('r', 23),
(88, ">=") : ('r', 24),
(89, ">=") : ('r', 26),
(90, ">=") : ('r', 27),
(118, ">=") : ('r', 21),
(131, ">=") : ('s', 164),
(139, ">=") : ('r', 82),
(147, ">=") : ('r', 14),
(148, ">=") : ('r', 15),
(149, ">=") : ('r', 17),
(150, ">=") : ('r', 18),
(151, ">=") : ('r', 19),
(152, ">=") : ('r', 22),
(161, ">=") : ('s', 164),
(176, ">=") : ('r', 81),
(179, ">=") : ('r', 25),
(83, "<") : ('r', 16),
(84, "<") : ('r', 20),
(87, "<") : ('r', 23),
(88, "<") : ('r', 24),
(89, "<") : ('r', 26),
(90, "<") : ('r', 27),
(118, "<") : ('r', 21),
(131, "<") : ('s', 165),
(139, "<") : ('r', 82),
(147, "<") : ('r', 14),
(148, "<") : ('r', 15),
(149, "<") : ('r', 17),
(150, "<") : ('r', 18),
(151, "<") : ('r', 19),
(152, "<") : ('r', 22),
(161, "<") : ('s', 165),
(176, "<") : ('r', 81),
(179, "<") : ('r', 25),
(83, "<=") : ('r', 16),
(84, "<=") : ('r', 20),
(87, "<=") : ('r', 23),
(88, "<=") : ('r', 24),
(89, "<=") : ('r', 26),
(90, "<=") : ('r', 27),
(118, "<=") : ('r', 21),
(131, "<=") : ('s', 166),
(139, "<=") : ('r', 82),
(147, "<=") : ('r', 14),
(148, "<=") : ('r', 15),
(149, "<=") : ('r', 17),
(150, "<=") : ('r', 18),
(151, "<=") : ('r', 19),
(152, "<=") : ('r', 22),
(161, "<=") : ('s', 166),
(176, "<=") : ('r', 81),
(179, "<=") : ('r', 25),
(83, "==") : ('r', 16),
(84, "==") : ('r', 20),
(87, "==") : ('r', 23),
(88, "==") : ('r', 24),
(89, "==") : ('r', 26),
(90, "==") : ('r', 27),
(118, "==") : ('r', 21),
(131, "==") : ('s', 167),
(139, "==") : ('r', 82),
(147, "==") : ('r', 14),
(148, "==") : ('r', 15),
(149, "==") : ('r', 17),
(150, "==") : ('r', 18),
(151, "==") : ('r', 19),
(152, "==") : ('r', 22),
(161, "==") : ('s', 167),
(176, "==") : ('r', 81),
(179, "==") : ('r', 25),
(83, "!=") : ('r', 16),
(84, "!=") : ('r', 20),
(87, "!=") : ('r', 23),
(88, "!=") : ('r', 24),
(89, "!=") : ('r', 26),
(90, "!=") : ('r', 27),
(118, "!=") : ('r', 21),
(131, "!=") : ('s', 168),
(139, "!=") : ('r', 82),
(147, "!=") : ('r', 14),
(148, "!=") : ('r', 15),
(149, "!=") : ('r', 17),
(150, "!=") : ('r', 18),
(151, "!=") : ('r', 19),
(152, "!=") : ('r', 22),
(161, "!=") : ('s', 168),
(176, "!=") : ('r', 81),
(179, "!=") : ('r', 25),
(33, "se") : ('s', 53),
(36, "se") : ('s', 53),
(41, "se") : ('s', 53),
(42, "se") : ('s', 53),
(43, "se") : ('r', 75),
(44, "se") : ('r', 65),
(45, "se") : ('r', 66),
(46, "se") : ('r', 67),
(47, "se") : ('r', 68),
(48, "se") : ('r', 69),
(62, "se") : ('s', 53),
(64, "se") : ('s', 53),
(65, "se") : ('s', 53),
(68, "se") : ('s', 53),
(71, "se") : ('r', 56),
(72, "se") : ('r', 57),
(73, "se") : ('r', 58),
(74, "se") : ('r', 59),
(75, "se") : ('r', 60),
(79, "se") : ('r', 74),
(80, "se") : ('r', 70),
(81, "se") : ('r', 71),
(91, "se") : ('r', 73),
(101, "se") : ('s', 53),
(102, "se") : ('s', 53),
(104, "se") : ('s', 53),
(108, "se") : ('r', 61),
(109, "se") : ('r', 62),
(111, "se") : ('r', 64),
(112, "se") : ('r', 72),
(121, "se") : ('r', 76),
(143, "se") : ('s', 53),
(146, "se") : ('r', 63),
(174, "se") : ('r', 79),
(180, "se") : ('r', 77),
(182, "se") : ('s', 53),
(187, "se") : ('s', 53),
(188, "se") : ('r', 45),
(190, "se") : ('r', 47),
(191, "se") : ('r', 48),
(194, "se") : ('r', 78),
(195, "se") : ('r', 37),
(196, "se") : ('s', 53),
(197, "se") : ('r', 43),
(198, "se") : ('s', 53),
(201, "se") : ('r', 38),
(203, "se") : ('r', 39),
(204, "se") : ('r', 44),
(206, "se") : ('r', 80),
(207, "se") : ('s', 53),
(208, "se") : ('r', 40),
(209, "se") : ('r', 46),
(210, "se") : ('r', 41),
(211, "se") : ('s', 53),
(212, "se") : ('r', 42),
(25, "{") : ('s', 33),
(27, "{") : ('s', 36),
(32, "{") : ('s', 36),
(34, "{") : ('s', 62),
(39, "{") : ('s', 62),
(156, "{") : ('s', 182),
(169, "{") : ('s', 187),
(202, "{") : ('s', 207),
(33, "}") : ('s', 40),
(36, "}") : ('s', 63),
(41, "}") : ('s', 69),
(42, "}") : ('s', 70),
(43, "}") : ('r', 75),
(44, "}") : ('r', 65),
(45, "}") : ('r', 66),
(46, "}") : ('r', 67),
(47, "}") : ('r', 68),
(48, "}") : ('r', 69),
(62, "}") : ('s', 100),
(64, "}") : ('s', 103),
(65, "}") : ('s', 105),
(68, "}") : ('s', 107),
(71, "}") : ('r', 56),
(72, "}") : ('r', 57),
(73, "}") : ('r', 58),
(74, "}") : ('r', 59),
(75, "}") : ('r', 60),
(79, "}") : ('r', 74),
(80, "}") : ('r', 70),
(81, "}") : ('r', 71),
(91, "}") : ('r', 73),
(101, "}") : ('s', 142),
(102, "}") : ('s', 144),
(104, "}") : ('s', 145),
(108, "}") : ('r', 61),
(109, "}") : ('r', 62),
(111, "}") : ('r', 64),
(112, "}") : ('r', 72),
(121, "}") : ('r', 76),
(143, "}") : ('s', 178),
(146, "}") : ('r', 63),
(174, "}") : ('r', 79),
(180, "}") : ('r', 77),
(182, "}") : ('s', 195),
(187, "}") : ('s', 197),
(188, "}") : ('r', 45),
(190, "}") : ('r', 47),
(191, "}") : ('r', 48),
(194, "}") : ('r', 78),
(195, "}") : ('r', 37),
(196, "}") : ('s', 203),
(197, "}") : ('r', 43),
(198, "}") : ('s', 204),
(201, "}") : ('r', 38),
(203, "}") : ('r', 39),
(204, "}") : ('r', 44),
(206, "}") : ('r', 80),
(207, "}") : ('s', 210),
(208, "}") : ('r', 40),
(209, "}") : ('r', 46),
(210, "}") : ('r', 41),
(211, "}") : ('s', 212),
(212, "}") : ('r', 42),
(195, "senao") : ('s', 202),
(203, "senao") : ('s', 202),
(33, "uai") : ('s', 54),
(36, "uai") : ('s', 54),
(41, "uai") : ('s', 54),
(42, "uai") : ('s', 54),
(43, "uai") : ('r', 75),
(44, "uai") : ('r', 65),
(45, "uai") : ('r', 66),
(46, "uai") : ('r', 67),
(47, "uai") : ('r', 68),
(48, "uai") : ('r', 69),
(62, "uai") : ('s', 54),
(64, "uai") : ('s', 54),
(65, "uai") : ('s', 54),
(68, "uai") : ('s', 54),
(71, "uai") : ('r', 56),
(72, "uai") : ('r', 57),
(73, "uai") : ('r', 58),
(74, "uai") : ('r', 59),
(75, "uai") : ('r', 60),
(79, "uai") : ('r', 74),
(80, "uai") : ('r', 70),
(81, "uai") : ('r', 71),
(91, "uai") : ('r', 73),
(101, "uai") : ('s', 54),
(102, "uai") : ('s', 54),
(104, "uai") : ('s', 54),
(108, "uai") : ('r', 61),
(109, "uai") : ('r', 62),
(111, "uai") : ('r', 64),
(112, "uai") : ('r', 72),
(121, "uai") : ('r', 76),
(143, "uai") : ('s', 54),
(146, "uai") : ('r', 63),
(174, "uai") : ('r', 79),
(180, "uai") : ('r', 77),
(182, "uai") : ('s', 54),
(187, "uai") : ('s', 54),
(188, "uai") : ('r', 45),
(190, "uai") : ('r', 47),
(191, "uai") : ('r', 48),
(194, "uai") : ('r', 78),
(195, "uai") : ('r', 37),
(196, "uai") : ('s', 54),
(197, "uai") : ('r', 43),
(198, "uai") : ('s', 54),
(201, "uai") : ('r', 38),
(203, "uai") : ('r', 39),
(204, "uai") : ('r', 44),
(206, "uai") : ('r', 80),
(207, "uai") : ('s', 54),
(208, "uai") : ('r', 40),
(209, "uai") : ('r', 46),
(210, "uai") : ('r', 41),
(211, "uai") : ('s', 54),
(212, "uai") : ('r', 42),
(33, "le") : ('s', 55),
(36, "le") : ('s', 55),
(41, "le") : ('s', 55),
(42, "le") : ('s', 55),
(43, "le") : ('r', 75),
(44, "le") : ('r', 65),
(45, "le") : ('r', 66),
(46, "le") : ('r', 67),
(47, "le") : ('r', 68),
(48, "le") : ('r', 69),
(62, "le") : ('s', 55),
(64, "le") : ('s', 55),
(65, "le") : ('s', 55),
(68, "le") : ('s', 55),
(71, "le") : ('r', 56),
(72, "le") : ('r', 57),
(73, "le") : ('r', 58),
(74, "le") : ('r', 59),
(75, "le") : ('r', 60),
(79, "le") : ('r', 74),
(80, "le") : ('r', 70),
(81, "le") : ('r', 71),
(91, "le") : ('r', 73),
(101, "le") : ('s', 55),
(102, "le") : ('s', 55),
(104, "le") : ('s', 55),
(108, "le") : ('r', 61),
(109, "le") : ('r', 62),
(111, "le") : ('r', 64),
(112, "le") : ('r', 72),
(121, "le") : ('r', 76),
(143, "le") : ('s', 55),
(146, "le") : ('r', 63),
(174, "le") : ('r', 79),
(180, "le") : ('r', 77),
(182, "le") : ('s', 55),
(187, "le") : ('s', 55),
(188, "le") : ('r', 45),
(190, "le") : ('r', 47),
(191, "le") : ('r', 48),
(194, "le") : ('r', 78),
(195, "le") : ('r', 37),
(196, "le") : ('s', 55),
(197, "le") :  ('r', 43),
(198, "le") : ('s', 55),
(201, "le") : ('r', 38),
(203, "le") : ('r', 39),
(204, "le") : ('r', 44),
(206, "le") : ('r', 80),
(207, "le") : ('s', 55),
(208, "le") : ('r', 40),
(209, "le") : ('r', 46),
(210, "le") : ('r', 41),
(211, "le") : ('s', 55),
(212, "le") : ('r', 42),
(27, ";") : ('s', 35),
(34, ";") : ('s', 61),
(49, ";") : ('s', 80),
(50, ";") : ('s', 81),
(51, ";") : ('s', 91),
(76, ";") : ('s', 108),
(77, ";") : ('s', 109),
(78, ";") : ('s', 111),
(82, ";") : ('s', 112),
(83, ";") : ('r', 16),
(84, ";") : ('r', 20),
(87, ";") : ('r', 23),
(88, ";") : ('r', 24),
(89, ";") : ('r', 26),
(90, ";") : ('r', 27),
(92, ";") : ('s', 121),
(110, ";") : ('s', 146),
(118, ";") : ('r', 21),
(136, ";") : ('s', 174),
(139, ";") : ('r', 82),
(147, ";") : ('r', 14),
(148, ";") : ('r', 15),
(149, ";") : ('r', 17),
(150, ";") : ('r', 18),
(151, ";") : ('r', 19),
(152, ";") : ('r', 22),
(154, ";") : ('s', 180),
(170, ";") : ('s', 188),
(172, ";") : ('s', 190),
(173, ";") : ('s', 191),
(176, ";") : ('r', 81),
(179, ";") : ('r', 25),
(181, ";") : ('s', 194),
(200, ";") : ('s', 206),
(205, ";") : ('s', 209),
(33, "escreve") : ('s', 56),
(36, "escreve") : ('s', 56),
(41, "escreve") : ('s', 56),
(42, "escreve") : ('s', 56),
(43, "escreve") : ('r', 75),
(44, "escreve") : ('r', 65),
(45, "escreve") : ('r', 66),
(46, "escreve") : ('r', 67),
(47, "escreve") : ('r', 68),
(48, "escreve") : ('r', 69),
(62, "escreve") : ('s', 56),
(64, "escreve") : ('s', 56),
(65, "escreve") : ('s', 56),
(68, "escreve") : ('s', 56),
(71, "escreve") : ('r', 56),
(72, "escreve") : ('r', 57),
(73, "escreve") : ('r', 58),
(74, "escreve") : ('r', 59),
(75, "escreve") : ('r', 60),
(79, "escreve") : ('r', 74),
(80, "escreve") : ('r', 70),
(81, "escreve") : ('r', 71),
(91, "escreve") :	('r', 73),
(101, "escreve") : ('s', 56),
(102, "escreve") : ('s', 56),
(104, "escreve") : ('s', 56),
(108, "escreve") : ('r', 61),
(109, "escreve") : ('r', 62),
(111, "escreve") : ('r', 64),
(112, "escreve") : ('r', 72),
(121, "escreve") : ('r', 76),
(143, "escreve") : ('s', 56),
(146, "escreve") : ('r', 63),
(174, "escreve") : ('r', 79),
(180, "escreve") : ('r', 77),
(182, "escreve") : ('s', 56),
(187, "escreve") : ('s', 56),
(188, "escreve") : ('r', 45),
(190, "escreve") : ('r', 47),
(191, "escreve") : ('r', 48),
(194, "escreve") : ('r', 78),
(195, "escreve") : ('r', 37),
(196, "escreve") : ('s', 56),
(197, "escreve") : ('r', 43),
(198, "escreve") : ('s', 56),
(201, "escreve") : ('r', 38),
(203, "escreve") : ('r', 39),
(204, "escreve") : ('r', 44),
(206, "escreve") : ('r', 80),
(207, "escreve") : ('s', 56),
(208, "escreve") : ('r', 40),
(209, "escreve") : ('r', 46),
(210, "escreve") : ('r', 41),
(211, "escreve") : ('s', 56),
(212, "escreve") : ('r', 42),
(96, "string") : ('s', 135),
(0, "int") : ('s', 7),
(2, "int") : ('s', 7),
(3, "int") : ('s', 7),
(5, "int") : ('r', 84),
(6, "int") : ('r', 88),
(12, "int") : ('s', 7),
(14, "int") : ('r', 83),
(16, "int") : ('r', 87),
(23, "int") : ('s', 30),
(24, "int") : ('s', 30),
(33, "int") : ('s', 58),
(35, "int") : ('r', 86),
(36, "int") : ('s', 58),
(37, "int") : ('s', 30),
(43, "int") : ('s', 58),
(61, "int") : ('r', 85),
(62, "int") : ('s', 58),
(63, "int") : ('r', 97),
(100, "int") : ('r', 93),
(103, "int") : ('r', 98),
(105, "int") : ('r', 100),
(121, "int") : ('r', 76),
(142, "int") : ('r', 94),
(144, "int") : ('r', 96),
(145, "int") : ('r', 99),
(178, "int") : ('r', 95),
(180, "int") : ('r', 77),
(194, "int") : ('r', 78),
(0, "real") : ('s', 9),
(2, "real") : ('s', 9),
(3, "real") : ('s', 9),
(5, "real") : ('r', 84),
(6, "real") : ('r', 88),
(12, "real") : ('s', 9),
(14, "real") : ('r', 83),
(16, "real") : ('r', 87),
(23, "real") : ('s', 9),
(24, "real") : ('s', 9),
(33, "real") : ('s', 59),
(35, "real") : ('r', 86),
(36, "real") : ('s', 59),
(37, "real") : ('s', 9),
(43, "real") : ('s', 59),
(61, "real") : ('r', 85),
(62, "real") : ('s', 59),
(63, "real") : ('r', 97),
(100, "real") : ('r', 93),
(103, "real") : ('r', 98),
(105, "real") : ('r', 100),
(121, "real") : ('r', 76),
(142, "real") : ('r', 94),
(144, "real") : ('r', 96),
(145, "real") : ('r', 99),
(178, "real") : ('r', 95),
(180, "real") : ('r', 77),
(194, "real") : ('r', 78),
(0, "letra") : ('s', 10),
(2, "letra") : ('s', 10),
(3, "letra") : ('s', 10),
(5, "letra") : ('r', 84),
(6, "letra") : ('r', 88),
(12, "letra") : ('s', 10),
(14, "letra") : ('r', 83),
(16, "letra") : ('r', 87),
(23, "letra") : ('s', 10),
(24, "letra") : ('s', 10),
(33, "letra") : ('s', 60),
(35, "letra") : ('r', 86),
(36, "letra") : ('s', 60),
(37, "letra") : ('s', 10),
(43, "letra") : ('s', 60),
(61, "letra") : ('r', 85),
(62, "letra") : ('s', 60),
(63, "letra") : ('r', 97),
(100, "letra") : ('r', 93),
(103, "letra") : ('r', 98),
(105, "letra") : ('r', 100),
(121, "letra") : ('r', 76),
(142, "letra") : ('r', 94),
(144, "letra") : ('r', 96),
(145, "letra") : ('r', 99),
(178, "letra") : ('r', 95),
(180, "letra") : ('r', 77),
(194, "letra") : ('r', 78),
(0, "nada") : ('s', 11),
(2, "nada") : ('s', 11),
(3, "nada") : ('s', 11),
(5, "nada") : ('r', 84),
(6, "nada") : ('r', 88),
(12, "nada") : ('s', 11),
(14, "nada") : ('r', 83),
(16, "nada") : ('r', 87),
(23, "nada") : ('s', 11),
(24, "nada") : ('s', 11),
(35, "nada") : ('r', 86),
(37, "nada") : ('s', 11),
(61, "nada") : ('r', 85),
(63, "nada") : ('r', 97),
(100, "nada") : ('r', 93),
(103, "nada") : ('r', 98),
(105, "nada") : ('r', 100),
(142, "nada") : ('r', 94),
(144, "nada") : ('r', 96),
(145, "nada") : ('r', 99),
(178, "nada") : ('r', 95),
(33, "vaza") : ('s', 49),
(36, "vaza") : ('s', 49),
(41, "vaza") : ('s', 49),
(42, "vaza") : ('s', 76),
(43, "vaza") : ('r', 75),
(44, "vaza") : ('r', 65),
(45, "vaza") : ('r', 66),
(46, "vaza") : ('r', 67),
(47, "vaza") : ('r', 68),
(48, "vaza") : ('r', 69),
(62, "vaza") : ('s', 49),
(64, "vaza") : ('s', 49),
(65, "vaza") : ('s', 76),
(68, "vaza") : ('s', 76),
(71, "vaza") : ('r', 56),
(72, "vaza") : ('r', 57),
(73, "vaza") : ('r', 58),
(74, "vaza") : ('r', 59),
(75, "vaza") : ('r', 60),
(79, "vaza") : ('r', 74),
(80, "vaza") : ('r', 70),
(81, "vaza") : ('r', 71),
(91, "vaza") : ('r', 73),
(101, "vaza") : ('s', 49),
(102, "vaza") : ('s', 76),
(104, "vaza") : ('s', 76),
(108, "vaza") : ('r', 61),
(109, "vaza") : ('r', 62),
(111, "vaza") : ('r', 64),
(112, "vaza") : ('r', 72),
(121, "vaza") : ('r', 76),
(143, "vaza") : ('s', 76),
(146, "vaza") : ('r', 63),
(174, "vaza") : ('r', 79),
(180, "vaza") : ('r', 77),
(182, "vaza") : ('s', 49),
(187, "vaza") : ('s', 49),
(188, "vaza") : ('r', 45),
(190, "vaza") : ('r', 47),
(191, "vaza") : ('r', 48),
(194, "vaza") : ('r', 78),
(195, "vaza") : ('r', 37),
(196, "vaza") : ('s', 76),
(197, "vaza") : ('r', 43),
(198, "vaza") : ('s', 76),
(201, "vaza") : ('r', 38),
(203, "vaza") : ('r', 39),
(204, "vaza") : ('r', 44),
(206, "vaza") : ('r', 80),
(207, "vaza") : ('s', 49),
(208, "vaza") : ('r', 40),
(209, "vaza") : ('r', 46),
(210, "vaza") : ('r', 41),
(211, "vaza") : ('s', 76),
(212, "vaza") : ('r', 42),
(33, "tome") : ('s', 50),
(36, "tome") : ('s', 50),
(41, "tome") : ('s', 50),
(42, "tome") : ('s', 77),
(43, "tome") : ('r', 75),
(44, "tome") : ('r', 65),
(45, "tome") : ('r', 66),
(46, "tome") : ('r', 67),
(47, "tome") : ('r', 68),
(48, "tome") : ('r', 69),
(62, "tome") : ('s', 50),
(64, "tome") : ('s', 50),
(65, "tome") : ('s', 77),
(68, "tome") : ('s', 77),
(71, "tome") : ('r', 56),
(72, "tome") : ('r', 57),
(73, "tome") : ('r', 58),
(74, "tome") : ('r', 59),
(75, "tome") : ('r', 60),
(79, "tome") : ('r', 74),
(80, "tome") : ('r', 70),
(81, "tome") : ('r', 71),
(91, "tome") : ('r', 73),
(101, "tome") : ('s', 50),
(102, "tome") :  ('s', 77),
(104, "tome") : ('s', 77),
(108, "tome") : ('r', 61),
(109, "tome") : ('r', 62),
(111, "tome") : ('r', 64),
(112, "tome") : ('r', 72),
(121, "tome") : ('r', 76),
(143, "tome") : ('s', 77),
(146, "tome") : ('r', 63),
(174, "tome") : ('r', 79),
(180, "tome") : ('r', 77),
(182, "tome") : ('s', 50),
(187, "tome") : ('s', 50),
(188, "tome") : ('r', 45),
(190, "tome") : ('r', 47),
(191, "tome") : ('r', 48),
(194, "tome") : ('r', 78),
(195, "tome") : ('r', 37),
(196, "tome") : ('s', 77),
(197, "tome") : ('r', 43),
(198, "tome") : ('s', 77),
(201, "tome") : ('r', 38),
(203, "tome") : ('r', 39),
(204, "tome") : ('r', 44),
(206, "tome") : ('r', 80),
(207, "tome") : ('s', 50),
(208, "tome") : ('r', 40),
(209, "tome") : ('r', 46),
(210, "tome") : ('r', 41),
(211, "tome") : ('s', 77),
(212, "tome") : ('r', 42),
(57, "=") : ('s', 97),
(92, "=") : ('s', 122),
(175, "=") : ('s', 192),
(7, "mainha") : ('s', 18),
(1, "$") : 'acc',
(4, "$") :	('r', 4),
(13, "$") :	('r', 2),
(15, "$") :	('r', 3),
(20, "$") :	('r', 1),
(40, "$") :	('r', 101),
(69, "$") :	('r', 103),
(70, "$") : ('r', 104),
(107, "$") : ('r', 102)
}
REDUCE = {
	('r', 0) : ("PROGRAMA'", 2),
	('r', 1) : ("PROGRAMA", 6),
	('r', 2) : ("PROGRAMA", 4),
	('r', 3) : ("PROGRAMA", 4),
	('r', 4) : ("PROGRAMA", 2),
	('r', 5) : ("EXP_COMP", 6),
	('r', 6) : ("EXP_COMP", 2),
	('r', 7) : ("W", 6),
	('r', 8) : ("W", 2),
	('r', 9) : ("Y", 4),
	('r', 10) : ("Y", 2),
	('r', 11) : ("X", 2),
	('r', 12) : ("X", 6),
	('r', 13) : ("EXP_REL", 6),
	('r', 14) : ("E", 6),
	('r', 15) : ("E", 6),
	('r', 16) : ("E", 2),
	('r', 17) : ("T", 6),
	('r', 18) : ("T", 6),
	('r', 19) : ("T", 6),
	('r', 20) : ("T", 2),
	('r', 21) : ("F", 4),
	('r', 22) : ("F", 6),
	('r', 23) : ("F", 2),
	('r', 24) : ("F", 2),
	('r', 25) : ("F", 8),
	('r', 26) : ("F", 2),
	('r', 27) : ("F", 2),
	('r', 28) : ("LISTA_ARIT", 6),
	('r', 29) : ("LISTA_ARIT", 2),
	('r', 30) : ("EXP_ARIT_AUX", 2),
	('r', 31) : ("OP_SIMB", 2),
	('r', 32) : ("OP_SIMB", 2),
	('r', 33) : ("OP_SIMB", 2),
	('r', 34) : ("OP_SIMB", 2),
	('r', 35) : ("OP_SIMB", 2),
	('r', 36) : ("OP_SIMB", 2),
	('r', 37) : ("IF", 12),
	('r', 38) : ("IF", 14),
	('r', 39) : ("IF", 14),
	('r', 40) : ("IF", 16),
	('r', 41) : ("ELSE", 6),
	('r', 42) : ("ELSE", 8),
	('r', 43) : ("REP", 12),
	('r', 44) : ("REP", 14),
	('r', 45) : ("LEI", 10),
	('r', 46) : ("LEI", 16),
	('r', 47) : ("ESCR", 10),
	('r', 48) : ("ESCR", 10),
	('r', 49) : ("TIPO", 2),
	('r', 50) : ("TIPO", 2),
	('r', 51) : ("TIPO", 2),
	('r', 52) : ("TIPO", 2),
	('r', 53) : ("TIPO_C_RETORNO", 2),
	('r', 54) : ("TIPO_C_RETORNO", 2),
	('r', 55) : ("TIPO_C_RETORNO", 2),
	('r', 56) : ("STEATMENT", 4),
	('r', 57) : ("STEATMENT", 4),
	('r', 58) : ("STEATMENT", 4),
	('r', 59) : ("STEATMENT", 4),
	('r', 60) : ("STEATMENT", 4),
	('r', 61) : ("STEATMENT", 6),
	('r', 62) : ("STEATMENT", 6),
	('r', 63) : ("STEATMENT", 8),
	('r', 64) : ("STEATMENT", 6), 
	('r', 65) : ("STEATMENT", 2),
	('r', 66) : ("STEATMENT", 2),
	('r', 67) : ("STEATMENT", 2),
	('r', 68) : ("STEATMENT", 2),
	('r', 69) : ("STEATMENT", 2),
	('r', 70) : ("STEATMENT", 4),
	('r', 71) : ("STEATMENT", 4),
	('r', 72) : ("STEATMENT", 6),
	('r', 73) : ("STEATMENT", 4),
	('r', 74) : ("DECLARACOES", 4),
	('r', 75) : ("DECLARACOES", 2),
	('r', 76) : ("DEC", 6),
	('r', 77) : ("DEC", 10),
	('r', 78) : ("DEC", 12),
	('r', 79) : ("ATRIB", 8),
	('r', 80) : ("ATRIB", 14),
	('r', 81) : ("CHAMADA_FUNC", 8),
	('r', 82) : ("CHAMADA_FUNC", 6),
	('r', 83) : ("LISTA_PRO", 4),
	('r', 84) : ("LISTA_PRO", 2),
	('r', 85) : ("PROTOTIPO", 12),
	('r', 86) : ("PROTOTIPO", 10),
	('r', 87) : ("FUNCOES", 4),
	('r', 88) : ("FUNCOES", 2),
	('r', 89) : ("LISTA_VARS", 6),
	('r', 90) : ("LISTA_VARS", 2),
	('r', 91) : ("VARS", 4),
	('r', 92) : ("VARS", 8),
	('r', 93) : ("FUNCAO", 14),
	('r', 94) : ("FUNCAO", 16),
	('r', 95) : ("FUNCAO", 18),
	('r', 96) : ("FUNCAO", 16),
	('r', 97) : ("FUNCAO", 12),
	('r', 98) : ("FUNCAO", 14),
	('r', 99) : ("FUNCAO", 16),
	('r', 100) : ("FUNCAO", 14),
	('r', 101) : ("PRINCIPAL", 12),
	('r', 102) : ("PRINCIPAL", 16),
	('r', 103) : ("PRINCIPAL", 14),
	('r', 104) : ("PRINCIPAL", 14)
}

goto = {
	(0, "PROGRAMA") : ('t',1),
	(93, "EXP_COMP") : ('t',124),
	(94,"EXP_COMP") :('t',132),
	(130, "EXP_COMP"): ('t',160),
	(93, "W") : ('t',125),
	(94, "W") : ('t',125),
	(130,"W") : ('t',125),
	(157, "W") : ('t',183),
	(93, "Y") : ('t',126),
	(94, "Y") :	('t',126),
	(127, "Y") : ('t',159),
	(130, "Y") : ('t',126),
	(157, "Y") : ('t',126),
	(158, "Y") : ('t',184),
	(93, "X") : ('t',128),
	(94, "X") :	('t',128),
	(127, "X") : ('t',128),
	(130, "X") : ('t',128),
	(157, "X") : ('t',128),
	(158, "X") : ('t',128),
	(93, "EXP_REL") : ('t',129),
	(94, "EXP_REL") : ('t',129),
	(127, "EXP_REL") : ('t',129),	
	(130, "EXP_REL") : ('t',129),
	(157, "EXP_REL") : ('t',129),
	(158, "EXP_REL") : ('t',129),
	(50, "E") : ('t',82),
	(77, "E") :	('t',110),
	(86, "E") :	('t',119),
	(93, "E") :	('t',131),
	(94, "E") :	('t',131),
	(96, "E") :	('t',134),
	(97, "E") :	('t',136),
	(98, "E") :	('t',137),
	(99, "E") :	('t',141),
	(120, "E") : ('t',153),
	(122, "E") : ('t',154),
	(123, "E") : ('t',155),
	(127, "E") : ('t',131),
	(130, "E") : ('t',161),
	(157, "E") : ('t',131),
	(158, "E") : ('t',131),
	(162, "E") : ('t',186),
	(171, "E") : ('t',189),
	(177, "E") : ('t',141),
	(192, "E") : ('t',200),
	(50, "T") : ('t',83),
	(77, "T") :	('t',83),	
	(86, "T") :	('t',83),
	(93, "T") :	('t',83),
	(94, "T") :	('t',83),
	(96, "T") :	('t',83),
	(97, "T") :	('t',83),
	(98, "T") :	('t',83),
	(99, "T") :	('t',83),
	(113, "T") : ('t',147),
	(114, "T") : ('t',148),
	(120, "T") : ('t',83),
	(122, "T") : ('t',83),
	(123, "T") : ('t',83),
	(127, "T") : ('t',83),
	(130, "T") : ('t',83),
	(157, "T") : ('t',83),
	(158, "T") : ('t',83),
	(162, "T") : ('t',83),
	(171, "T") : ('t',83),
	(177, "T") : ('t',83),	
	(192, "T") : ('t',83),
	(50, "F") :	('t',84),
	(77, "F") :	('t',84),	
	(85, "F") :	('t',118),
	(86, "F") :	('t',84),	
	(93, "F") :	('t',84),
	(94, "F") :	('t',84),
	(96, "F") :	('t',84),
	(97, "F") :	('t',84),
	(98, "F") :	('t',84),
	(99, "F") :	('t',84),
	(113, "F") : ('t',84),
	(114, "F") : ('t',84),
	(115, "F") : ('t',149),
	(116, "F") : ('t',150),
	(117, "F") : ('t',151),
	(120, "F") : ('t',84),
	(122, "F") : ('t',84),
	(123, "F") : ('t',84),
	(127, "F") : ('t',84),
	(130, "F") : ('t',84),
	(157, "F") : ('t',84),
	(158, "F") : ('t',84),
	(162, "F") : ('t',84),
	(171, "F") : ('t',84),
	(177, "F") : ('t',84),
	(192, "F") : ('t',84),
	(99, "LISTA_ARIT") : ('t',138),
	(177, "LISTA_ARIT") : ('t',193),
	(99, "EXP_ARIT_AUX") : ('t',140),
	(177, "EXP_ARIT_AUX") : ('t',140),
	(131, "OP_SIMB") : ('t',162),
	(161, "OP_SIMB") : ('t',162),	
	(33, "IF") : ('t',44),
	(36, "IF") : ('t',44),
	(41, "IF") : ('t',44),
	(42, "IF") : ('t',71),
	(62, "IF") : ('t',44),	
	(64, "IF") : ('t',44),
	(65, "IF") : ('t',71),
	(68, "IF") : ('t',71),
	(101, "IF") : ('t',44),
	(102, "IF") : ('t',71),
	(104, "IF") : ('t',71),
	(143, "IF") : ('t',71),
	(182, "IF") : ('t',44),
	(187, "IF") : ('t',44),
	(196, "IF") : ('t',71),	
	(198, "IF") : ('t',71),
	(207, "IF") : ('t',44),
	(211, "IF") : ('t',71),
	(195, "ELSE") :	('t',201),
	(203, "ELSE") :	('t',208),
	(33, "REP") : ('t',45),	
	(36, "REP") : ('t',45),	
	(41, "REP") : ('t',45),
	(42, "REP") : ('t',72),	
	(62, "REP") : ('t',45),
	(64, "REP") : ('t',45),
	(65, "REP") : ('t',72),
	(68, "REP") : ('t',72),
	(101, "REP") : ('t',45),
	(102, "REP") : ('t',72),
	(104, "REP") : ('t',72),
	(143, "REP") : ('t',72),
	(182, "REP") : ('t',45),
	(187, "REP") : ('t',45),
	(196, "REP") : ('t',72),
	(198, "REP") : ('t',72),
	(207, "REP") : ('t',45),
	(211, "REP") : ('t',72),
	(33, "LEI")	: ('t',46),
	(36, "LEI")	: ('t',46),
	(41, "LEI")	: ('t',46),
	(42, "LEI")	: ('t',73),
	(62, "LEI")	: ('t',46),
	(64, "LEI")	: ('t',46),
	(65, "LEI")	: ('t',73),	
	(68, "LEI")	: ('t',73),
	(101, "LEI") : ('t',46),
	(102, "LEI") : ('t',73),
	(104, "LEI") : ('t',73),
	(143, "LEI") : ('t',73),
	(182, "LEI") : ('t',46),
	(187, "LEI") : ('t',46),
	(196, "LEI") : ('t',73),
	(198, "LEI") : ('t',73),
	(207, "LEI") : ('t',46),
	(211, "LEI") : ('t',73),
	(33, "ESCR") : ('t',47),
	(36, "ESCR") :	('t',47),
	(41, "ESCR") :	('t',47),
	(42, "ESCR") :	('t',74),
	(62, "ESCR") :	('t',47),
	(64, "ESCR") :	('t',47),
	(65, "ESCR") :	('t',74),
	(68, "ESCR") :	('t',74),
	(101, "ESCR") :	('t',47),
	(102, "ESCR") :	('t',74),
	(104, "ESCR") :	('t',74),
	(143, "ESCR") :	('t',74),
	(182, "ESCR") :	('t',47),
	(187, "ESCR") :	('t',47),
	(196, "ESCR") :	('t',74),
	(198, "ESCR") :	('t',74),
	(207, "ESCR") :	('t',47),
	(211, "ESCR") :	('t',74),
	(0, "TIPO") : ('t', 8),
	(2, "TIPO") : ('t', 8),
	(3, "TIPO") : ('t',17),	
	(12, "TIPO") : ('t',17),
	(23, "TIPO") : ('t',29),
	(24, "TIPO") : ('t',29),
	(37, "TIPO") : ('t',29),		
	(33, "TIPO_C_RETORNO") : ('t',52),
	(36, "TIPO_C_RETORNO") : ('t',52),
	(43, "TIPO_C_RETORNO") : ('t',52),
	(62, "TIPO_C_RETORNO") : ('t',52),
	(33, "STEATMENT") :	('t',42),
	(36, "STEATMENT") :	('t',65),
	(41, "STEATMENT") :	('t',68),
	(62, "STEATMENT") :	('t',102),	
	(64, "STEATMENT") :	('t',104),
	(101, "STEATMENT") : ('t',143),
	(182, "STEATMENT") : ('t',196),
	(187, "STEATMENT") : ('t',198),
	(207, "STEATMENT") : ('t',211),
	(33, "DECLARACOES") : ('t',41),	
	(36, "DECLARACOES") : ('t',64),
	(43, "DECLARACOES") : ('t',79),
	(62, "DECLARACOES") : ('t',101),
	(33, "DEC") : ('t',43),
	(36, "DEC") : ('t',43),
	(43, "DEC") : ('t',43),
	(62, "DEC") : ('t',43),
	(33, "ATRIB") :	('t',48),
	(36, "ATRIB") :	('t',48),
	(41, "ATRIB") :	('t',48),
	(42, "ATRIB") :	('t',75),
	(62, "ATRIB") :	('t',48),
	(64, "ATRIB") :	('t',48),
	(65, "ATRIB") :	('t',75),
	(68, "ATRIB") :	('t',75),
	(101, "ATRIB") : ('t',48),
	(102, "ATRIB") : ('t',75),
	(104, "ATRIB") : ('t',75),
	(143, "ATRIB") : ('t',75),
	(182, "ATRIB") : ('t',48),
	(187, "ATRIB") : ('t',48),
	(196, "ATRIB") : ('t',75),
	(198, "ATRIB") : ('t',75),
	(207, "ATRIB") : ('t',48),	
	(211, "ATRIB") : ('t',75),
	(33, "CHAMADA_FUNC") : ('t',51),	
	(36, "CHAMADA_FUNC") : ('t',51),
	(41, "CHAMADA_FUNC") : ('t',51),
	(42, "CHAMADA_FUNC") : ('t',78),
	(50, "CHAMADA_FUNC") : ('t',88),
	(62, "CHAMADA_FUNC") : ('t',51),
	(64, "CHAMADA_FUNC") : ('t',51),
	(65, "CHAMADA_FUNC") : ('t',78),
	(68, "CHAMADA_FUNC") : ('t',78),
	(77, "CHAMADA_FUNC") : ('t',88),
	(85, "CHAMADA_FUNC") : ('t',88),
	(86, "CHAMADA_FUNC") : ('t',88),
	(93, "CHAMADA_FUNC") : ('t',88),
	(94, "CHAMADA_FUNC") : ('t',88),
	(96, "CHAMADA_FUNC") : ('t',88),
	(97, "CHAMADA_FUNC") : ('t',88),
	(98, "CHAMADA_FUNC") : ('t',88),
	(99, "CHAMADA_FUNC") : ('t',88)	,
	(101, "CHAMADA_FUNC") : ('t',51),
	(102, "CHAMADA_FUNC") :	('t',78),
	(104, "CHAMADA_FUNC") :	('t',78),
	(113, "CHAMADA_FUNC") :	('t',88),
	(114, "CHAMADA_FUNC") :	('t',88),
	(115, "CHAMADA_FUNC") :	('t',88),
	(116, "CHAMADA_FUNC") :	('t',88),
	(117, "CHAMADA_FUNC") :	('t',88),
	(120, "CHAMADA_FUNC") :	('t',88),
	(122, "CHAMADA_FUNC") :	('t',88),
	(123, "CHAMADA_FUNC") :	('t',88),
	(127, "CHAMADA_FUNC") :	('t',88),
	(130, "CHAMADA_FUNC") :	('t',88),
	(143, "CHAMADA_FUNC") :	('t',78),
	(157, "CHAMADA_FUNC") :	('t',88),
	(158, "CHAMADA_FUNC") :	('t',88),
	(162, "CHAMADA_FUNC") :	('t',88),
	(171, "CHAMADA_FUNC") :	('t',88),
	(177, "CHAMADA_FUNC") :	('t',88),
	(182, "CHAMADA_FUNC") :	('t',51),
	(187, "CHAMADA_FUNC") :	('t',51),
	(192, "CHAMADA_FUNC") :	('t',88),
	(196, "CHAMADA_FUNC") :	('t',78),
	(198, "CHAMADA_FUNC") :	('t',78),
	(207, "CHAMADA_FUNC") :	('t',51),
	(211, "CHAMADA_FUNC") :	('t',78),
	(0, "LISTA_PRO") : ('t',2),
	(0, "PROTOTIPO") : ('t',5),
	(2, "PROTOTIPO") : ('t',14),
	(0, "FUNCOES") : ('t',3),	
	(2, "FUNCOES") : ('t',12),
	(23, "LISTA_VARS") : ('t',26),
	(24, "LISTA_VARS") : ('t',31),
	(37, "LISTA_VARS") : ('t',66),
	(23, "VARS") :	('t',28),
	(24, "VARS") :	('t',28),
	(37, "VARS") :	('t',28),
	(0, "FUNCAO") :	('t',6),
	(2, "FUNCAO") :	('t',6),
	(3, "FUNCAO") :	('t',16),
	(12, "FUNCAO") : ('t',16),
	(0, "PRINCIPAL") : ('t',4),
	(2, "PRINCIPAL") : ('t',13),
	(3, "PRINCIPAL") : ('t',15),
	(12, "PRINCIPAL") :	('t',20),
}
#------------------------------------------------------------------------------------------------------------------------------------------DICIONÁRIOS------------------------------------------------------------------------------------------------------------------------------------------

#Função de aspas duplas
def AspasDuplas(indice, linha, coluna):
	
	linha_aux = 0
	coluna_aux = 0
	
	if (indice == len(buffer) - 1): 
		return False, indice, linha, coluna, False
		
	indice += 1 #já li 1, posso ler + 128
	coluna += 1
	
	contador_aspas = 1
	Ultimo_eh_barra_n = False
	Encontrei = False
	Final_Arquivo = False
	
	while (contador_aspas != 130): # 
		
		if (buffer[indice] == '"'):
			Encontrei = True
			break
		
		if (indice == len(buffer) - 1): 
			Final_Arquivo = True
			break
		
		if (buffer[indice] == '\n' and contador_aspas == 129): #um barra n na última posição
			indice += 1
			coluna += 1
			break 
		
		if (buffer[indice] == '\n' and contador_aspas != 128):
			linha += 1
			coluna = 0
			
		if (buffer[indice] == '\n' and contador_aspas == 128):
			Ultimo_eh_barra_n = True
			linha_aux = linha
			coluna_aux = coluna
			linha += 1
			coluna = 0
			
		contador_aspas += 1
		indice += 1
		coluna += 1
			
	if (Encontrei == False and Final_Arquivo == True): #caso em que o arquivo acabou e não encontrou uma aspas
		return False, indice , linha, coluna, False
			
	if (Encontrei == False and Ultimo_eh_barra_n == False): #caso em que não encontra uma " para fechar
		return False, indice - 2, linha, coluna - 2, False
		
	if (Encontrei == False and Ultimo_eh_barra_n == True): #caso em que o último caractere é um \n e não acha
		#print "caso 3"
		return False, indice - 2, linha_aux, coluna_aux, True #Este True é só neste caso
		
	if (Encontrei == True): #caso em que encontra uma "
		return True, indice, linha, coluna, False


#Função de aspas simples
def AspasSimples(indice, linha, coluna):
	
	if (indice == len(buffer) - 1):
		return False, indice, linha, coluna
		
	indice += 1
	coluna += 1
		
	if (buffer[indice] == "'"): #caso '' ---> 1 1, 1 2 .... da erro no anterior porque já leu uma aspas, incrementa a coluna e o indice da erro dnv pq dps é eof
		return False, indice - 1, linha, coluna - 1 #verificar o return do indice

	if (buffer[indice] != "'" and indice == len(buffer) - 1): #caso 'a #erro dps do a que é eof
		return False, indice - 1, linha, coluna #acho que coluna - 1 também

	if (buffer[indice] == '\n' and buffer[indice + 1] != "'"): #caso '\nW
		return False, indice - 1, linha, coluna

	if (buffer[indice] != '\n' and buffer[indice] != "'" and buffer[indice + 1] != "'"): #caso 'ab
		return False, indice, linha, coluna 

	if (buffer[indice] == '\n' and buffer[indice + 1] == "'"): #caso '\n'
		linha += 1
		coluna = 1
		return True, indice + 1, linha, coluna #return True, indice + 1, linha, coluna

	if (buffer[indice] != "'" and buffer[indice + 1] == "'"): #caso 'a'
		return True, indice + 1, linha, coluna + 1

	
#Função de letras	
def le_char(indice, linha, coluna): 

	if (buffer[indice].isalpha() or buffer[indice] == '_'): #lê letra ou _
		return True, indice, linha, coluna
	
	if (buffer[indice].isdigit()): #lê numero
		return True, indice, linha, coluna
		
	if (buffer[indice] in permitidos): #lê algum operador 
		contador_letra = 0
		return True, indice, linha, coluna 	
		
	if (buffer[indice] == '.'): #lê um ponto, dá erro numa casa antes
		return False, indice, linha, coluna	
		
	if (buffer[indice] != '!' and buffer[indice] not in permitidos): #se não for uma ! e não estiver em simbolos permitidos lê simbolo nao permitido, dá erro nessa casa
		return False, indice, linha, coluna	
		
	if (indice == len(buffer) - 1):	#se for a última posição e for um !
		return False, indice, linha, coluna
		
	if (buffer[indice + 1] == '='): #não é a última posição como visto acima, no último if, então posso olhar a próxima
		contador_letra = 0
		return True, indice + 1, linha, coluna + 1
		
	if (buffer[indice + 1] != '='): #tem que dar erro nela pois não achou um =
		return False, indice, linha, coluna	
	
#Função de inteiros
def le_inteiro(indice, linha, coluna): #o último retorno True é se for um real
	
	if (buffer[indice].isdigit()): #lê numero
		return True, indice, linha, coluna, False
		
	if (buffer[indice] in permitidos): #lê algum operador ##################################REVER##################################
		contador_inteiro = 0
		return True, indice, linha, coluna, False	
		
	if (buffer[indice] == '.'): #lê '.' e vira um real
		return True, indice, linha, coluna, True	
	
	if (buffer[indice].isalpha() or buffer[indice] == '_'): #lê letra ou _, dá erro uma casa antes
		return False, indice - 1, linha, coluna - 1, False
		
	if (buffer[indice] != '!' and buffer[indice] not in permitidos): #lê simbolo nao permitido, dá erro nessa casa
		return False, indice, linha, coluna, False
		
	if (indice == len(buffer) - 1):	#se for a última posição e for um !
		return False, indice, linha, coluna, False
		
	if (buffer[indice + 1] == '='): #não é a última posição como visto acima, no último if, então posso olhar a próxima
		contador_inteiro = 0
		return True, indice + 1, linha, coluna + 1, False
		
	if (buffer[indice + 1] != '='): #tem que dar erro nela pois não achou um =
		return False, indice, linha, coluna, False
	
	
#Função de reais
def le_real(indice, linha, coluna): # o último retorno do True é apenas para tratamento de 7..

	if (buffer[indice].isdigit()): #lê numero
		return True, indice, linha, coluna, False
		
	if (buffer[indice] in permitidos): #lê algum operador ##################################REVER##################################
		contador_real = 0
		contador_inteiro = 0
		return True, indice, linha, coluna, False	
		
	if (buffer[indice] == '.' and Real_ponto == False): #lê um ponto, é de boa
		return True, indice, linha, coluna, True		
		
	if (buffer[indice] == '.' and Real_ponto == True): #lê outro . ...dá erro uma casa antes
		return False, indice - 1, linha, coluna - 1, True	
	
	if (buffer[indice].isalpha() or buffer[indice] == '_'): #lê letra ou _, dá erro uma casa antes
		return False, indice - 1, linha, coluna - 1, False
		
	if (buffer[indice] != '!' and buffer[indice] not in permitidos): #lê simbolo nao permitido, dá erro nessa casa
		return False, indice, linha, coluna, False
		
	if (indice == len(buffer) - 1):	#se for a última posição e for um !
		return False, indice, linha, coluna, False
		
	if (buffer[indice + 1] == '='): #não é a última posição como visto acima, no último if, então posso olhar a próxima
		contador_real = 0
		contador_inteiro = 0
		return True, indice + 1, linha, coluna + 1, False
		
	if (buffer[indice + 1] != '='): #tem que dar erro nela pois não achou um =
		return False, indice, linha, coluna, False
			
	
def retornaTipoToken(elemento):

	if (elemento == '\n'): #Quebra linha
		return "quebraLinha"
		
	if (elemento == '"'):
		return "AspasDuplas"
		
	if (elemento == "'"):
		return "AspasSimples"
		
	if (elemento in "><[]{}(),;"):
		return "delimitadores"
	
	if (elemento == "="):
	    return "atribuicao"
		
	if (elemento in "+-/*%"):
		return "operadores"
		
	if (elemento == chr(9) or elemento == chr(10) or elemento == chr(32)):
		return "controle"	
		
	if ((elemento.isalpha() or elemento == '_') and Estado_Inteiro == False and Estado_Real == False): #Lê letras ou _ no estado letra
		return "letra"
		
	if (elemento.isdigit() and Estado_Letra == True): #Lê inteiros no estado letra
		return "letra"
		
	if (elemento == '.' and Estado_Letra == True): #Vai dar erro a ser tratado na função de letras
		return "letra"	
	
	if (elemento.isdigit() and Estado_Letra == False and Estado_Real == False): #Posso ler inteiros
		return "inteiro"
	
	if ((elemento.isalpha() or elemento == '_') and Estado_Inteiro == True): #Vai dar erro a ser tratado na função de inteiros
		return "inteiro"
		
	if (elemento.isdigit() and Estado_Letra == False and Estado_Real == True): #Posso ler inteiros
		return "real"	
	
	if (elemento == '.' and Estado_Inteiro == True): #Muda para estado real
		return "real"
		
	if (elemento == '.' and Estado_Real == True): #É pra dar erro lá no tratamento de real lendo o segundo ponto
		return "real"
		
	if ((elemento.isalpha() or elemento == '_') and Estado_Inteiro == False and Estado_Real == True): #Lê letras ou _ no estado real
		return "real"	
		
	if (elemento == '.'): #É pra dar erro de simbolo nao permitido
		return "nao_permitidos"	
		
	if (elemento is '!'): #Não está em nenhum estado e é exclamação
		return "exclamacao"	
		
	if (elemento not in permitidos and elemento is not '!'): #É pra dar erro de simbolo nao permitido porque não é nem . nem !
		return "nao_permitidos"	
	

#Variáveis principais
linha = 1
coluna = 0
indice = 0

#Variável responsável por ativar print de erro
qtd_erros = 0

#Variáveis de Contadores
contador_letra = 0
contador_inteiro = 0
contador_real = 0

#Booleanos para tratamento de aspas duplas
Sem_Erro_Aspas_Duplas = False
Ultimo_eh_barra_n = False

#Booleanos para tratamento de aspas simples
Sem_Erro_Aspas_Simples = False

#Booleanos para tratamento de letras
Estado_Letra = False
Erro_letra = False

#Booleanos para tratamento inteiros
Estado_Inteiro = False
Erro_inteiro = False
Reseta_inteiro = False #rever se precisa
Muda_int_Real = False

#Booleanos para tratamento de real
Estado_Real = False
Erro_real = False
Real_ponto = False


while (indice < len(buffer)):
	
	coluna += 1
	token = retornaTipoToken(buffer[indice])
	
	#print buffer[indice], tipo_token_anterior, token
	
	if (tipo_token_anterior != token):
		
	   #print "caiu aqui", token, tipo_token_anterior
	    
	   if (tipo_token_anterior is "letra"):
		    if (cadeia in reservadas):
			    tokens.append(cadeia)
			    tipo_tokens.append(cadeia) #"reservadas"
			    
		    if (cadeia not in reservadas):
		    	if (cadeia != ""):
			    	tokens.append("id")
			    	tipo_tokens.append("id")
		    	
		    cadeia = ""
	        
	   if (tipo_token_anterior is "inteiro"):
	   		if (token is not "real" or token is not "operadores" or token is not "delimitadores" or token is not "controle"):
	   			#print "AQUI", buffer[indice], token
	   			if (cadeia != ""):
					tokens.append("numero")
					tipo_tokens.append("numero")
					cadeia = ""
	        
	   if (tipo_token_anterior is "real"):
	   		if (token is not "controle"): #token is not "operadores" or token is not "delimitadores" or token is not "controle"
	   			if (cadeia != ""):
		   			tokens.append("numero")
					tipo_tokens.append("numero")
					cadeia = ""
	
	if (token is "quebraLinha"):
		linha += 1
		coluna = 0
		token = "controle"
		
	if (token is "atribuicao"):
	    if (indice == len(buffer) - 1):
		    token = "atribuicao"
	    else:
		    if (buffer[indice + 1] == '='):
		        indice += 1
		        coluna += 1
		        tokens.append("==")
		        tipo_tokens.append("comparacao")
		        cadeia = ""
		        token = "controle"
		    else:
		        token = "atribuicao"	
		
	if (token is "exclamacao"):

		if (indice == len(buffer) - 1):
			token = "nao_permitidos"
		else:
			if (buffer[indice + 1] == '='):
				indice += 1
				coluna += 1
				tokens.append("!=")
				tipo_tokens.append("comparacao")
				cadeia = ""
				token = "controle"
			else:
				token = "nao_permitidos"	
		
	if (token is "AspasDuplas"):
		
		tipo_token_anterior = token
		
		antes = indice
		Sem_Erro_Aspas_Duplas, indice, linha, coluna, Ultimo_eh_barra_n = AspasDuplas(indice, linha, coluna) #, eh_barra_n]
		depois = indice
		
		if (Sem_Erro_Aspas_Duplas == False):
			qtd_erros += 1
			print linha, coluna
			
		if (Ultimo_eh_barra_n == True): #ACHO QUE NÃO PRECISA DAQUI PQ EU INCREMENTO LINHA E COLUNA... DPS na próxima chamada do índice leio outra quebra de linha e faço novamente
			linha += 1
			coluna = 0
			
		if (Sem_Erro_Aspas_Duplas == True):
		    cadeia = buffer[antes:(depois + 1)]
		    cadeia = ''.join(cadeia)
		    tokens.append("string") #colocar um print na linha anterior para aver o conteúdo de cadeia
	        tipo_tokens.append("string")
			
		token = "controle"

	if (token is "AspasSimples"):
		
		tipo_token_anterior = token
		
		antes = indice
		Sem_Erro_Aspas_Simples, indice, linha, coluna = AspasSimples(indice, linha, coluna)
		depois = indice
	
		if (Sem_Erro_Aspas_Simples == False):
			qtd_erros += 1
			print linha, coluna	
			
		if (Sem_Erro_Aspas_Simples == True):
		    cadeia = buffer[antes:(depois + 1)]
		    cadeia = ''.join(cadeia)
		    tokens.append("char") #colocar um print na linha anterior para aver o conteúdo de cadeia
	        tipo_tokens.append("char")
			
		token = "controle"
	
	if (token is "letra"):
	
		tipo_token_anterior = token
		cadeia = cadeia + buffer[indice]
			
		Estado_Letra = True
		contador_letra += 1

		if (contador_letra == 129):
			qtd_erros += 1
			coluna -= 1
			indice -= 1
			print linha, coluna
			token = "controle"
			
		else:
			Erro_letra, indice, linha, coluna = le_char(indice, linha, coluna)

			if (Erro_letra == False):
				qtd_erros += 1
				print linha, coluna
				token = "controle"
				
	if (token is "inteiro"):
		
		tipo_token_anterior = token
		cadeia = cadeia + buffer[indice]
		
		Estado_Inteiro = True
		contador_inteiro += 1

		if (contador_inteiro == 129):
			qtd_erros += 1
			coluna -= 1
			indice -= 1
			print linha, coluna
			token = "controle"

		else:
			Erro_inteiro, indice, linha, coluna, Muda_int_Real = le_inteiro(indice, linha, coluna)

			if (Erro_inteiro == False):
				qtd_erros += 1
				print linha, coluna
				token = "controle"
				
			if (Muda_int_Real == True): #print "MUDA ESTADO", Estado_Inteiro ACHO QUE NÃO ESTÁ CAINDO AQUI E VER TB NA FUNÇÃO DE REAL SE PRECISA DO if (buffer[indice] == '.'):
				contador_inteiro = 0
				Estado_Inteiro = False
				Estado_Real = True
	
	if (token is "real"):
		
		tipo_token_anterior = token
		cadeia = cadeia + buffer[indice]
		
		Estado_Inteiro = False
		Estado_Real = True #acho que não precisa visto que no tratamento do inteiro eu mudo pra real
		contador_inteiro += 1 #contador_inteiro

		if (contador_inteiro == 129): #contador_inteiro
			qtd_erros += 1
			coluna -= 1
			indice -= 1
			print linha, coluna
			token = "controle"
			
		else:
			Erro_real, indice, linha, coluna, Real_ponto = le_real(indice, linha, coluna)

			if (Erro_real == False):
				qtd_erros += 1
				print linha, coluna
				token = "controle"
				
			if (Erro_real == False and Real_ponto == True): #se tiver erro e se ler mais um ponto
				Real_ponto = False
	
	if (token is "nao_permitidos"):
		qtd_erros += 1
		print linha, coluna
		token = "controle"
	
	if (token is "atribuicao"): 
		if (tipo_token_anterior is not "atribuicao"):
			tokens.append("=")
			tipo_tokens.append("atribuicao")
	    
	if (token is "operadores"): #+-/*% #----------------------
		
		if (buffer[indice] == '+'):
			tokens.append(buffer[indice])
			tipo_tokens.append("op_soma")
			tipo_token_anterior = "operadores"
		
		if (buffer[indice] == '-'):
			tokens.append(buffer[indice])
			tipo_tokens.append("op_subt")
			tipo_token_anterior = "operadores"
			
		if (buffer[indice] == '/'):
			tokens.append(buffer[indice])
			tipo_tokens.append("op_div")
			tipo_token_anterior = "operadores"
			
		if (buffer[indice] == '*'):
			tokens.append(buffer[indice])
			tipo_tokens.append("op_mult")
			tipo_token_anterior = "operadores"
			
		if (buffer[indice] == '%'):
			tokens.append(buffer[indice])
			tipo_tokens.append("op_mod")
			tipo_token_anterior = "operadores"
		
		cadeia = ""	
		Estado_Letra = False
		Estado_Inteiro = False
		Estado_Real = False
		Real_ponto = False
		contador_letra = 0
		contador_inteiro = 0
		contador_real = 0	
	    
	if (token is "delimitadores"): #><[]{}(),; #----------------------
		if (buffer[indice] == '>'):
			if (indice == len(buffer) - 1):
				tokens.append(">")
				tipo_tokens.append("de_maior")
				tipo_token_anterior = "delimitadores"
			if (indice != len(buffer) - 1):
				if (buffer[indice + 1] == '='):
					indice += 1
					coluna += 1
					tokens.append(">=")
					tipo_tokens.append("de_maior_igual")
					tipo_token_anterior = "delimitadores"
				else:
					tokens.append(">")
					tipo_tokens.append("de_maior")
					tipo_token_anterior = "delimitadores"
		
		if (buffer[indice] == '<'):
			if (indice == len(buffer) - 1):
				tokens.append("<")
				tipo_tokens.append("de_menor")
				tipo_token_anterior = "delimitadores"
			if (indice != len(buffer) - 1):
				if (buffer[indice + 1] == '='):
					indice += 1
					coluna += 1
					tokens.append("<=")
					tipo_tokens.append("de_menor_igual")
					tipo_token_anterior = "delimitadores"
				else:
					tokens.append("<")
					tipo_tokens.append("de_menor")
					tipo_token_anterior = "delimitadores"
			
		if (buffer[indice] == '['):
			tokens.append(buffer[indice])
			tipo_tokens.append("de_ab_coche")
			tipo_token_anterior = "delimitadores"
			
		if (buffer[indice] == ']'):
			tokens.append(buffer[indice])
			tipo_tokens.append("de_fe_coche")
			tipo_token_anterior = "delimitadores"
			
		if (buffer[indice] == '{'):
			tokens.append(buffer[indice])
			tipo_tokens.append("de_ab_cha")
			tipo_token_anterior = "delimitadores"
			
		if (buffer[indice] == '}'):
			tokens.append(buffer[indice])
			tipo_tokens.append("de_fe_cha")
			tipo_token_anterior = "delimitadores"
			
		if (buffer[indice] == '('):
			tokens.append(buffer[indice])
			tipo_tokens.append("de_ab_par")
			tipo_token_anterior = "delimitadores"
			
		if (buffer[indice] == ')'):
			tokens.append(buffer[indice])
			tipo_tokens.append("de_fe_par")
			tipo_token_anterior = "delimitadores"
			
		if (buffer[indice] == ','):
			tokens.append(buffer[indice])
			tipo_tokens.append("de_vir")
			tipo_token_anterior = "delimitadores"
			
		if (buffer[indice] == ';'):
			tokens.append(buffer[indice])
			tipo_tokens.append("de_ponvir")
			tipo_token_anterior = "delimitadores"
		
		cadeia = ""	
		Estado_Letra = False
		Estado_Inteiro = False
		Estado_Real = False
		Real_ponto = False
		contador_letra = 0
		contador_inteiro = 0
		contador_real = 0
	
	if (token is "controle"): #verificar se aqui eu coloco mesmo cadeia = "", pq se o último token for do tipo controle, e zero ela, eu salvaria algo em branco na lista ao acabar de percorrer o buffer
		if (indice + 1 != len(buffer) - 1): #se não for a ultima coisa a ler não zera a cadeia, trata em baixo, a partir das linhas 620...
			cadeia = ""
		Estado_Letra = False
		Estado_Inteiro = False
		Estado_Real = False
		Real_ponto = False
		contador_letra = 0
		contador_inteiro = 0
		contador_real = 0
		
	indice += 1

#if (qtd_erros == 0):
#	print "OK"

estado = 0
pilha = [0]
entrada = []
entrada = tokens
entrada.append("$")
lis = []

while entrada:
    
    chave = entrada[0]
    x = Matriz.get((estado, chave))
    
    if x == None:
        erro_sintatico = True
        break
    elif x == "acc":
        erro_sintatico = False
        break
    elif x[0] == "s":
        a = entrada.pop(0) #retira o primeiro elemento da lista
        pilha.append(a) #empilha na pilha a entrada
        pilha.append(x[1]) #empilha na pilha o valor do novo estado
        estado = x[1]
    elif x[0] == "r":
        y = REDUCE.get(('r', x[1])) #vai retornar uma tupla com 2 valores, 
        emp = y[0] #o que vamos empilhar
        desemp = y[1] #a quantidade de elementos que vamos desempilhar
        while desemp > 0:
        	pilha.pop()
        	desemp -= 1
        pilha.append(emp)
        transicao = goto.get((pilha[-2], pilha[-1])) #uma tupla com 2 valores ('t', estado)
        
        if transicao == None:
        	erro_sintatico = True
        	break
        
        pilha.append(transicao[1])
        estado = transicao[1]
       
if erro_sintatico == True:
	print "NO"
else:
	print "YES"

			