Commit 7278be60 authored by Gregory Casamento's avatar Gregory Casamento
Browse files

Correct Lexer issue. Was not parsing initial token.

parent 5cc396ec
......@@ -51,6 +51,9 @@ static ASTContext *ctx = nil; // Initialized top ASTContext when first context
// Node
@interface ASTNode: NSObject
{
GenericType *type;
}
@property (nonatomic, retain) GenericType *type;
......
......@@ -197,7 +197,7 @@ NSString *tabulate(NSString *code)
// Node
@implementation ASTNode
@synthesize type;
@dynamic type;
- (NSString *)toCode
{
......@@ -222,7 +222,8 @@ NSString *tabulate(NSString *code)
- (void) setType: (GenericType *)atype
{
self.type = atype;
type = atype;
[type retain];
}
- (void) setTypeIfEmpty: (GenericType *)atype
......
......@@ -238,6 +238,7 @@ static TokenData *lastyylexToken = nil;
- (int) yylex
{
TokenData *data = nil;
lastyylexToken = [self nextToken];
if((data = lastyylexToken))
{
return (int)data.token;
......
......@@ -3,5 +3,7 @@
@class Lexer;
@class ASTNode;
ASTNode* bridge_yyparse(Lexer * lexer, int debug);
const char * bridge_yyerror();
void foo();
\ No newline at end of file
This diff is collapsed.
......@@ -9,10 +9,10 @@
#import <Foundation/Foundation.h>
#import "Lexer.h"
#import "AST.h"
// #import "bridge.h"
ASTNode* bridge_yyparse(Lexer * lexer, int debug);
const char * bridge_yyerror();
// ASTNode* bridge_yyparse(Lexer * lexer, int debug);
// const char * bridge_yyerror();
NSDictionary *swiftCompiler(NSString *sourceCode, BOOL debug)
{
......@@ -30,6 +30,8 @@ NSDictionary *swiftCompiler(NSString *sourceCode, BOOL debug)
NSLog(@"===========");
}
foo();
ASTNode *ast = bridge_yyparse(lexer, debug);
if(ast != nil)
{
......@@ -46,7 +48,7 @@ NSDictionary *swiftCompiler(NSString *sourceCode, BOOL debug)
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
BOOL debug = YES;
BOOL debug = NO;
/*
if(argc <= 1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment