kdevelop

This is a discussion on kdevelop within the Linux Programming forums, part of the Platform Specific Boards category; Hi! I'm trying to simulate a sort of terminal simulation ( or command prompt in D.O.S ), so that it ...

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    3

    kdevelop

    Hi!

    I'm trying to simulate a sort of terminal simulation ( or command prompt in D.O.S ), so that it reads commands from the keyboard. Using flex/bison (or lex/yacc) it should recognize commands and run a routine that I coded on another file.

    I'm a complete newbie to linux c programming. I've tried flex/bison and gcc from the terminal and I've been able to run simple analyzers but I'm not sure how to even start with kdevelop, and how to compile everything. Excuse my stupidity but I'm new to the linux world (and so far I like it ).

    I would appreciate a little help just to get started.

    Thanks!


  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    3
    I'm not asking how to use kdevelop I'm asking how to combine lex and yacc with c files to make a command interpreter in kdevelop

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    3
    Following a tutorial on the web got this two files, I compiled them with:

    flex ejemplo2.l
    bison -d ejemplo2.y
    gcc lex.yy.c ejemplo2.tab.c -o ejemplo2
    ../ejemplo2

    This is the source:

    *********** lexfile ****************

    %{
    #include <stdio.h>
    #include "ejemplo2.tab.h"
    %}

    %%

    \n return NL;
    bye|quit|exit return BYE;
    [0-9]+ return NUMBER;
    heat return TOKHEAT;
    on|off return STATE;
    target return TOKTARGET;
    temperature return TOKTEMPERATURE;
    [ \t]+ ; /* Ignora los espacios en blanco */
    ..; /* Reconoce cualquier otra cosa y la ignora */

    %%


    *********** yaccfile ***************

    %{
    #include <stdio.h>
    #include <string.h>

    void yyerror (char *s);

    %}

    %token NUMBER TOKHEAT STATE TOKTARGET TOKTEMPERATURE NL BYE

    %%

    entrada: statement
    | entrada statement
    ;

    statement: NL
    | exp NL
    | BYE NL { printf("Cerrando calculadora...\n");exit(0); }
    ;

    exp: TOKHEAT STATE { printf("\tHeat turned on or off\n"); }
    |
    TOKTARGET TOKTEMPERATURE NUMBER { printf("\tTemperature set to", $3); }
    ;


    %%

    void yyerror (char *s)
    {
    fprintf (stderr, "%s\n", s);
    }

    int yywrap()
    {
    return 1;
    }

    main()
    {
    yyparse();
    }

    *************************************

    And finally my question would be how to put everything on a project plus some more code on another file that my commands (not these commands) would run after reading them.

    So my question is more a Lex Yacc question on Kdevelop.

    Hope that makes it clear,

    Thanks in advance


  4. #4
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    Habla espanol? No se nada de esto, pero, quiero decirle "Hola"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. why can't build project in KDevelop C/C++
    By Lauris in forum Linux Programming
    Replies: 21
    Last Post: 09-04-2007, 11:41 AM
  2. Kdevelop 3.3.2 project problem..
    By BobS0327 in forum Linux Programming
    Replies: 4
    Last Post: 03-14-2006, 07:22 PM
  3. kdevelop
    By octavian in forum Linux Programming
    Replies: 3
    Last Post: 02-18-2006, 11:09 PM
  4. KDevelop questions
    By geek@02 in forum Linux Programming
    Replies: 2
    Last Post: 10-27-2005, 03:46 PM
  5. KDevelop in gnome
    By FillYourBrain in forum Linux Programming
    Replies: 6
    Last Post: 11-12-2002, 08:45 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21