Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4106
Number of posts: 14016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
modules? Posted by dmallord on 9 Apr 2007 at 6:57 PM
hi all,
i have a 4 part assignment that is to write
[1:lexical analyzer][2:parser][3:symbol table][4:simulator]
these have to be built using modules? my lex will read in a .txt file that contains int i;
int n = 4 ;
float sum ;

for ( i = 0 ; i < n ; i = i + 1 )
{
sum = sum + 1 ;
} ;

i can read this from a .txt file to the screen; but i am pretty sure that inorder to move to the next step, i need to tokenize each character. that is the first problem. i can use whitespace as my delimeter. once the file is tokenized i need to pass it as a module to a state machine for parsing.

i am stuck. if i could get help with the creation of the tokens i would be off to a better start.

thanks
Report
Re: modules? Posted by zibadian on 9 Apr 2007 at 8:09 PM
: hi all,
: i have a 4 part assignment that is to write
: [1:lexical analyzer][2:parser][3:symbol table][4:simulator]
: these have to be built using modules? my lex will read in a .txt file that contains int i;
: int n = 4 ;
: float sum ;
:
: for ( i = 0 ; i < n ; i = i + 1 )
: {
: sum = sum + 1 ;
: } ;
:
: i can read this from a .txt file to the screen; but i am pretty sure that inorder to move to the next step, i need to tokenize each character. that is the first problem. i can use whitespace as my delimeter. once the file is tokenized i need to pass it as a module to a state machine for parsing.
:
: i am stuck. if i could get help with the creation of the tokens i would be off to a better start.
:
: thanks
:
I've written a function called StringSplit(), which can take a part from a larger string. See the http://www.codepedia.com/1/StringSplit for the source. This will come helpful in tokenizing the text.
Report
Re: modules? Posted by dmallord on 9 Apr 2007 at 9:44 PM
: : hi all,
: : i have a 4 part assignment that is to write
: : [1:lexical analyzer][2:parser][3:symbol table][4:simulator]
: : these have to be built using modules? my lex will read in a .txt file that contains int i;
: : int n = 4 ;
: : float sum ;
: :
: : for ( i = 0 ; i < n ; i = i + 1 )
: : {
: : sum = sum + 1 ;
: : } ;
: :
: : i can read this from a .txt file to the screen; but i am pretty sure that inorder to move to the next step, i need to tokenize each character. that is the first problem. i can use whitespace as my delimeter. once the file is tokenized i need to pass it as a module to a state machine for parsing.
: :
: : i am stuck. if i could get help with the creation of the tokens i would be off to a better start.
: :
: : thanks
: :
: I've written a function called StringSplit(), which can take a part from a larger string. See the http://www.codepedia.com/1/StringSplit for the source. This will come helpful in tokenizing the text.
:
hi, and thank you. it looks like i can set the delimiter to the whitespace, and break the string up nicely.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.