Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 941489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:07:39+00:00 2026-05-15T22:07:39+00:00

I’m trying to build a simple lexical analyzer to go along with a simple

  • 0

I’m trying to build a simple lexical analyzer to go along with a simple input output library for (scientific) C programs. When compiling with autotools, including automake, libtool, and autoconf, I get the following error:

simpleio_lex.l:41: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘of’

This usually means that I’ve forgotten a semicolon at the end of a function prototype, but I’ve checked my header and there’s no such omission.

Here’s simpleio_lex.l:

%{
int yylex(void);
#define yylex sio_lex
#include "simpleio.h"
%}

NUM [0-9]           /* a number */
FLOAT {NUM}+"."{NUM}*           /* a floating point number */
FLOATSEQ {FLOAT[[:space:]]?}+
FLOATLN ^FLOATSEQ$
SYMBOL [a-z]+           /* a symbol always comes at the
                   beginning of a line */
SYMDEF ^SYMBOL[[:space:]]*FLOAT /* define a single value for a symbol */
RANGE FLOAT":"FLOAT":"FLOAT /* a range of numbers */
SYMRANGE ^SYMBOL[[:space:]]+RANGE$ /* assign a range of values to a symbol */

%%
                /* a set of lines with just numbers
                   indicates we should parse it as data */
{FLOATLN}+ sio_read_stk_inits (yytext);
SYMDEF sio_read_parse_symdef (yytext);
SYMRANGE sio_read_parse_symrange (yytext);
%%

/* might as well define these here */
sio_symdef_t *
sio_read_parse_symdef (char * symdef)
{
  sio_symdef_t * def = malloc (sizeof (sio_symdef_t));
  /* split the string into tokens on the LHS and RHS */
  char * delim = " ";
  char * lvalue = strtok (symdef, delim);
  size_t lsize = sizeof (lvalue);

  char * rest = strtok (NULL, delim);
  double plval;         /* place holder */
  int s_ck = sscanf (rest, "%lg", &plval);
  if (s_ck == EOF)
    return NULL;
  else
    {
    def->value = plval;
    def->name = malloc (lsize);
    memcpy(def->name, lvalue, lsize);
    }
  return def;
}

The *compilation* buffer hyperlink in Emacs refers me to the %}% at the end of the preamble. Why am I getting this error? I have no symbol called “of,” either.

Thanks,

Joel

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T22:07:40+00:00Added an answer on May 15, 2026 at 10:07 pm

    The problem was a dangling comment that I folded onto a line by itself, like this:

    /* this is a comment that's going to run into a 
         new line */
    

    The second line was copied directly into the source, without its comment delimiter. It seems flex is rather picky about comments and formatting. The “of” mentioned in the error message is the first word of the second line of the comment.

    The problem is that I had to look in the derived .c file, not in the .l file where the hyperlink was directing me. This is the transformed source:

    #line 38 "simpleio_lex.l"
    int yylex(void);
    #define yylex sio_lex
    #include <simpleio.h>
    beginning of a line */
    #line 505 "simpleio_lex.c"
    

    From this in the file processed by flex:

    %{
    int yylex(void);
    #define yylex sio_lex
    #include <simpleio.h>
    %}
    
    
    NUM [0-9]           /* a number */
    FLOAT {NUM}+"."{NUM}*           /* a floating point number */
    FLOATSEQ {FLOAT[[:space:]]?}+
    FLOATLN ^FLOATSEQ$
    SYMBOL [a-z]+           /* a symbol always comes at the
                       beginning of a line */
    

    Thanks!
    Joel

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.