Add files via upload

complete all types of var
This commit is contained in:
Valk Richard Li
2019-07-28 00:01:28 +08:00
committed by GitHub
parent 9b945d9391
commit 5c12e3dbf3
5 changed files with 377 additions and 3 deletions
+72
View File
@@ -0,0 +1,72 @@
#ifndef __PROCESS_STACK_H__
#define __PROCESS_STACK_H__
#include <iostream>
#include <cstring>
#include "nasal.h"
namespace nasal
{
struct process_stack_unit
{
int line; //place the unit first appear
std::string content;//content of the unit or name of the var/class/function
std::string type; //var class function
process_stack_unit *next;
process_stack_unit *last;
};
class process_stack
{
private:
process_stack_unit *head;
process_stack_unit *ptr;
public:
process_stack()
{
head->line=0;
head->content="# Nasal language for FlightGear.";
head->last=NULL;
head->next=NULL;
ptr=NULL;
}
~process_stack()
{
process_stack_unit *temp=head;
while(temp->next)
{
temp=temp->next;
delete head;
head=temp;
}
delete head;
}
void stack_append(process_stack_unit &p)
{
process_stack_unit *temp=head;
process_stack_unit *last_node;
while(temp->next)
{
if(!temp->next->next)
last_node=temp;
temp=temp->next;
}
if(temp==head)
last_node=head;
temp=new process_stack_unit;
temp->last=last_node;
temp->next=NULL;
temp->content=p.content;
temp->line=p.last;
temp->type=p.type;
return;
}
};
}
#endif