首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 .NET Java 游戏 视频 人才 外包 培训 数据库 书店 程序员
中国软件网
欢迎您:游客 | 登录 注册 帮助
  • 急!急!急! 有人肯帮忙我做下列题吗?是国外大学的作业题
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • xieqq
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    • 揭贴率:
    发表于:2007-11-11 09:35:17 楼主
    A8P3 - 30 marks (LR.java or lr.ss)
    Write a Java or Scheme program that reads an LR1 file representing a context-free grammar, an LR(1) machine, and a sequence to be recognized. If the sequence is in the language, output the unindented reversed rightmost derivation, as defined in the cfg-r file format. If the input is not recognized, output "ERROR at k" to standard error, where k is one greater than the number of tokens in the longest correct prefix.
    For the sample lr1 file as input, the correct output is:

    term id
    expr term
    term id
    expr term
    term ( expr )
    expr expr - term
    term id
    expr expr - term
    S BOF expr EOF

    If you replace the last line of this file by
    BOF id - id ) - id EOF
    the correct output (to standard error) is
    ERROR at 5

    You may also test your program with the WL grammar and parse tables, in .lr1 format after adding a sequence to be recognized.
    Note that the parsing handout contains LR pseudocode.

    A8P4 - 16 marks (WLParse.java or wlparse.ss)
    Write a WL parser encapsulated as a Java or Scheme program. The input to your parser is a file representing the sequence of tokens in a WL program, as output by the scanner specified in A6P4.
    That is, each token is represented by a line containing the name of the token, followed by a space, followed by the string recognized as the token in the WL source program. Note: Unlike the input of A8P3, the input to your parser in this problem will not have lines containing BOF and EOF at the beginning and end.

    If the input represents a syntactically valid WL program, the output from your program should be a .wli file. The format of a .wli represents the derivation and also the recognized token strings.

    If the input does not represent a syntactically valid WL program, output "ERROR at k" to System.err where k is one greater the number of tokens in the longest correct prefix of the input (that is, not counting BOF).

    The student.cs undergraduate enviroment includes two commands to help you test your parser:

    java cs241.WLScan reads a WL program and outputs a token list that may be used as input to your parser;
    java cs241.WLICheck displays and verifies the format of a .wli file.
    20  修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • fu320212253
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2007-11-16 15:54:211楼 得分:0
    脑壳大
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • malligator
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2007-11-29 10:44:072楼 得分:0
    :)
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    • daniel_kaka
    • 等级:
    • 可用分等级:
    • 总技术分:
    • 总技术分排名:
    发表于:2007-11-29 13:33:343楼 得分:0
    大学编译原理教材上关于LR1语法写得很详细,你可以找找看看,网上这方面的也很多
    修改 删除 举报 引用 回复

    网站简介广告服务网站地图帮助联系方式诚聘英才English 问题报告
    北京创新乐知广告有限公司 版权所有 京 ICP 证 070598 号
    世纪乐知(北京)网络技术有限公司 提供技术支持
    Copyright © 2000-2008, CSDN.NET, All Rights Reserved