- 浏览: 60751 次
最近访客 更多访客>>
最新评论
-
healer_kx:
Reading~healer.kx~~~~~~~
编译器的书 -
yawl:
"SVM are some of the most ...
classifier算法优缺点 -
coderplay:
SVM有啥优点? 没整过, 只是知道算法是咋回事. 依算法描述 ...
classifier算法优缺点 -
yawl:
我现在在做sentiment analysis的,看这方面的p ...
classifier算法优缺点 -
luven:
好看不重要,关键看创意!
Rails Rumble -- 48小时内完成的131个 application
For people who are interested in how ruby's yacc parser works, there is an undocumented command line option("-y") that may be helpful. It will display a trace of the parser's operations.
To use it, you need to clear your RUBYOPT environment variable to NOT use "rubygems" (this will break some ruby applications), otherwise it will make too much noise.
Here is an example:
XRuby's ANTLR parser does not have this option. But as ANRLE produces human readable code, you can just read the generated code or step through it in a debugger to learn how it works.
To use it, you need to clear your RUBYOPT environment variable to NOT use "rubygems" (this will break some ruby applications), otherwise it will make too much noise.
Here is an example:
$ruby -y -e "a=1"
Starting parse
Entering state 0
Reducing stack by rule 1 (line 328), -> @1
Stack now 0
Entering state 2
Reading a token: Next token is token tIDENTIFIER ()
Shifting token tIDENTIFIER, Entering state 34
Reading a token: Next token is token '=' ()
Reducing stack by rule 418 (line 2146), tIDENTIFIER -> variable
Stack now 0 2
Entering state 90
Next token is token '=' ()
Reducing stack by rule 83 (line 827), variable -> lhs
Stack now 0 2
Entering state 73
Next token is token '=' ()
Shifting token '=', Entering state 315
Reading a token: Next token is token tINTEGER ()
Shifting token tINTEGER, Entering state 40
Reducing stack by rule 414 (line 2134), tINTEGER -> numeric
Stack now 0 2 73 315
Entering state 89
Reducing stack by rule 376 (line 1899), numeric -> literal
Stack now 0 2 73 315
Entering state 79
Reducing stack by rule 267 (line 1421), literal -> primary
Stack now 0 2 73 315
Entering state 75
Reading a token: Next token is token '\n' ()
Reducing stack by rule 217 (line 1199), primary -> arg
Stack now 0 2 73 315
Entering state 488
Next token is token '\n' ()
Reducing stack by rule 173 (line 953), lhs '=' arg -> arg
Stack now 0 2
Entering state 74
Next token is token '\n' ()
Reducing stack by rule 40 (line 616), arg -> expr
Stack now 0 2
Entering state 64
Next token is token '\n' ()
Reducing stack by rule 34 (line 596), expr -> stmt
Stack now 0 2
Entering state 63
Next token is token '\n' ()
Reducing stack by rule 6 (line 381), stmt -> stmts
Stack now 0 2
Entering state 62
Next token is token '\n' ()
Shifting token '\n', Entering state 216
Reducing stack by rule 496 (line 2429), '\n' -> term
Stack now 0 2 62
Entering state 220
Reducing stack by rule 497 (line 2432), term -> terms
Stack now 0 2 62
Entering state 300
Reading a token: Now at end of input.
Reducing stack by rule 489 (line 2416), terms -> opt_terms
Stack now 0 2 62
Entering state 299
Reducing stack by rule 4 (line 373), stmts opt_terms -> compstmt
Stack now 0 2
Entering state 61
Reducing stack by rule 2 (line 328), @1 compstmt -> program
Stack now 0
Entering state 1
Now at end of input.
XRuby's ANTLR parser does not have this option. But as ANRLE produces human readable code, you can just read the generated code or step through it in a debugger to learn how it works.
发表评论
-
编译器的书
2008-01-04 01:12 2821有关编译器的书中"Dragon Book" ... -
新的各种ruby实现的性能比较
2007-12-04 06:13 2282Antonio Cangiano今天在blog上更新了各种ru ... -
xruby 0.3.2发布了
2007-11-29 06:00 1563基本和上一个版本(0.3.1)相比变化不大, 大多数都是bug ... -
三周的假期结束了
2007-11-27 20:44 1093用年假回国了一趟。由于时间太短,只在北京和兰州各待了几天。家里 ... -
YAML也要没人维护了
2007-11-05 12:45 1413sishen在xruby mailist提到YAML项目很可能 ... -
Strongtalk项目将无人维护了
2007-11-01 02:05 1974Strongtalk项目的Dave Griswold几天前发了 ... -
和日期相关的库
2007-10-29 22:52 1088上周加入了三个和日期相关的库: time.rb parseda ... -
xruby.googlecode.com
2007-10-23 13:24 1310刚才发现google code最近做了不少改进,其中的就是一个 ... -
复杂的依赖关系
2007-10-19 13:48 1272支持ruby on rails是xruby最重要的目标.我最近 ... -
rails application和web server
2007-10-17 01:31 1418部署到apache/lighthttpd的rails appl ... -
singleton.rb
2007-10-16 00:01 1148上一周的时间,基本上都在争取让xruby能支持singleto ... -
用Jakarta-ORO重写了Regexp
2007-10-10 00:36 2298这个javaeye上的blog本来是利用rss导入做的在国内的 ... -
xruby 0.3.0 released
2007-08-08 05:02 1689I am pleased to announce that X ... -
XRuby 0.2.0 released
2007-05-15 15:15 1170I am glad to announce that XRub ... -
InfoQ article on XRuby
2007-04-17 11:16 906Werner Schuster from InfoQ has ... -
XRuby 0.1.0 released
2007-01-29 22:32 1264[Link of this article: http://x ... -
On-Ruby interview
2007-02-19 03:33 1164Pat Eyler recently interviewed ... -
XRuby 0.1.2 released
2007-03-02 05:58 1241XRuby 0.1.2 is now available fo ... -
XRuby is faster than Ruby 1.8.5 in most benchmarks
2007-03-12 03:02 1732Two weeks ago, Antonio Cangiano ... -
Ruby builtin in pure Ruby
2007-03-12 12:50 1528[Update 03/12/2007 If you know ...
相关推荐
**Ruby-Blender:模块化远程命令执行框架详解** Ruby-Blender,作为一个模块化的远程命令执行框架,是Ruby开发者和DevOps工程师的利器。它旨在简化和自动化跨服务器的工作流,通过提供一套基础的原语,使得在多...
例如,可以通过调整x轴和y轴的范围、添加数据标签、设置图表的动画效果,甚至添加自定义的事件处理函数。此外,通过结合其他Ruby库,如ActiveRecord,可以方便地从数据库中获取并处理数据,进一步增强数据可视化的...
pdf.bar_chart(data, x: 50, y: 50, width: 400, height: 300) # 保存PDF pdf.save("chart.pdf") ``` 这段代码会生成一个包含三个类别的条形图,并将其保存到当前目录下的"chart.pdf"文件中。你可以根据需要调整...
例如,`pgslice create users --time column=created_at format=%Y%m%d`会创建一个基于`created_at`字段的日期分区表。 2. **插入数据**:当向分区表插入新数据时,pgslice会自动将其放入正确的分区。 3. **查询优化...
5. **parse.y**:Ruby的语法描述文件,用于Yacc生成解析器。 6. **lexer.l**:词法分析器的描述文件,用于flex生成词法分析器。 通过分析这些源代码,开发者可以深入了解Ruby的内部工作原理,如何进行内存管理,...
plot.add_layer(Layer.new(data: data, x: 0, y: 1, mark_type: :circle)) plot.render('scatterplot.html') ``` 这个例子创建了一个简单的散点图,并将其保存为HTML文件。 总的来说,Plotrb为Ruby开发者提供了一种...
### Ruby的手动编译安装与升级方法 #### 引言 Ruby是一种动态、面向对象的脚本语言,常被用于Web开发。对于开发者而言,掌握Ruby的安装与配置至关重要。Ubuntu用户通常会依赖于包管理工具`apt-get`来安装Ruby,...
如何安装RHEL / CentOS 5/6 yum install -y rpm-build rpmdevtools readline-devel ncurses-devel gdbm-devel tcl-devel openssl-devel db4-devel byacc libyaml-devel libffi-devel makerpmdev-setuptreecd ~/...
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
json.created_at @user.created_at.strftime('%Y-%m-%d %H:%M:%S') ``` 在这个例子中,`json.`是Jbuilder DSL的起始关键字,后面的每个方法调用都会在JSON对象中添加一个键值对。`@user`是Ruby中的实例变量,它包含...
params = { code: '1234', time: Time.now.strftime('%Y-%m-%d %H:%M') } result = client.send_template_sms(phone_number: '13800138000', template_id: template_id, params: params) ``` 此外,云片API还提供了...
handler :google_analytics, 'UA-XXXXX-Y' end ``` 3. **启用自定义事件**:如果你需要追踪特定的用户事件,可以通过调用 `track_event` 方法来实现,例如: ```ruby track_event('ButtonClick', category: '...
formatted_date = date.format('%Y-%m-%d') # 输出 '2023-04-07' # 自定义格式 custom_format = Yymmdd::Format.new do pattern '%m/%d/%y' end custom_date = custom_format.parse('04/07/23') # 返回一个Date...
在Ruby开发中,MongoDB是常见的后端数据存储选择,因其灵活的数据模型和强大的查询能力受到青睐。本文将详细介绍如何在基于RHEL(Red Hat Enterprise Linux)、Ubuntu和Debian的Linux系统上安装MongoDB,以及使用10...
标题 "Ruby-LikeActiveModelAttributesbutlessfluffyandmoreattributey" 暗示我们要讨论的是一个与 Ruby 的 ActiveModel::Attributes 相关但更为精简、更专注于属性操作的库或框架。ActiveModel 是 Ruby on Rails ...
Acl9通过DSL(领域特定语言)允许你声明如“角色X可以做Y操作在Z资源上”。 4. **DSL(Domain Specific Language)**:Acl9提供了一种简洁的DSL,使得在Ruby代码中声明权限规则变得非常直观。例如,`allow :admin, ...
在Ruby中,可以使用`Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ')`获取当前UTC时间戳。 5. **Format**: 表示返回结果的格式,通常是'JSON'。此参数在请求中固定设置即可。 6. **Version**: API的具体版本号,...
default: "%Y-%m-%d" ``` ```yaml # config/locales/es.yml es: date: formats: default: "%d-%m-%Y" ``` `ShowFor`还提供了其他高级特性,如条件展示、自定义模板、分页等,使得开发者可以根据需要灵活定制...
[root@test ~]# yum -y install ruby ruby-devel ruby-libs ruby-irb ruby-rdoc ruby-mysql 三、安装 RubyGems RubyGems 是一个 Ruby 软件包管理工具,用于安装 Ruby 软件包。需要安装 RubyGems 1.3.7 或更高版本...