Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. calculateFirstRightSide: rightSide
  2. | break firstSet firstSetB set rightSideRule epsilon|
  3. rightSideRule := RightSideRule withAll: rightSide.
  4. firstSet := Set new.
  5. break := false.
  6. epsilon := true.
  7. rightSideRule do: [ :sym |
  8. (break)
  9. ifFalse: [
  10. (terminalsSet includes: sym)
  11. "terminal"
  12. ifTrue: [
  13. firstSet add: sym.
  14. epsilon := false.
  15. break := true.
  16. ]
  17. "nieterminal"
  18. ifFalse: [
  19. firstSetB := firstDict at: sym.
  20. set := firstSetB copy.
  21. (set includes: Eps)
  22. ifTrue: [ set remove: Eps ]
  23. ifFalse: [
  24. break := true.
  25. epsilon := false.
  26. ].
  27. firstSet addAll: set.
  28. ].
  29. ].
  30. ].
  31. (epsilon)
  32. ifTrue: [
  33. firstSet add: Eps.
  34. ].
  35. ^firstSet.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement