【问题标题】:Chicken Scheme and malformed definitions鸡计划和畸形定义
【发布时间】:2014-12-15 05:45:07
【问题描述】:

鸡计划 4.8.0.5

大家好,

这是列表列表的格式错误定义的 sn-p。我说格式不正确是因为 变量名位于最左边的括号之外,并且没有明确的定义语句,即。 (define techDisplays ((AG1 FillerIgnore....nil nil))

sn-p.il

techDisplays(
;( LayerName            Purpose                  Packet                         Vis Sel C2C Drg Val )
;( ---------            -------                  ------                         --- --- --- --- --- )
( AG1                  fillerIgnore             AG1_fillerIgnore                t   t  nil  t  nil )
( AG2                  drawing                  AG2_drawing                     t   t  nil  t   t  )
( AG2                  fillerIgnore             AG2_fillerIgnore                t   t  nil  t  nil )
( AG2                  frame                    AG2_frame                       t   t  nil  t   t  )
( AG2                  frameOnly                AG2_frameOnly                   t   t  nil  t   t  )
( AG2                  frameOnlyHole            AG2_frameOnlyHole               t   t  nil  t   t  )
( y0               flight     y0_flight                 t   t   t   t   nil )
( y1               flight     y1_flight                 t   t   t   t   nil )
( y2               flight     y2_flight                 t   t   t   t   nil )
( y3               flight     y3_flight                 t   t   t   t   nil )
( y4               flight     y4_flight                 t   t   t   t   nil )
( y5               flight     y5_flight                 t   t   t   t   nil )
( y6               flight     y6_flight                 t   t   t   t   nil )
( y7               flight     y7_flight                 t   t   t   t   nil )
( y8               flight     y8_flight                 t   t   t   t   nil )
( y9               flight     y9_flight                 t   t   t   t   nil )
( border           boundary   border_boundary           t   nil t   t   nil )
( snap             grid       snap_grid                 t   nil t   nil nil )
) ;techDisplays

问题:我需要让 Scheme 将其识别为有效的顶级定义 进一步的问题:解决方案必须是可扩展的,因为这个来自那个的地方还有 100 多个 我也必须阅读 约束:我非常非常希望不必编写一些解析例程,因为它很可能 结果发现所有括号计数、匹配和分层都是错误的。

欢迎任何想法、提示、建设性批评。

TIA,

还在学习的史蒂夫

【问题讨论】:

    标签: chicken-scheme


    【解决方案1】:

    考虑一下,

    ; this is structured as your input with just a space after the first name
    #;1> (define inp 
                 '(techdisps (foo bar baz) 
                             (foo1 bar1 baz1) 
                             (foo2 bar2 baz2))) 
    #;2> inp
    (techdisps (foo bar baz) (foo1 bar1 baz1) (foo2 bar2 baz2))
    #;3> (define techdisps cdr)
    ;get all the displays from you input
    #;4> (techdisps inp)
    ((foo bar baz) (foo1 bar1 baz1) (foo2 bar2 baz2))
    ;this should be just a tech display, let's see how it parses.
    #;5> (car (techdisps inp))
    (foo bar baz)
    #;6> (define foo car)
    #;7> (define bar cadr)
    #;8> (define baz caddr)
    ;this will give us all the bazes
    #;9> (map baz (techdisps inp))
    (baz baz1 baz2)
    

    如果您认为这不会扩展(尽管 100 多个不会是现代方案解释器在一个像样的盒子中难以处理的东西),我们可以建议替代方案。 希望这可以帮助。

    干杯。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-09
      相关资源
      最近更新 更多