首页 > 其他分享 >ml语法转C语法,转译器成品

ml语法转C语法,转译器成品

时间:2024-09-14 12:24:45浏览次数:11  
标签:function languages language ml 语法 program 转译 project

<iframe allowfullscreen="true" data-mediaembed="csdn" frameborder="0" id="eeZ9gUz8-1725591747192" src="https://live.csdn.net/v/embed/422559"></iframe>

ml编译器成品

Project 1 2024 - see also project clarifications (updated 5pm 28th Aug) and marking rubric

成品(Price 500)

w,e,c,h,a,t : help-assignment

The goal of this project is to implement a C11 program to translate programs written in a small mini- language to C11, and to then compile and execute that program.
Successful completion of the project will enhance your understanding of core features of the C11 programming language, functions from the C11 standard library, your operating system’s system-calls, the creation and management of operating system processes, and reward familiarisation with online systems’ documentation.

(The wording on this page may change to improve grammar and to make things clearer)
Project Description
We’re all very familiar with higher-level programming languages, such as Python, Java, and C. They have many well-defined features, and are supported by standard libraries and modules. We’ll term these large-languages.
At the other end of the scale are mini-languages, that are often embedded in other programs that don’t require the support of a full programming language, or are invoked from the command-line or in a shellscript. You could consider the use of macros in MS-Excel, or the Unix command-line program bc (see man bc), as examples of al mini-languages. Chapter 8 of The Art of Unix Programming provides an overview of some (older) mini-languages [not required reading].
This project requires you write a C11 program to compile and execute a program written in a mini-language thatl we’ll name ml. Note that there already exists a very successful programming language named ML (for Meta Language), but our mini-language is unrelated to ML (or to Machine Learning).
Writing a compiler for any programming language is an enormous task, clearly not one suited for this project. However, what many have recognised, is that C is an excellent language to support other languages, and that C has an extensive toolchain supporting compilation and linking. The strategy is to first translate programs written in other languages, such as our ml, to C, to compile that translated C code using a standard C compiler, and to finallyl execute the resultant program. This sequence is often termed transpiling, the ‘joining’ of the words translating and compiling. In this role, C is often described as a high-level assembly language, sometimes a ‘wallpaper language’.l
The goal of this project is to implement a C11 program, named runml, which accepts a single command-linel argument providing the pathname of a text file containing a program written in ml, [added 28/8] and any optionall command-line arguments to be passed the transpiled program when it is executed. Successful execution of runmll will involve checking the syntax of the ml program, translating that valid ml program to a C11 program, compilationl of the resultant C program and, finally, execution of the compiled program.

Our ml language

  1. the syntax of ml programs
    sample01.ml, sample02.ml, sample03.ml, sample04.ml, sample05.ml, sample06.ml, sample07.ml, sample08.ml
  2. programs are written in text files whose names end in .ml
  3. statements are written one-per-line (with no terminating semi-colon)
  4. the character “#” appearing anywhere on a line introduces a comment which extends until the end of that line
  5. only a single datatype is supported - real numbers, such as 2.71828
  6. identifiers (variable and function names) consist of 1…12 lowercase alphabetic characters, such as budgie
  7. there will be at most 50 unique identifiers appearing in any program
  8. variables do not need to be defined before being used in an expression, and are automatically initialised to the (real) value 0.0
  9. the variables arg0, arg1, and so on, provide access to the program’s command-line arguments which provide real-valued numbers
  10. a function must have been defined before it is called in an expression
  11. each statement in a function’s body (one-per-line) is indented with a tab character
  12. functions may have zero-or-more formal parameters
  13. a function’s parameters and any other identifiers used in a function body are local to that function, and become unavailable when the function’s execution completes
  14. programs execute their statements from top-to-bottom and function calls are the only form of control-flow (yes, the language would be more useful with loops and conditions, but this project is not about designing programming languages - future work for those interested)

标签:function,languages,language,ml,语法,program,转译,project
From: https://blog.csdn.net/telnet3000/article/details/142169413

相关文章

  • 在xml文件中 大于|小于|等于 的使用
    字符名称sql符号转义字符大于号>>小于号<<不等于<><>大于等于号>=>=小于等于号<=<=......
  • 中移ML307A(4G Cat1,C-SDK,OpenCPU)模组学习开发-关于操作SD卡
    <p><iframename="ifd"src="https://mnifdv.cn/resource/cnblogs/ML307A_OPEN"frameborder="0"scrolling="auto"width="100%"height="1500"></iframe></p> 提示1,SD卡的引脚和串口0是冲突......
  • 标准IO流类库 语法练习
    1.编写函数,接受一个istream&参数,返回值类型也是istream&。此函数须从给定流中读取数据,直至遇到文件结束标识时停止。它将读取的数据打印在标准输出上。完成这些操作后,在返回流之前,对流进行复位,使其处于有效状态。1#include<iostream>2usingnamespacestd;3istream&fu......
  • QT6 QML编程
    QT6QML编程使用AI技术辅助生成QT界面美化视频课程QT性能优化视频课程QT原理与源码分析视频课程QTQMLC++扩展开发视频课程免费QT视频课程您可以看免费1000+个QT技术视频免费QT视频课程QT统计图和QT数据可视化视频免费看免费QT视频课程QT性能优化视频免费看免费QT视......
  • QT6 QML编程
    QT6QML编程使用AI技术辅助生成[QT界面美化视频课程](https://edu.csdn.net/lecturer/7637)[QT性能优化视频课程](https://edu.csdn.net/lecturer/7637)[QT原理与源码分析视频课程](https://edu.csdn.net/lecturer/7637)[QTQMLC++扩展开发视频课程](https://edu.csdn.net/lectu......
  • MemLong: 基于记忆增强检索的长文本LLM生成方法
    本文将介绍MemLong,这是一种创新的长文本语言模型生成方法。MemLong通过整合外部检索器来增强模型处理长上下文的能力,从而显著提升了大型语言模型(LLM)在长文本处理任务中的表现。核心概念MemLong的设计理念主要包括以下几点:高效扩展LLM上下文窗口的轻量级方法。利用不可训练的......
  • PbootCMS生成的sitemap.xml中增加tag标签链接
    打开/apps/home/model/SitemapModel.php,在78行后面增加个指定分类标签调用代码//指定分类标签调用publicfunctiongetSortTags($scode){$join=array(array('ay_content_sortb','a.scode=b.scode','LEFT'......
  • warkdown语法基础
    warkdown语法标题:#+标语提名字(一级标题)+名字(二级标题,依次增加)字体内容两边加上两个*,表示粗体​一个*,表示斜体​三个*,表示斜体+加粗内容(两边加上两个~)引用一个>分割线三个-或三个*图片!+[图片名字]+(地址)可以是......
  • 对HTML基础详细拓展
    1.什么是HMTL?HTML是用来描述网页的一种语言。HTML指的是超文本标记语言:HyperTextMarkupLanguageHTML不是一种编程语言,而是一种标记语言标记语言是一套标记标签(markuptag)HTML使用标记标签来描述网页HTML文档包含了HTML标签及文本内容HTML文档也叫做web页面......
  • AV1 Bitstream & Decoding Process Specification--[4]:语法结构
    原文地址:https://aomediacodec.github.io/av1-spec/av1-spec.pdf没有梯子的下载地址:AV1Bitstream&DecodingProcessSpecification摘要:这份文档定义了开放媒体联盟(AllianceforOpenMedia)AV1视频编解码器的比特流格式和解码过程。规范:此文档规定了开放媒体联盟(Alliance......