LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-01-2024, 11:35 AM   #16
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,855

Rep: Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311

obviously make parse does not work, there is a missing r at the end: make parser is the right syntax
 
Old 02-01-2024, 11:57 AM   #17
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,865
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
@OP please go back to post #13 -- that wasn't the actual command and error massage, was it?
 
Old 02-01-2024, 04:55 PM   #18
ajiten
Member
 
Registered: Jun 2023
Posts: 375

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by NevemTeve View Post
@OP please go back to post #13 -- that wasn't the actual command and error massage, was it?
Sorry, the command was wrong. Though, now on (having run the 3 lines of commands in the 'earlier' makefile) the error is not there.
Code:
$ bison -o parser.c -Hparser.h parser.y
$ flex -o lexpars.c lexpars.flex
$ cc -m64 -g -W -Wall -DYYDEBUG -m64 -g -L/usr/local/lib64 -Wl,-rpath,/usr/local/lib64 parser.c lexpars.c   -o parser
parser.y: In function ‘main’:
parser.y:392:9: warning: implicit declaration of function ‘yyset_debug’ [-Wimplicit-function-declaration]
  392 |         yyset_debug(1);
      |         ^~~~~~~~~~~
parser.y:387:9: warning: unused variable ‘token’ [-Wunused-variable]
  387 |     int token = 0;
      |         ^~~~~
lexpars.c:1281:16: warning: ‘input’ defined but not used [-Wunused-function]
 1281 | #else
      |                ^
lexpars.c:1238:17: warning: ‘yyunput’ defined but not used [-Wunused-function]
 1238 |
      |                 ^
And, if run the 'make parser' command, instead get the response.
Code:
$ make parser
make: 'parser' is up to date.
Attached Thumbnails
Click image for larger version

Name:	Screenshot (209).png
Views:	4
Size:	159.5 KB
ID:	42510  

Last edited by ajiten; 02-01-2024 at 11:23 PM.
 
Old 02-02-2024, 12:12 AM   #19
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,865
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Note1: you are allowed to copy+paste the relevant lines from your terminal-window, you don't have to annoy us with screen-shots.

Note2: you might be one 'git pull' late, but that doesn't matter much.

So you have a working executable, and you have the test files so you can try them
Code:
./parser.exe sample01.txt
type_specifier -> INT
type_specifier -> INT
parameter_list -> type_specifier ID
type_specifier -> INT
parameter_list -> parameter_list COMMA type_specifier ID
variable -> ID
factor -> variable
unary_expression -> factor
term -> unary_expression
simple_expression -> term
ADDOP+
variable -> ID
factor -> variable
unary_expression -> factor
term -> unary_expression
simple_expression -> simple_expression ADDOP(+) term
rel_expression  -> simple_expression
expression -> logic_expression
statement -> RETURN expression SEMICOLON
statements -> statement
compound_statement -> LCURL statements RCURL
func_definition -> type_specifier ID LPAREN parameter_list RPAREN compound_statement
program -> unit
start -> program
 
1 members found this post helpful.
Old 02-03-2024, 02:17 AM   #20
ajiten
Member
 
Registered: Jun 2023
Posts: 375

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by NevemTeve View Post
Note1: you are allowed to copy+paste the relevant lines from your terminal-window, you don't have to annoy us with screen-shots.

Note2: you might be one 'git pull' late, but that doesn't matter much.

So you have a working executable, and you have the test files so you can try them
Code:
./parser.exe sample01.txt
type_specifier -> INT
type_specifier -> INT
parameter_list -> type_specifier ID
type_specifier -> INT
parameter_list -> parameter_list COMMA type_specifier ID
variable -> ID
factor -> variable
unary_expression -> factor
term -> unary_expression
simple_expression -> term
ADDOP+
variable -> ID
factor -> variable
unary_expression -> factor
term -> unary_expression
simple_expression -> simple_expression ADDOP(+) term
rel_expression  -> simple_expression
expression -> logic_expression
statement -> RETURN expression SEMICOLON
statements -> statement
compound_statement -> LCURL statements RCURL
func_definition -> type_specifier ID LPAREN parameter_list RPAREN compound_statement
program -> unit
start -> program
Please tell what you expected in the 3 empty header files, in the project, as you have stated in each of them : 'missing file'. The 3 header files are:
1. ScopeTable.h,
2. SymbolInfo.h,
3. SymbolTable.h.

I assume that for the case of the exercise stated earlier, the the second table would have the information given on the page, i.e.:
Code:
#ifndef _SCANTYPE_H_
#define _SCANTYPE_H_
// 
//  SCANNER TOKENDATA
// 
struct TokenData {
    int  tokenclass;        // token class
    int  linenum;           // line where found
    char *tokenstr;         // what string was actually read
    char cvalue;            // any character value
    int  nvalue;            // any numeric value or Boolean value
    char *svalue;           // any string value e.g. an id
};
#endif
Though the header file can be optionally named: Scantype.h, instead to satisfy the naming convention specified by the web-page.

The name of the file lexpars.flex, should be renamed parser.l; accordingly. Though the contents need be mulled by me still.

Last edited by ajiten; 02-03-2024 at 02:28 AM.
 
Old 02-03-2024, 02:59 AM   #21
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,865
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
I really don't understand what are you talking about.

You linked a stackoverflow question: https://stackoverflow.com/questions/...-bison-grammar
That question contains incomplete code, asking for help with debugging.

As you know, only actual executables can be debugged, so I added the missing files.
The result is here: https://github.com/lzsiga/stackoverflow_50821203

And now you bring in some unrelated website I know nothing of.
 
Old 02-03-2024, 03:52 AM   #22
ajiten
Member
 
Registered: Jun 2023
Posts: 375

Original Poster
Rep: Reputation: 4
Quote:
Originally Posted by NevemTeve View Post
I really don't understand what are you talking about.

You linked a stackoverflow question: https://stackoverflow.com/questions/...-bison-grammar
That question contains incomplete code, asking for help with debugging.

As you know, only actual executables can be debugged, so I added the missing files.
The result is here: https://github.com/lzsiga/stackoverflow_50821203

And now you bring in some unrelated website I know nothing of.
Please tell what you expected in the 3 empty header files, in the project, as you have stated in each of them : 'missing file'. The 3 header files are:
1. ScopeTable.h,
2. SymbolInfo.h,
3. SymbolTable.h.
 
Old 02-04-2024, 09:07 AM   #23
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,865
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
You can safely delete these files.
 
  


Reply

Tags
parser



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Realtek rtl8822be blues on the new Lenovos.. Flex 6-ARR, Flex 14 AMD Ryzen 2200U specifically w00tus Linux - Newbie 7 10-13-2018 12:30 PM
[Flex & Bison] How to check which state Flex is in? courteous Programming 0 06-03-2011 11:46 AM
help with a shell script that data parses /usr/bin/time Ryzol Programming 1 08-04-2008 04:24 PM
User Preferences: Use HTML code instead of vB code? (vB code is overrated) stefanlasiewski LQ Suggestions & Feedback 5 07-26-2005 01:37 AM
flex c++ code about nest file?? chuanyung Programming 0 01-20-2004 03:36 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration