Hi all,

I would like to use modules from the compiler to outsource parsing a
definition module. I wrote the code beneath based on what I saw in the
compiler code and some hacking. It works, but I'm not sure if this is
the preferred way to use cocl's parser (if there *is* a preferred way).

In particular, I wasn't sure how I was supposed to create a new heap /
hashtable / pointer. Is it correct to use init_identifiers, nilPtr, and
IC_Module NoQualifiedIdents?

Any help is much appreciated. Thanks in advance.

Camil

-----------------------

  // StdEnv
  import StdFile

  // frontend
  import Heap, compile, parse, predef

  mod_id :== "StdList"
  filename :== "/opt/clean/lib/StdEnv/" +++ mod_id +++ ".dcl"

  Start w
  # (ok,f,w) = fopen filename FReadText w
  | not ok = abort ("Couldn't open file " +++ filename +++ "\n")
  # (st, w) = init_identifiers newHeap w
  # ptr = nilPtr
  # cache = empty_cache st
  # id = {id_name=mod_id, id_info=ptr}
  # (mod_id, ht) = putIdentInHashTable mod_id (IC_Module
NoQualifiedIdents) cache.hash_table
    cache = {cache & hash_table=ht}
  # ((ok,dynamics_used,module,ht,f),w)
      = accFiles (wantModule` f "" False id NoPos False ht stderr) w
  # (ok,w) = fclose f w
  // do something with module

  wantModule` :: !*File !{#Char} !Bool !Ident !Position !Bool
!*HashTable !*File !*Files
        -> ((!Bool,!Bool,!ParsedModule, !*HashTable, !*File), !*Files)
  wantModule` f s b1 i p b2 ht io fs
  # (b1,b2,pm,ht,f,fs) = wantModule f s b1 i p b2 ht io fs
  = ((b1,b2,pm,ht,f),fs)

  //From syntax.icl:
  abort_empty_SymbolTableEntry :: a
  abort_empty_SymbolTableEntry = abort "empty SymbolTableEntry"

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
clean-list mailing list
[email protected]
http://mailman.science.ru.nl/mailman/listinfo/clean-list

Reply via email to