Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对标准lexfile的parse。 #1

Open
acodercc opened this issue Oct 23, 2014 · 0 comments
Open

对标准lexfile的parse。 #1

acodercc opened this issue Oct 23, 2014 · 0 comments
Assignees

Comments

@acodercc
Copy link
Owner

对标准lexfile要进行parse,并转换为jsbison要求的json格式的cfg。

从lexfile:

%x  MultiComment
%%
/\/\*/   this.pushState("MultiComment");
<MultiComment>   /\*\//   this.popState();

到jsbison要求的json格式的cfg(context free grammar):

{
  states:{
    exclusive: "MultiComment"
  },
  rules:[{
     regex: /\/\*/,
     action: 'this.pushState("MultiComment");'
  }, {
    conditions: ['MultiComment'],
    regex: /\*\//,
    action: 'this.popState();'
  }]
}

目前lex2cfg中lex文法的功能为:

功能 完成度
正则别名定义 待实现
有限自动机对状态的支持 ok
状态的包容性(%s)与独占性(%x) ok
规则的激活条件的支持 ok
为规则指定多种自动机状态 ok
规则的正则表达式 ok
规则的动作代码 ok
规则动作代码中改变自动机状态 ok
规则动作代码中改变已匹配文本yytext ok
规则动作代码中返回值为TOKEN ok
规则动作代码没有返回,自动继续下次匹配 ok
规则动作代码中调用yymore(),暂不返回,合并下次匹配内容到当前匹配的yytext ok
规则动作代码中调用yyless(),会退匹配点 待实现
@acodercc acodercc self-assigned this Oct 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant