•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 392,065 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,281 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Assembly advertiser:
Views: 4114 | Replies: 0
![]() |
•
•
Join Date: Sep 2005
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
/*
INTOPOST.C
Rex Jaechke, "C Users Journal" mach 92.
*/
#include <ctype.h>
void push(int);
int pop(void);
/*--------------------------------------------------------------------------
FUNCTION: intopost - converts infix to postfix
A. Push a ( on the stack. This sentinel allows us to detect when we
have flushed out the stack on completion in step 1.
--- Perform steps B through H for each character in the infix string ---
B. Ignore white space.
C. Pass alphabetic characters through to postfix list.
D. Push any ( on the stack. These sentinels allows us to detect when
have flushed out the stack when handling ) and operators.
E. Have a ) so pop off the stack and put into postfix list until a (
is popped. Discard the (.
F Have a * or /. Pop off any operators of equal or higher precedence
and put them into postfix list. If a ( or lower precedence operator
(such as + or -) is popped, put it back and stop looking.
Push new * or /.
G. Have a + or -. Pop off any operators of equal or higher precedence
(that includes all of them) and put them into postfix list. If a (
is popped, put it back and stop looking. Push new + or -.
H. Report unknown character on input.
--------
I. Have processed all input characters. New flush stack until we find
the matchint ( put there in step A.
J. Terminate the postfix list.
--------------------------------------------------------------------------*/
void intopost(const char *infix, char *postfix)
{
int st;
/*A*/ push('(');
while (*infix != '\0') {
#ifdef TRACE
printf("*infix: %c\n", *infix);
#endif
/*B*/ if (isspace(*infix)) {
;
}
/*C*/ else if (isalpha(*infix)) {
*postfix++ = *infix;
}
/*D*/ else if (*infix == '(') {
push('(');
}
/*E*/ else if (*infix == ')') {
while ((st = pop()) != '(')
*postfix++ = st;
}
/*F*/ else if (*infix == '*' || *infix == '/') {
while (1) {
if ((st = pop()) == '(' || st == '+'
|| st == '-') {
push(st);
break;
}
*postfix++ = st;
}
push(*infix);
}
/*G*/ else if (*infix == '+' || *infix == '-') {
while (1) {
if ((st = pop()) == '(') {
push(st);
break;
}
*postfix++ = st;
}
push(*infix);
}
/*H*/ else {
printf("Unknown input character %c\n", *infix);
}
++infix;
continue;
}
/*I*/ while ((st = pop()) != '(')
*postfix++ = st;
/*J*/ *postfix = '\0';
}
I Can Write In C Language But Cannot In Assembly SomeOne Can Try Please Do it
/* Fil Slut : INTOPOST.C */
INTOPOST.C
Rex Jaechke, "C Users Journal" mach 92.
*/
#include <ctype.h>
void push(int);
int pop(void);
/*--------------------------------------------------------------------------
FUNCTION: intopost - converts infix to postfix
A. Push a ( on the stack. This sentinel allows us to detect when we
have flushed out the stack on completion in step 1.
--- Perform steps B through H for each character in the infix string ---
B. Ignore white space.
C. Pass alphabetic characters through to postfix list.
D. Push any ( on the stack. These sentinels allows us to detect when
have flushed out the stack when handling ) and operators.
E. Have a ) so pop off the stack and put into postfix list until a (
is popped. Discard the (.
F Have a * or /. Pop off any operators of equal or higher precedence
and put them into postfix list. If a ( or lower precedence operator
(such as + or -) is popped, put it back and stop looking.
Push new * or /.
G. Have a + or -. Pop off any operators of equal or higher precedence
(that includes all of them) and put them into postfix list. If a (
is popped, put it back and stop looking. Push new + or -.
H. Report unknown character on input.
--------
I. Have processed all input characters. New flush stack until we find
the matchint ( put there in step A.
J. Terminate the postfix list.
--------------------------------------------------------------------------*/
void intopost(const char *infix, char *postfix)
{
int st;
/*A*/ push('(');
while (*infix != '\0') {
#ifdef TRACE
printf("*infix: %c\n", *infix);
#endif
/*B*/ if (isspace(*infix)) {
;
}
/*C*/ else if (isalpha(*infix)) {
*postfix++ = *infix;
}
/*D*/ else if (*infix == '(') {
push('(');
}
/*E*/ else if (*infix == ')') {
while ((st = pop()) != '(')
*postfix++ = st;
}
/*F*/ else if (*infix == '*' || *infix == '/') {
while (1) {
if ((st = pop()) == '(' || st == '+'
|| st == '-') {
push(st);
break;
}
*postfix++ = st;
}
push(*infix);
}
/*G*/ else if (*infix == '+' || *infix == '-') {
while (1) {
if ((st = pop()) == '(') {
push(st);
break;
}
*postfix++ = st;
}
push(*infix);
}
/*H*/ else {
printf("Unknown input character %c\n", *infix);
}
++infix;
continue;
}
/*I*/ while ((st = pop()) != '(')
*postfix++ = st;
/*J*/ *postfix = '\0';
}
I Can Write In C Language But Cannot In Assembly SomeOne Can Try Please Do it
/* Fil Slut : INTOPOST.C */
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Assembly Marketplace
•
•
•
•
access activation api asm assembly x86 programming hla demo blogger blogging blogs code combo dani daniweb data debugging dell development dreamweaver drive dropdownlist flash gdata google gpl hard hard drive hitachi html innovation key laptop linux microsoft module net news openbsd product programming reuse rss sandisk serial source storage tags terabyte vista web wysiwyg xml
- Object Orientated C+++.net Calculator! (C++)
- Help pplz. . convert infix to postfix. . (C++)
- help with a infix to postfix program (C++)
- Assembly, machine code and compilers (Assembly)
- can't proceed from here. (C++)
- Using x86 Assembly Language with Microsoft Visual C++ (C++)
Other Threads in the Assembly Forum
- Previous Thread: Help for quicksort in assembly 8085
- Next Thread: divide overflow???


Linear Mode