📄 parser.pm
字号:
################################################################### Copyright (C) 2000 Greg London All Rights Reserved.# This program is free software; you can redistribute it and/or# modify it under the same terms as Perl itself.##################################################################################################################################### this module defines a grammar for the VHDL language# that can be used by Parse::RecDescent##################################################################package Hardware::Vhdl::Parser;use Parse::RecDescent;use strict;use vars qw($VERSION @ISA);@ISA = ( 'Parse::RecDescent' );$VERSION = '0.12';###########################################################################################################################################sub new##################################################################{ my ($pkg) = @_; # get the vhdl grammar defined in this file my $vhdl_grammar = $pkg->grammar(); # create a parser object, use SUPER:: to find the method via @ISA my $r_hash = $pkg->SUPER::new ($vhdl_grammar); # bless it as a vhdl_parser object bless $r_hash, $pkg; return $r_hash;} ##################################################################sub grammar##################################################################{# note, q{ statement should be on line 100, # to make it easier to find referenced line numbersreturn q{#START_OF_GRAMMAR##################################################### define reserved words. case insensitive####################################################reserved_word_abs : /abs/ireserved_word_access : /access/ireserved_word_after : /after/ireserved_word_alias : /alias/ireserved_word_all : /all/ireserved_word_and : /and/ireserved_word_architecture : /architecture/ireserved_word_array : /array/ireserved_word_assert : /assert/ireserved_word_attribute : /attribute/ireserved_word_begin : /begin/ireserved_word_block : /block/ireserved_word_body : /body/ireserved_word_buffer : /buffer/ireserved_word_bus : /bus/ireserved_word_case : /case/ireserved_word_component : /component/ireserved_word_configuration : /configuration/ireserved_word_constant : /constant/ireserved_word_disconnect : /disconnect/ireserved_word_downto : /downto/ireserved_word_else : /else/ireserved_word_elsif : /elsif/ireserved_word_end : /end/ireserved_word_entity : /entity/ireserved_word_exit : /exit/ireserved_word_file : /file/ireserved_word_for : /for/ireserved_word_function : /function/ireserved_word_generate : /generate/ireserved_word_generic : /generic/ireserved_word_group : /group/ireserved_word_guarded : /guarded/ireserved_word_if : /if/ireserved_word_impure : /impure/ireserved_word_in : /in/ireserved_word_inertial : /inertial/ireserved_word_inout : /inout/ireserved_word_is : /is/ireserved_word_label : /label/ireserved_word_library : /library/ireserved_word_linkage : /linkage/ireserved_word_literal : /literal/ireserved_word_loop : /loop/ireserved_word_map : /map/ireserved_word_mod : /mod/ireserved_word_nand : /nand/ireserved_word_new : /new/ireserved_word_next : /next/ireserved_word_nor : /nor/ireserved_word_not : /not/ireserved_word_null : /null/ireserved_word_of : /of/ireserved_word_on : /on/ireserved_word_open : /open/ireserved_word_or : /or/ireserved_word_others : /others/ireserved_word_out : /out/ireserved_word_package : /package/ireserved_word_port : /port/ireserved_word_postponed : /postponed/ireserved_word_procedure : /procedure/ireserved_word_process : /process/ireserved_word_pure : /pure/ireserved_word_range : /range/ireserved_word_record : /record/ireserved_word_register : /register/ireserved_word_reject : /reject/ireserved_word_rem : /rem/ireserved_word_report : /report/ireserved_word_return : /return/ireserved_word_rol : /rol/ireserved_word_ror : /ror/ireserved_word_select : /select/ireserved_word_severity : /severity/ireserved_word_signal : /signal/ireserved_word_shared : /shared/ireserved_word_sla : /sla/ireserved_word_sll : /sll/ireserved_word_sra : /sra/ireserved_word_srl : /srl/ireserved_word_subtype : /subtype/ireserved_word_then : /then/ireserved_word_to : /to/ireserved_word_transport : /transport/ireserved_word_type : /type/ireserved_word_unaffected : /unaffected/ireserved_word_units : /units/ireserved_word_until : /until/ireserved_word_use : /use/ireserved_word_variable : /variable/ireserved_word_wait : /wait/ireserved_word_when : /when/ireserved_word_while : /while/ireserved_word_with : /with/ireserved_word_xnor : /xnor/ireserved_word_xor : /xor/ieofile : /^\Z/########################################################################################################design_file : design_unit(s) eofile { $return = $item[1] }design_unit : context_clause(s?) library_unit | <error> context_clause : library_clause | use_clause library_unit : entity_declaration | architecture_body | package_declaration | package_body | configuration_declaration library_clause : reserved_word_library library_name_list ';' library_name_list : identifier_comma_identifieruse_clause : reserved_word_use selected_name_comma_selected_name ';' ########################################################################################################entity_declaration : reserved_word_entity entity_name reserved_word_is generic_declaration_section(?) port_declaration_section(?) entity_declaritive_item(?) begin_entity_section(?) reserved_word_end reserved_word_entity(?) identifier(?) ';' begin_entity_section : reserved_word_begin ( concurrent_assertion_statement | passive_concurrent_procedure_call_statement | passive_process_statement ) passive_concurrent_procedure_call_statement : concurrent_procedure_call_statementpassive_process_statement : process_statemententity_declaritive_item : | signal_declaration | constant_declaration | type_declaration | subtype_declaration | shared_variable_declaration | file_declaration | alias_declaration | attribute_declaration | attribute_specification | disconnection_specification | use_clause | group_template_declaration | group_declaration | subprogram_declaration | subprogram_body architecture_body : reserved_word_architecture identifier reserved_word_of entity_name reserved_word_is block_declarative_item(s?) reserved_word_begin concurrent_statement(s?) reserved_word_end reserved_word_architecture(?) identifier(?) ';' | <error> configuration_declaration : reserved_word_configuration identifier reserved_word_of entity_name reserved_word_is use_clause_or_attribute_specification_or_group_declaration(s?) block_configuration reserved_word_end reserved_word_configuration(?) identifier(?) ';' use_clause_or_attribute_specification_or_group_declaration : use_clause | attribute_specification | group_declarationblock_configuration : reserved_word_for architecture_name use_clause_or_for_use_clause(s?) reserved_word_end reserved_word_for ';'use_clause_or_for_use_clause : use_clause | for_use_clausefor_use_clause : reserved_word_for identifier ':' identifier use_clause(?) reserved_word_end reserved_word_for ';'package_declaration : reserved_word_package identifier reserved_word_is package_declarative_item(s?) reserved_word_end reserved_word_package(?) identifier(?) ';' | <error> package_declarative_item : subprogram_declaration | type_declaration | subtype_declaration | constant_declaration | signal_declaration | shared_variable_declaration | file_declaration | alias_declaration | component_declaration | attribute_declaration | attribute_specification | disconnection_specification | use_clause | group_template_declaration | group_declaration package_body : reserved_word_package reserved_word_body identifier reserved_word_is package_body_declarative_item(s?) reserved_word_end reserved_word_package_and_body(?) identifier(?) ';' | <error> reserved_word_package_and_body : reserved_word_package reserved_word_bodypackage_body_declarative_item : subprogram_body | subprogram_declaration | type_declaration | subtype_declaration | constant_declaration | shared_variable_declaration | file_declaration | alias_declaration | use_clause | group_template_declaration
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -