129129/* Use as a command line script */ 
130130/* npm run start:dev -- test.py */ 
131131
132+ // import { Translator } from "./translator"; 
133+ // import { Program } from "estree"; 
134+ // import { Resolver } from "./resolver"; 
135+ // import { Context } from './cse-machine/context'; 
136+ // import { runCSEMachine } from "./runner/pyRunner"; 
137+ 
132138import  {  Tokenizer  }  from  "./tokenizer" ; 
133139import  {  Parser  }  from  "./parser" ; 
134- import  {  Translator  }  from  "./translator" ; 
135- import  {  Program  }  from  "estree" ; 
136- import  {  Resolver  }  from  "./resolver" ; 
137- import  {  Context  }  from  './cse-machine/context' ; 
140+ 
138141export  *  from  './errors' ; 
139142import  {  Finished ,  RecursivePartial ,  Result  }  from  "./types" ; 
140- // import { runCSEMachine } from "./runner/pyRunner"; 
141143import  {  initialise  }  from  "./conductor/runner/util/initialise" ; 
142144import  {  PyEvaluator  }  from  "./conductor/runner/types/PyEvaluator" ; 
143145export  *  from  './errors' ; 
@@ -147,20 +149,20 @@ import { PyContext } from "./cse-machine/py_context";
147149
148150type  Stmt  =  StmtNS . Stmt ; 
149151
150- export  function  parsePythonToEstreeAst ( code : string , 
151-     variant : number  =  1 , 
152-     doValidate : boolean  =  false ) : Program  { 
153-     const  script  =  code  +  '\n' 
154-     const  tokenizer  =  new  Tokenizer ( script ) 
155-     const  tokens  =  tokenizer . scanEverything ( ) 
156-     const  pyParser  =  new  Parser ( script ,  tokens ) 
157-     const  ast  =  pyParser . parse ( ) 
158-     if  ( doValidate )  { 
159-         new  Resolver ( script ,  ast ) . resolve ( ast ) ; 
160-     } 
161-     const  translator  =  new  Translator ( script ) 
162-     return  translator . resolve ( ast )  as  unknown  as  Program 
163- } 
152+ //  export function parsePythonToEstreeAst(code: string,
153+ //      variant: number = 1,
154+ //      doValidate: boolean = false): Program {
155+ //      const script = code + '\n'
156+ //      const tokenizer = new Tokenizer(script)
157+ //      const tokens = tokenizer.scanEverything()
158+ //      const pyParser = new Parser(script, tokens)
159+ //      const ast = pyParser.parse()
160+ //      if (doValidate) {
161+ //          new Resolver(script, ast).resolve(ast);
162+ //      }
163+ //      const translator = new Translator(script)
164+ //      return translator.resolve(ast) as unknown as Program
165+ //  }
164166
165167// import {ParserErrors, ResolverErrors, TokenizerErrors} from "./errors"; 
166168// import fs from "fs"; 
@@ -200,15 +202,15 @@ export interface IOptions {
200202    stepLimit : number 
201203} ; 
202204
203- export  async  function  runInContext ( 
204-     code : string , 
205-     context : Context , 
206-     options : RecursivePartial < IOptions >  =  { } 
207- ) : Promise < Result >  { 
208-     const  estreeAst  =  parsePythonToEstreeAst ( code ,  1 ,  true ) ; 
209-     const  result  =  runCSEMachine ( code ,  estreeAst ,  context ,  options ) ; 
210-     return  result ; 
211- } 
205+ //  export async function runInContext(
206+ //      code: string,
207+ //      context: Context,
208+ //      options: RecursivePartial<IOptions> = {}
209+ //  ): Promise<Result> {
210+ //      const estreeAst = parsePythonToEstreeAst(code, 1, true);
211+ //      const result = runCSEMachine(code, estreeAst, context, options);
212+ //      return result;
213+ //  }
212214
213215
214216
@@ -245,7 +247,7 @@ if (require.main === module) {
245247        process . exit ( 1 ) ; 
246248      } 
247249      const  options  =  { } ; 
248-       const  context  =  new  Context ( ) ; 
250+       const  context  =  new  PyContext ( ) ; 
249251
250252      const  filePath  =  process . argv [ 2 ] ; 
251253
@@ -255,10 +257,10 @@ if (require.main === module) {
255257        const  code  =  fs . readFileSync ( filePath ,  "utf8" )  +  "\n" ; 
256258        console . log ( `Parsing Python file: ${ filePath }  ` ) ; 
257259
258-         const  result  =  await  runInContext ( code ,  context ,  options ) ; 
260+         const  result  =  await  PyRunInContext ( code ,  context ,  options ) ; 
259261        console . info ( result ) ; 
260262        console . info ( ( result  as  Finished ) . value ) ; 
261-         console . info ( ( result  as  Finished ) . representation . toString ( ( result   as   Finished ) . value ) ) ; 
263+         console . info ( ( result  as  Finished ) . representation . toString ( ) ) ; 
262264
263265      }  catch  ( e )  { 
264266        console . error ( "Error:" ,  e ) ; 
0 commit comments