Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. parse
  2.     "comment stating purpose of message"
  3.     |result a x tmp error res t node top toAdd g|
  4.     error := false.
  5.     t := Tree new.
  6.     t tag: (NonTerm g).
  7.     g := Tree new.
  8.     g tag: (CTerm eop).
  9.     mag := {{NonTerm g. t.}. {CTerm eop. g.}.}.
  10.     result := OrderedCollection new.
  11.     a := (scanner nextToken) tag.
  12.     x := ((mag at: 1) at: 1).
  13.     [(x ~= (CTerm eop) and: (error not))] whileTrue:[
  14.         x := ((mag at: 1) at:1).
  15.         top := ((mag at: 1) at:2).
  16.         (terms includes: x) ifTrue: [
  17.             ((x = CTerm pass) or: (x = a )) ifTrue: [
  18.                 node := Tree new.
  19.                 node tag: x.
  20.                 (top childs) add: node.
  21.                 (x = CTerm pass) ifTrue:[
  22.                     mag := mag allButFirst.
  23.                 ].
  24.                 (x = a) ifTrue:[
  25.                     mag := mag allButFirst.
  26.                     a := (scanner nextToken) tag.
  27.                 ]
  28.             ]
  29.             ifFalse: [
  30.                 Transcript show: 'ERROR'.
  31.                 error := true.
  32.             ].
  33.         ]
  34.         ifFalse:[
  35.             tmp := (table at:(x-20)) at:a.
  36.             (tmp at:1) = -1
  37.             ifTrue: [
  38.                 Transcript show: 'ERROR'.
  39.                 error := true.
  40.             ]
  41.             ifFalse: [
  42.                 node := Tree new.
  43.                 node tag: x.
  44.                 (top childs) add:node.
  45.                 mag := mag allButFirst.
  46.                 "mag := tmp, mag."
  47.                 toAdd := {}.
  48.                 (tmp reverse) do: [:object | toAdd := {{object. node.}.},toAdd].
  49.                 mag := toAdd,mag.
  50.                 res := (self class describe: x), ' -> '.
  51.                 tmp do: [:object | res := res, ' ', (self class describe: object), ', ' ].
  52.                 result add:res.
  53.             ].
  54.         ].
  55.     ].
  56.     t describe:'-'.
  57.     "error ifFalse:[
  58.         result do: [:object | Transcript show: object; cr].
  59. ]"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement