pcboyyyy's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
Active Members
Active Posts:
66 (0.05 per day)
Joined:
29-August 10
Profile Views:
7,033
Last Active:
User is offline Oct 10 2013 09:35 PM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Linux
Favorite Browser:
FireFox
Favorite Processor:
Intel
Favorite Gaming Platform:
PC
Your Car:
Mitsubishi
Dream Kudos:
0

Latest Visitors

Icon   pcboyyyy Help on my Calendar Event thread would be much appreciated.

Posts I've Made

  1. In Topic: *lex-yacc*

    Posted 8 Sep 2013

    View Postsepp2k, on 08 September 2013 - 09:35 AM, said:

    View Postpcboyyyy, on 08 September 2013 - 07:42 AM, said:

    I am not sure how to actually run the program I am trying to create.


    1. Write the lex file.
    2. Use flex to compile the lex file to .c code (flex lexer.l).
    3. Use your C compiler to compile the .c file to an executable (gcc ley.yy.c -o mylexer).
    4. Run the executable (./mylexer).


    What am I getting a premature EOF????

    
    %{
    #include <stdio.h>
    %}
         
             DIGIT    [0-9]
             ID       [a-z][a-z0-9]*
         
             %%
         
             {DIGIT}+    {
                         printf( "An integer: %s (%d)\n", yytext,
                                 atoi( yytext ) );
                         }
         
             if|then|begin|end|procedure|function        {
                         printf( "A keyword: %s\n", yytext );
                         }
         
             {ID}        printf( "An identifier: %s\n", yytext );
         
             "&&" | "||" | "==" | "!=" | "<" | ">" | "<=" | ">=" | "+" | "-" | "*" | "/"   printf( "An operator: %s\n", yytext );
         
             "{"[\^{}}\n]*"}"     /* one-line comments */
         
             [ \t\n]+          /* whitespace */
         
             .           printf( "Unrecognized character: %s\n", yytext );
         
             %%
         
             int main( int argc, char **argv )
                 {
                 ++argv, --argc;  /* skip over program name */
                 if ( argc > 0 )
                         yyin = fopen( argv[0], "r" );
                 else
                         yyin = stdin;
         
                 yylex();
    	     }
    
    
  2. In Topic: *lex-yacc*

    Posted 8 Sep 2013

    View Postsepp2k, on 08 September 2013 - 09:35 AM, said:

    View Postpcboyyyy, on 08 September 2013 - 07:42 AM, said:

    I am not sure how to actually run the program I am trying to create.


    1. Write the lex file.
    2. Use flex to compile the lex file to .c code (flex lexer.l).
    3. Use your C compiler to compile the .c file to an executable (gcc ley.yy.c -o mylexer).
    4. Run the executable (./mylexer).


    Very nice!

    How can I run only the lex file to test it without linking to a C file? Or is that possible?

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Interests:
Engineering, software, hardware, computers, reading, golf, e-commerce, business, networking, retail.
Years Programming:
12
Programming Languages:
VB.NET, C#, C++, C, Java, PHP, CSS, HTML.

Contact Information

E-mail:
Click here to e-mail me

Comments

pcboyyyy has no profile comments yet. Why not say hello?