ここで説明されている文法を使用して、PowerShell 言語のパーサーを作成しています: http://www.microsoft.com/en-us/download/details.aspx?id=9706。
私は Irony を使用しましたが、Irony Grammar Explorer はシフト/リデュースおよびリデュース/リデュース エラーを報告しています。何を言っているのかわからないので、これは私を困惑させます。
状態 S79 (不十分) 入力に対する Shift-reduce 競合: [ , + ダッシュ ++ ダッシュダッシュ シフト項目: cast_expression -> type_literal ·unary_expression unary_expression -> ·primary_expression 一次式 -> ·値 値 -> ·括弧付きの式 括弧付き式 -> ·(パイプライン) 値 -> ·sub_expression サブ式 -> ·$( statement_list_opt ) 値 -> ·array_expression 配列式 -> ·@( statement_list_opt ) 値 -> ·script_block_expression script_block_expression -> ·{ script_block } 値 -> ·hash_literal_expression hash_literal_expression -> ·@{ hash_literal_body_opt } 値 -> ·リテラル リテラル -> ·integer_literal integer_literal -> ·decimal_integer_literal integer_literal -> ·hexadecimal_integer_literal リテラル -> ·real_literal リテラル -> ·string_literal string_literal -> ·expandable_string_literal string_literal -> ·verbatim_string_literal 値 -> ·type_literal type_literal -> ·[ type_spec ] 値 -> ·変数 primary_expression -> ·member_access member_access -> ·primary_expression 無名6 member_name primary_expression -> ·element_access element_access -> ·primary_expression [式] primary_expression -> ·post_increment_expression post_increment_expression -> ·primary_expression ++ primary_expression -> ·post_decrement_expression post_decrement_expression -> ·primary_expression ダッシュダッシュ unary_expression -> ·expression_with_unary_operator expression_with_unary_operator -> · ·, unary_expression expression_with_unary_operator -> ·-not unary_expression expression_with_unary_operator -> ·! 単項式 expression_with_unary_operator -> ·-bnot unary_expression expression_with_unary_operator -> · + unary_expression expression_with_unary_operator -> ·dash unary_expression expression_with_unary_operator -> ·pre_increment_expression pre_increment_expression -> ·++ unary_expression expression_with_unary_operator -> ·pre_decrement_expression pre_decrement_expression -> ·dashdash unary_expression expression_with_unary_operator -> ·cast_expression cast_expression -> ·type_literal unary_expression expression_with_unary_operator -> ·-split unary_expression expression_with_unary_operator -> ·-結合 unary_expression アイテムを減らす: 値 -> type_literal · [assignment_operator . :: [ ++ ダッシュダッシュ , .. format_operator * / % + ダッシュ as ccontains ceq cge cgt cle clike clt cmatch cne cnotcontains cnotlike cnotmatch contains creplace csplit eq ge gt icontains ieq ige igt ile ilike ilt imatch ine inotcontains inotlike inotmatch ireplace isnot isplit join le like lt match ne notcontains notlike notmatch replace split -band -bor -bxor -and -or -xor 2>&1 1>&2 file_redirection_operator | ; new_line_character EOF } ) = ]] 遷移: unary_expression->S187、primary_expression->S158、value->S60、parenthesized_expression->S61、(->S62、sub_expression->S63、$(->S64、array_expression->S65、@(->S66、script_block_expression ->S67, {->S68, hash_literal_expression->S69, @{->S70,literal->S71, integer_literal->S72, decimal_integer_literal->S73, hexadecimal_integer_literal->S74, real_literal->S75, string_literal->S76, expandable_string_literal->S77, verbatim_string_literal->S78, type_literal->S79, [->S80, variable->S81, member_access->S82, element_access->S83, post_increment_expression->S84, post_decrement_expression->S85, expression_with_unary_operator->S97, ,->S98, -not->S99, !->S100, -bnot->S101, +->S102, dash->S103, pre_increment_expression->S104, ++->S105,pre_decrement_expression->S106、ダッシュダッシュ->S107、cast_expression->S108、-split->S109、-join->S110
自分自身を見たい場合、コードはこちら: https://github.com/Pash-Project/Pash/tree/method-invocation/Source/Pash.System.Management
編集:これが混乱する入力は次のとおりだと思います:
[int] +7
これは追加ですか、それともキャストですか?