文法のコメント ブロックに問題があります。構文は問題ありませんが、ステップ 3 DFA スキャナーは、私が行っている方法について不平を言っています。
解析しようとしている言語は次のようになります。
{ステートメント}{ステートメント} など
各ステートメント内には、いくつかの異なるタイプのコメントを含めることができます。
{% This is a comment.
It can contain multiple lines
and continues until the statement end}
{statement REM This is a comment.
It can contain multiple lines
and continues until the statement end}
これは、私が直面している問題を表示する単純化された文法です。
"Start Symbol" = <Program>
{String Chars} = {Printable} + {HT} - ["\]
StringLiteral = '"' ( {String Chars} | '\' {Printable} )* '"'
Comment Start = '{%'
Comment End = '}'
Comment Block @= { Ending = Closed } ! Eat the } and produce an empty statement
!Comment @= { Type = Noise } !Implied by GOLD
Remark Start = 'REM'
Remark End = '}'
Remark Block @= { Ending = Open } ! Don't eat the }, the statements expects it
Remark @= { Type = Noise }
<Program> ::= <Statements>
<Statements> ::= '{' <Statement> '}' <Statements> | <>
<Statement> ::= StringLiteral
ステップ 3 は、<Statements> の } と字句グループの End の } について不平を言っています。
必要なことを達成する方法を知っている人はいますか?
[編集]
REM 部分を次のように動作させました。
{Remark Chars} = {Printable} + {WhiteSpace} - [}]
Remark = 'REM' {Remark Chars}* '}'
<Statements> ::= <Statements> '{' <Statement> '}'
| <Statements> '{' <Statement> <Remark Stmt>
| <>
<Remark Stmt> ::= Remark
Remarks は私にとって必ずしもノイズではないので、これは実際には理想的です。
コメント字句グループにはまだ問題があります。同じように解いていきます。