ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.