elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: ¿Eres nuevo? ¿Tienes dudas acerca del funcionamiento de la comunidad? Lee las Reglas Generales


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  Interprete
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Interprete  (Leído 1,737 veces)
mapers


Desconectado Desconectado

Mensajes: 638


Ver Perfil
Interprete
« en: 23 Marzo 2011, 07:57 am »

bueanas señores del foro estoy empezando a hacer un pequeño interprete ........lo amlo esque no se porque se salta de la sentencia :
if(frase[patron]=='e' && frase[patron+1]=='l' && frase[patron+2]=='s' && frase[patron+3]=='e' )

justo cunando ingreso 1aelse;
me deve de salir en  pantalla:

identidicador entero else

else e if son palabras reservdas que  de a cuerdo al analisis que le doy me deve ingresar a la comparacion pero no se porqeu no entra en ese ejemplo me sale

identidicador / entero /identificador

no entiendo orque a que se deve a ver denle una ojeada
Código
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. int patron=0;
  5. int i=0,j=0,factor=0;
  6. char frase[100];
  7. //------------------------------------------------------//
  8. void entero();
  9. void identificador();
  10. void entero_identificador();
  11. //------------------------------------------------------//
  12. int main()
  13. {
  14.  
  15. cout<<"ingrese frase "<<endl;
  16. cin>>frase;
  17. int n=strlen(frase);
  18. cout<<endl;
  19. while(n!= patron)
  20.    {
  21.  
  22.       if(frase[patron]==';')
  23.       {
  24.          if(i!=0)
  25.          {
  26.           cout<<"entero "<<"/";
  27.           }
  28.           if(j!=0)
  29.           {
  30.           cout<<"identificador"<<"/";
  31.           }
  32.  
  33.        cin.ignore();
  34.    cin.get ();
  35.  
  36.       }
  37. if(frase[patron]=='i' && frase[patron+1]=='f')
  38. {
  39.                 if(j!=0)
  40.                {
  41.                 cout<<"identificador"<<"/";
  42.                 i=0;
  43.                 j=0;
  44.                 }
  45.  
  46.                if(i!=0)
  47.                {
  48.                 cout<<"entero"<<"/";
  49.                 i=0;
  50.                 j=0;
  51.                 }              
  52. cout<<"if"<<" /";
  53. patron=patron+2;
  54.                  continue;
  55. }
  56.  
  57. if(frase[patron]=='e' && frase[patron+1]=='l' && frase[patron+2]=='s' && frase[patron+3]=='e' )
  58. {    
  59.                if(j!=0)
  60.                {
  61.                 cout<<"identificador "<<"/";
  62.                 i=0;
  63.                 j=0;
  64.                 }
  65.  
  66.                if(i!=0)
  67.                {
  68.                 cout<<"entero "<<"/";
  69.                 i=0;
  70.                 j=0;
  71.                 }
  72.  
  73. cout<<"else"<<" /";
  74. patron=patron+4;
  75. continue;
  76.  
  77. }
  78.  
  79. if(isdigit(frase[patron])!=0)
  80. {
  81. identificador();
  82. patron++;
  83. }
  84. if(isdigit(frase[patron])==0)
  85. {
  86. entero();
  87. patron++;
  88. }
  89.  
  90.  
  91. }
  92.  
  93. }
  94.  
  95. //------------------------------------------------------//
  96. //------------------------------------------------------//
  97.  
  98. void identificador()
  99. {
  100. if(j==0)
  101. {
  102. i++;
  103. }
  104.  
  105. if(j!=0)
  106. {
  107. cout<<"identificador "<<"/";
  108. j=0;
  109. i++;
  110.    }
  111.  
  112.  
  113. }
  114.  
  115. //------------------------------------------------------//
  116. //------------------------------------------------------//
  117. void entero()
  118. {
  119. if(i==0)
  120. {
  121. j++;
  122. }
  123. if(i!=0)
  124. {
  125. cout<<"entero "<<"/";
  126. i=0;
  127. j++;
  128. }
  129. }
  130.  
  131.  


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Interprete de Dos
Programación Visual Basic
Hendrix 2 1,665 Último mensaje 24 Marzo 2006, 15:21 pm
por Hendrix
Interprete VBS
Scripting
Napster.A530 1 3,009 Último mensaje 4 Agosto 2010, 01:17 am
por Novlucker
[Sloth] Psuedo-intérprete (en proceso)
Scripting
»NaSH 0 1,892 Último mensaje 20 Mayo 2013, 11:27 am
por »NaSH
Ayuda - interprete, archivos y sockets..
Programación C/C++
ank3r 0 1,396 Último mensaje 19 Abril 2014, 18:25 pm
por ank3r
[Python] ¿Un cómodo y flexible intérprete?
GNU/Linux
hcaulfield 1 1,671 Último mensaje 21 Junio 2014, 22:33 pm
por JorgeEMX
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines