English 中文(简体)
如何在无引证的情况下抓住扼杀
原标题:How to capture a string without quote characters

我试图在没有引述的情况下抓住引证。 我有这个终点站。

%token <string> STRING

生产

constant:
    | QUOTE STRING QUOTE { String($2) }

连同这些备选案文

|           { QUOTE }
| [^    ]*  { STRING (lexeme lexbuf) } //final regex before eof

似乎正在将形成<条码>QUOTE的所有东西解释为单一半年法,而后一法则是 par。 因此,我的问题可能在于图马诺言中其他地方。 我是否这样做? 在我试图将引证从扼杀中删除之前,这等于罚款。

Update

我认为,与以下灵活规则可能有些含糊不清。

let name = alpha (alpha | digit |  _ )*
let identifier = name ( .  name)*

以下规则在<代码>之前: 光盘

| identifier    { ID (lexeme lexbuf) }

如果没有在<条码>战略中引述的话,是否有办法去模糊这些内容?

最佳回答

在弹性体内对像体字和数字字面等固定体进行审慎分析,是很正常的,因此,你可以考虑对像你这样固定不变的弹性规则。

|     [^    ]*     
    { STRING (let s = lexeme lexbuf in s.Substring(1, s.Length - 2)) }
问题回答

您可使用斜体,但用斜体字表示。

Lexer:

let constant       = (" " ([^    ])* " ")
...
| constant         { STRING(lexeme lexbuf) } 

Parser:

%token <string> STRING

...
constant:
    | STRING { ($1).Trim([|   |]) }

www.un.org/Depts/DGACM/index_french.htm

Lexer:

let name = alpha (alpha | digit |  _ )*
let identifier = name ( .  name)*
...

|           { QUOTE }
| identifier { ID (lexeme lexbuf) }
| _          { STRING (lexeme lexbuf) } 

identifier will take away symbols from STRING, so your lexeme stream can be like: QUOTE ID STRING ID .. QUOTE, and you have to handle this in parser:

Parser:

constant:
     | QUOTE content QUOTE     { String($2) }

content:
     | ID content      { $1+$2 }
     | STRING content  { $1+$2 }
     | ID              { $1 }
     | STRING          { $1 }

I had a similar problem. I capture them in the "lexic.l" file using states. Here my autoanswer





相关问题
Parse players currently in lobby

I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...

How to get instance from string in C#?

Is it possible to get the property of a class from string and then set a value? Example: string s = "label1.text"; string value = "new value"; label1.text = value; <--and some code that makes ...

XML DOM parsing br tag

I need to parse a xml string to obtain the xml DOM, the problem I m facing is with the self closing html tag like <br /> giving me the error of Tag mismatch expected </br>. I m aware this ...

Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

Locating specific string and capturing data following it

I built a site a long time ago and now I want to place the data into a database without copying and pasting the 400+ pages that it has grown to so that I can make the site database driven. My site ...

热门标签