Documentos de Académico
Documentos de Profesional
Documentos de Cultura
1 Parcial Compiladores 6ta Pregunta - Humberto Orellana
1 Parcial Compiladores 6ta Pregunta - Humberto Orellana
0907 – 19 – 10916
Compiladores
#include <iostream>
using namespace std;
int main ()
{
int contra;
string user;
cout<<"Ingrese el usuario para poder entrar a la BD ";
cin>>user;
cout<<"Ingrese la contraseña ";
cin>>contra;
if(user == "Usuario1" && contra == 1234)
{
cout<<"Bienvenido";
}
else
{
cout<<"Contraseña o usuario inocrrectos";
}
}
1 #include INCLUDE - 1 -
2 <iostream> ID_LIBRERIA Iostream 1 -
3 Using Using - 2 -
4 Namespace NAMESPACE - 2 -
5 Std ID_NAMESPACE Std 2 -
6 ; SIMBOLO_FIN_LÍNEA ; 2 -
7 Int TIPO_DATO Int 3 -
8 Main ID_METODO Main 3 -
9 ( SÍMBOLO_APERTURA_ATRIBUTOS ( 3 -
10 ) SÍMBOLO_CIERRE_ATRIBUTOS ) 3 -
11 { SÍMBOLO_APERTURA_CÓDIGO { 4 -
12 Int TIPO_DATO Int 5 -
13 Contra ID_VARIABLE Contra 5 Int
14 ; SIMBOLO_FIN_LÍNEA ; 5 -
15 String TIPO_DATO String 6 -
16 User ID_VARIABLE User 6 String
Humberto José Orellana Colindres
0907 – 19 – 10916
Compiladores
17 ; SIMBOLO_FIN_LÍNEA ; 6 -
18 Cout ID_SYSTEM_OUTPUT Cout 7 -
19 << ID_SYSTEM_WRITE << 7 -
20 " SIMBOLO_CADENA_DE_TEXTO " 7 -
21 Ingrese el ID_TEXTO Ingrese el 7 String
usuario usuario
para poder para poder
entrar a la entrar a la
BD BD
22 " SIMBOLO_CADENA_DE_TEXTO " 7 -
23 ; SIMBOLO_FIN_LÍNEA ; 7 -
24 Cin ID_SYSTEM_INPUT Cin 8 -
25 >> ID_SYSTEM_RECIBE >> 8 -
26 User ID_VARIABLE User 8 String
27 ; SIMBOLO_FIN_LÍNEA ; 8 -
28 Cout ID_SYSTEM_OUTPUT Cout 9 -
29 << ID_SYSTEM_WRITE << 9 -
30 " SIMBOLO_CADENA_DE_TEXTO " 9 -
31 Ingrese la ID_TEXTO Ingrese la 9 String
contraseña contraseña
32 " SIMBOLO_CADENA_DE_TEXTO " 9 -
33 ; SIMBOLO_FIN_LÍNEA ; 9 -
34 Cin ID_SYSTEM_INPUT Cin 10 -
35 >> ID_SYSTEM_RECIBE >> 10 -
36 Contra ID_VARIABLE Contra 10 Int
37 ; SIMBOLO_FIN_LÍNEA ; 10 -
38 If ID_SYSTEM_CONDITION If 11 -
39 ( SÍMBOLO_APERTURA_ATRIBUTOS ( 11 -
40 User ID_VARIABLE User 11 String
41 == SIMBOLO_IGUALACIÓN == 11 -
42 " SIMBOLO_CADENA_DE_TEXTO " 11 -
47 == SIMBOLO_IGUALACIÓN == 11 -
49 ) SÍMBOLO_CIERRE_ATRIBUTOS ) 11 -
50 { SÍMBOLO_APERTURA_CÓDIGO { 12 -
56 ; SIMBOLO_FIN_LÍNEA ; 13 -
57 } SIMBOLO_CIERRE_CÓDIGO } 14 -
59 { SÍMBOLO_APERTURA_CÓDIGO { 16 -
65 ; SIMBOLO_FIN_LÍNEA ; 17 -
66 } SIMBOLO_CIERRE_CÓDIGO } 18 -
67 } SIMBOLO_CIERRE_CÓDIGO } 19 -
En el círculo verde podemos ver un error semántico, ya que faltan las comillas para que tome que
es una cadena de texto, por lo mismo de que user es una variable de tipo string.
En el círculo rojo es un error de sintaxis, ya que falta un ; para que pueda funcionar.