├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ └── question.md └── workflows │ └── build.yml ├── .gitignore ├── .readthedocs.yaml ├── CONTRIBUTING.md ├── LICENSE ├── LICENSE-3RD-PARTY ├── MANIFEST.in ├── README.md ├── docs ├── .gitignore ├── Makefile ├── README.md ├── _static │ └── css │ │ └── theme_overrides.css ├── api │ ├── compiler.rst │ ├── component.rst │ ├── importer.rst │ ├── messages.rst │ ├── node.rst │ ├── source_ref.rst │ ├── types.rst │ ├── udp.rst │ └── walker.rst ├── conf.py ├── dev_notes │ ├── antlr.rst │ ├── compilation.rst │ ├── dpa_type_generation.rst │ ├── expressions.rst │ ├── hierarchical_references.rst │ ├── inferred_placement.rst │ ├── instance_arrays.rst │ ├── logbook.rst │ ├── multi_file_compilation.rst │ ├── namespaces.rst │ ├── perl_preprocessing.rst │ ├── preprocessors.rst │ ├── properties.rst │ ├── rdl_format_code.rst │ ├── rdl_spec_errata.rst │ ├── semantic_checks.ods │ └── user_tree_traversal.rst ├── examples │ ├── json_exporter.rst │ ├── json_importer.rst │ ├── print_hierarchy.rst │ └── print_hierarchy_spi.stdout ├── genindex.rst ├── img │ ├── component-tree.svg │ ├── diagrams.odg │ ├── node-overlay.svg │ ├── overview.svg │ └── walker-listener.svg ├── index.rst ├── known_issues.rst ├── model_structure.rst ├── model_traversal.rst ├── properties.csv ├── properties.rst ├── property_reference.rst └── requirements.txt ├── examples ├── README.md ├── accelera-generic_example.rdl ├── atxmega_spi.rdl ├── export_json.py ├── import_json.py ├── print_hierarchy.py ├── tiny.json └── tiny.rdl ├── pyproject.toml ├── setup.py ├── src └── systemrdl │ ├── __about__.py │ ├── __init__.py │ ├── ast │ ├── __init__.py │ ├── ast_node.py │ ├── binary.py │ ├── boolean.py │ ├── cast.py │ ├── conditional.py │ ├── exponential.py │ ├── literals.py │ ├── reduction.py │ ├── references.py │ ├── relational.py │ ├── sequence.py │ └── unary.py │ ├── compiler.py │ ├── component.py │ ├── core │ ├── BaseVisitor.py │ ├── ComponentVisitor.py │ ├── EnumVisitor.py │ ├── ExprVisitor.py │ ├── StructVisitor.py │ ├── UDPVisitor.py │ ├── __init__.py │ ├── elaborate.py │ ├── helpers.py │ ├── namespace.py │ ├── parameter.py │ ├── rdlformatcode.py │ ├── validate.py │ └── value_normalization.py │ ├── importer.py │ ├── messages.py │ ├── node.py │ ├── parser │ ├── SystemRDL.g4 │ ├── SystemRDL.interp │ ├── SystemRDL.tokens │ ├── SystemRDLLexer.interp │ ├── SystemRDLLexer.py │ ├── SystemRDLLexer.tokens │ ├── SystemRDLParser.py │ ├── SystemRDLParser.pyi │ ├── SystemRDLVisitor.py │ ├── __init__.py │ ├── ext │ │ ├── SystemRDL.interp │ │ ├── SystemRDL.tokens │ │ ├── SystemRDLBaseVisitor.cpp │ │ ├── SystemRDLBaseVisitor.h │ │ ├── SystemRDLLexer.cpp │ │ ├── SystemRDLLexer.h │ │ ├── SystemRDLLexer.interp │ │ ├── SystemRDLLexer.tokens │ │ ├── SystemRDLParser.cpp │ │ ├── SystemRDLParser.h │ │ ├── SystemRDLVisitor.cpp │ │ ├── SystemRDLVisitor.h │ │ ├── antlr4-cpp-runtime │ │ │ ├── ANTLRErrorListener.cpp │ │ │ ├── ANTLRErrorListener.h │ │ │ ├── ANTLRErrorStrategy.cpp │ │ │ ├── ANTLRErrorStrategy.h │ │ │ ├── ANTLRFileStream.cpp │ │ │ ├── ANTLRFileStream.h │ │ │ ├── ANTLRInputStream.cpp │ │ │ ├── ANTLRInputStream.h │ │ │ ├── BailErrorStrategy.cpp │ │ │ ├── BailErrorStrategy.h │ │ │ ├── BaseErrorListener.cpp │ │ │ ├── BaseErrorListener.h │ │ │ ├── BufferedTokenStream.cpp │ │ │ ├── BufferedTokenStream.h │ │ │ ├── CharStream.cpp │ │ │ ├── CharStream.h │ │ │ ├── CommonToken.cpp │ │ │ ├── CommonToken.h │ │ │ ├── CommonTokenFactory.cpp │ │ │ ├── CommonTokenFactory.h │ │ │ ├── CommonTokenStream.cpp │ │ │ ├── CommonTokenStream.h │ │ │ ├── ConsoleErrorListener.cpp │ │ │ ├── ConsoleErrorListener.h │ │ │ ├── DefaultErrorStrategy.cpp │ │ │ ├── DefaultErrorStrategy.h │ │ │ ├── DiagnosticErrorListener.cpp │ │ │ ├── DiagnosticErrorListener.h │ │ │ ├── Exceptions.cpp │ │ │ ├── Exceptions.h │ │ │ ├── FailedPredicateException.cpp │ │ │ ├── FailedPredicateException.h │ │ │ ├── FlatHashMap.h │ │ │ ├── FlatHashSet.h │ │ │ ├── InputMismatchException.cpp │ │ │ ├── InputMismatchException.h │ │ │ ├── IntStream.cpp │ │ │ ├── IntStream.h │ │ │ ├── InterpreterRuleContext.cpp │ │ │ ├── InterpreterRuleContext.h │ │ │ ├── Lexer.cpp │ │ │ ├── Lexer.h │ │ │ ├── LexerInterpreter.cpp │ │ │ ├── LexerInterpreter.h │ │ │ ├── LexerNoViableAltException.cpp │ │ │ ├── LexerNoViableAltException.h │ │ │ ├── ListTokenSource.cpp │ │ │ ├── ListTokenSource.h │ │ │ ├── NoViableAltException.cpp │ │ │ ├── NoViableAltException.h │ │ │ ├── Parser.cpp │ │ │ ├── Parser.h │ │ │ ├── ParserInterpreter.cpp │ │ │ ├── ParserInterpreter.h │ │ │ ├── ParserRuleContext.cpp │ │ │ ├── ParserRuleContext.h │ │ │ ├── ProxyErrorListener.cpp │ │ │ ├── ProxyErrorListener.h │ │ │ ├── RecognitionException.cpp │ │ │ ├── RecognitionException.h │ │ │ ├── Recognizer.cpp │ │ │ ├── Recognizer.h │ │ │ ├── RuleContext.cpp │ │ │ ├── RuleContext.h │ │ │ ├── RuleContextWithAltNum.cpp │ │ │ ├── RuleContextWithAltNum.h │ │ │ ├── RuntimeMetaData.cpp │ │ │ ├── RuntimeMetaData.h │ │ │ ├── Token.cpp │ │ │ ├── Token.h │ │ │ ├── TokenFactory.h │ │ │ ├── TokenSource.cpp │ │ │ ├── TokenSource.h │ │ │ ├── TokenStream.cpp │ │ │ ├── TokenStream.h │ │ │ ├── TokenStreamRewriter.cpp │ │ │ ├── TokenStreamRewriter.h │ │ │ ├── UnbufferedCharStream.cpp │ │ │ ├── UnbufferedCharStream.h │ │ │ ├── UnbufferedTokenStream.cpp │ │ │ ├── UnbufferedTokenStream.h │ │ │ ├── Version.h │ │ │ ├── Vocabulary.cpp │ │ │ ├── Vocabulary.h │ │ │ ├── WritableToken.cpp │ │ │ ├── WritableToken.h │ │ │ ├── antlr4-common.h │ │ │ ├── antlr4-runtime.h │ │ │ ├── atn │ │ │ │ ├── ATN.cpp │ │ │ │ ├── ATN.h │ │ │ │ ├── ATNConfig.cpp │ │ │ │ ├── ATNConfig.h │ │ │ │ ├── ATNConfigSet.cpp │ │ │ │ ├── ATNConfigSet.h │ │ │ │ ├── ATNDeserializationOptions.cpp │ │ │ │ ├── ATNDeserializationOptions.h │ │ │ │ ├── ATNDeserializer.cpp │ │ │ │ ├── ATNDeserializer.h │ │ │ │ ├── ATNSimulator.cpp │ │ │ │ ├── ATNSimulator.h │ │ │ │ ├── ATNState.cpp │ │ │ │ ├── ATNState.h │ │ │ │ ├── ATNStateType.cpp │ │ │ │ ├── ATNStateType.h │ │ │ │ ├── ATNType.h │ │ │ │ ├── ActionTransition.cpp │ │ │ │ ├── ActionTransition.h │ │ │ │ ├── AmbiguityInfo.cpp │ │ │ │ ├── AmbiguityInfo.h │ │ │ │ ├── ArrayPredictionContext.cpp │ │ │ │ ├── ArrayPredictionContext.h │ │ │ │ ├── AtomTransition.cpp │ │ │ │ ├── AtomTransition.h │ │ │ │ ├── BasicBlockStartState.h │ │ │ │ ├── BasicState.h │ │ │ │ ├── BlockEndState.h │ │ │ │ ├── BlockStartState.h │ │ │ │ ├── ContextSensitivityInfo.cpp │ │ │ │ ├── ContextSensitivityInfo.h │ │ │ │ ├── DecisionEventInfo.cpp │ │ │ │ ├── DecisionEventInfo.h │ │ │ │ ├── DecisionInfo.cpp │ │ │ │ ├── DecisionInfo.h │ │ │ │ ├── DecisionState.cpp │ │ │ │ ├── DecisionState.h │ │ │ │ ├── EpsilonTransition.cpp │ │ │ │ ├── EpsilonTransition.h │ │ │ │ ├── ErrorInfo.cpp │ │ │ │ ├── ErrorInfo.h │ │ │ │ ├── HashUtils.h │ │ │ │ ├── LL1Analyzer.cpp │ │ │ │ ├── LL1Analyzer.h │ │ │ │ ├── LexerATNConfig.cpp │ │ │ │ ├── LexerATNConfig.h │ │ │ │ ├── LexerATNSimulator.cpp │ │ │ │ ├── LexerATNSimulator.h │ │ │ │ ├── LexerAction.cpp │ │ │ │ ├── LexerAction.h │ │ │ │ ├── LexerActionExecutor.cpp │ │ │ │ ├── LexerActionExecutor.h │ │ │ │ ├── LexerActionType.h │ │ │ │ ├── LexerChannelAction.cpp │ │ │ │ ├── LexerChannelAction.h │ │ │ │ ├── LexerCustomAction.cpp │ │ │ │ ├── LexerCustomAction.h │ │ │ │ ├── LexerIndexedCustomAction.cpp │ │ │ │ ├── LexerIndexedCustomAction.h │ │ │ │ ├── LexerModeAction.cpp │ │ │ │ ├── LexerModeAction.h │ │ │ │ ├── LexerMoreAction.cpp │ │ │ │ ├── LexerMoreAction.h │ │ │ │ ├── LexerPopModeAction.cpp │ │ │ │ ├── LexerPopModeAction.h │ │ │ │ ├── LexerPushModeAction.cpp │ │ │ │ ├── LexerPushModeAction.h │ │ │ │ ├── LexerSkipAction.cpp │ │ │ │ ├── LexerSkipAction.h │ │ │ │ ├── LexerTypeAction.cpp │ │ │ │ ├── LexerTypeAction.h │ │ │ │ ├── LookaheadEventInfo.cpp │ │ │ │ ├── LookaheadEventInfo.h │ │ │ │ ├── LoopEndState.h │ │ │ │ ├── NotSetTransition.cpp │ │ │ │ ├── NotSetTransition.h │ │ │ │ ├── OrderedATNConfigSet.cpp │ │ │ │ ├── OrderedATNConfigSet.h │ │ │ │ ├── ParseInfo.cpp │ │ │ │ ├── ParseInfo.h │ │ │ │ ├── ParserATNSimulator.cpp │ │ │ │ ├── ParserATNSimulator.h │ │ │ │ ├── ParserATNSimulatorOptions.h │ │ │ │ ├── PlusBlockStartState.h │ │ │ │ ├── PlusLoopbackState.h │ │ │ │ ├── PrecedencePredicateTransition.cpp │ │ │ │ ├── PrecedencePredicateTransition.h │ │ │ │ ├── PredicateEvalInfo.cpp │ │ │ │ ├── PredicateEvalInfo.h │ │ │ │ ├── PredicateTransition.cpp │ │ │ │ ├── PredicateTransition.h │ │ │ │ ├── PredictionContext.cpp │ │ │ │ ├── PredictionContext.h │ │ │ │ ├── PredictionContextCache.cpp │ │ │ │ ├── PredictionContextCache.h │ │ │ │ ├── PredictionContextMergeCache.cpp │ │ │ │ ├── PredictionContextMergeCache.h │ │ │ │ ├── PredictionContextMergeCacheOptions.h │ │ │ │ ├── PredictionContextType.h │ │ │ │ ├── PredictionMode.cpp │ │ │ │ ├── PredictionMode.h │ │ │ │ ├── ProfilingATNSimulator.cpp │ │ │ │ ├── ProfilingATNSimulator.h │ │ │ │ ├── RangeTransition.cpp │ │ │ │ ├── RangeTransition.h │ │ │ │ ├── RuleStartState.h │ │ │ │ ├── RuleStopState.h │ │ │ │ ├── RuleTransition.cpp │ │ │ │ ├── RuleTransition.h │ │ │ │ ├── SemanticContext.cpp │ │ │ │ ├── SemanticContext.h │ │ │ │ ├── SemanticContextType.h │ │ │ │ ├── SerializedATNView.h │ │ │ │ ├── SetTransition.cpp │ │ │ │ ├── SetTransition.h │ │ │ │ ├── SingletonPredictionContext.cpp │ │ │ │ ├── SingletonPredictionContext.h │ │ │ │ ├── StarBlockStartState.h │ │ │ │ ├── StarLoopEntryState.h │ │ │ │ ├── StarLoopbackState.cpp │ │ │ │ ├── StarLoopbackState.h │ │ │ │ ├── TokensStartState.h │ │ │ │ ├── Transition.cpp │ │ │ │ ├── Transition.h │ │ │ │ ├── TransitionType.cpp │ │ │ │ ├── TransitionType.h │ │ │ │ ├── WildcardTransition.cpp │ │ │ │ └── WildcardTransition.h │ │ │ ├── dfa │ │ │ │ ├── DFA.cpp │ │ │ │ ├── DFA.h │ │ │ │ ├── DFASerializer.cpp │ │ │ │ ├── DFASerializer.h │ │ │ │ ├── DFAState.cpp │ │ │ │ ├── DFAState.h │ │ │ │ ├── LexerDFASerializer.cpp │ │ │ │ └── LexerDFASerializer.h │ │ │ ├── internal │ │ │ │ ├── Synchronization.cpp │ │ │ │ └── Synchronization.h │ │ │ ├── misc │ │ │ │ ├── InterpreterDataReader.cpp │ │ │ │ ├── InterpreterDataReader.h │ │ │ │ ├── Interval.cpp │ │ │ │ ├── Interval.h │ │ │ │ ├── IntervalSet.cpp │ │ │ │ ├── IntervalSet.h │ │ │ │ ├── MurmurHash.cpp │ │ │ │ ├── MurmurHash.h │ │ │ │ ├── Predicate.cpp │ │ │ │ └── Predicate.h │ │ │ ├── support │ │ │ │ ├── Any.cpp │ │ │ │ ├── Any.h │ │ │ │ ├── Arrays.cpp │ │ │ │ ├── Arrays.h │ │ │ │ ├── BitSet.h │ │ │ │ ├── CPPUtils.cpp │ │ │ │ ├── CPPUtils.h │ │ │ │ ├── Casts.h │ │ │ │ ├── Declarations.h │ │ │ │ ├── StringUtils.cpp │ │ │ │ ├── StringUtils.h │ │ │ │ ├── Unicode.h │ │ │ │ ├── Utf8.cpp │ │ │ │ └── Utf8.h │ │ │ └── tree │ │ │ │ ├── AbstractParseTreeVisitor.h │ │ │ │ ├── ErrorNode.h │ │ │ │ ├── ErrorNodeImpl.cpp │ │ │ │ ├── ErrorNodeImpl.h │ │ │ │ ├── IterativeParseTreeWalker.cpp │ │ │ │ ├── IterativeParseTreeWalker.h │ │ │ │ ├── ParseTree.cpp │ │ │ │ ├── ParseTree.h │ │ │ │ ├── ParseTreeListener.cpp │ │ │ │ ├── ParseTreeListener.h │ │ │ │ ├── ParseTreeProperty.h │ │ │ │ ├── ParseTreeType.h │ │ │ │ ├── ParseTreeVisitor.cpp │ │ │ │ ├── ParseTreeVisitor.h │ │ │ │ ├── ParseTreeWalker.cpp │ │ │ │ ├── ParseTreeWalker.h │ │ │ │ ├── TerminalNode.h │ │ │ │ ├── TerminalNodeImpl.cpp │ │ │ │ ├── TerminalNodeImpl.h │ │ │ │ ├── Trees.cpp │ │ │ │ ├── Trees.h │ │ │ │ ├── pattern │ │ │ │ ├── Chunk.cpp │ │ │ │ ├── Chunk.h │ │ │ │ ├── ParseTreeMatch.cpp │ │ │ │ ├── ParseTreeMatch.h │ │ │ │ ├── ParseTreePattern.cpp │ │ │ │ ├── ParseTreePattern.h │ │ │ │ ├── ParseTreePatternMatcher.cpp │ │ │ │ ├── ParseTreePatternMatcher.h │ │ │ │ ├── RuleTagToken.cpp │ │ │ │ ├── RuleTagToken.h │ │ │ │ ├── TagChunk.cpp │ │ │ │ ├── TagChunk.h │ │ │ │ ├── TextChunk.cpp │ │ │ │ ├── TextChunk.h │ │ │ │ ├── TokenTagToken.cpp │ │ │ │ └── TokenTagToken.h │ │ │ │ └── xpath │ │ │ │ ├── XPath.cpp │ │ │ │ ├── XPath.h │ │ │ │ ├── XPathElement.cpp │ │ │ │ ├── XPathElement.h │ │ │ │ ├── XPathLexer.cpp │ │ │ │ ├── XPathLexer.g4 │ │ │ │ ├── XPathLexer.h │ │ │ │ ├── XPathLexer.interp │ │ │ │ ├── XPathLexer.tokens │ │ │ │ ├── XPathLexerErrorListener.cpp │ │ │ │ ├── XPathLexerErrorListener.h │ │ │ │ ├── XPathRuleAnywhereElement.cpp │ │ │ │ ├── XPathRuleAnywhereElement.h │ │ │ │ ├── XPathRuleElement.cpp │ │ │ │ ├── XPathRuleElement.h │ │ │ │ ├── XPathTokenAnywhereElement.cpp │ │ │ │ ├── XPathTokenAnywhereElement.h │ │ │ │ ├── XPathTokenElement.cpp │ │ │ │ ├── XPathTokenElement.h │ │ │ │ ├── XPathWildcardAnywhereElement.cpp │ │ │ │ ├── XPathWildcardAnywhereElement.h │ │ │ │ ├── XPathWildcardElement.cpp │ │ │ │ └── XPathWildcardElement.h │ │ ├── sa_systemrdl_cpp_parser.cpp │ │ ├── sa_systemrdl_translator.cpp │ │ ├── sa_systemrdl_translator.h │ │ ├── speedy_antlr.cpp │ │ └── speedy_antlr.h │ ├── generate_parser.sh │ └── sa_systemrdl.py │ ├── preprocessor │ ├── __init__.py │ ├── perl_preprocessor.py │ ├── ppp_runner.pl │ ├── segment_map.py │ ├── stream.py │ └── verilog_preprocessor.py │ ├── properties │ ├── __init__.py │ ├── bases.py │ ├── builtin.py │ ├── prop_refs.py │ ├── rulebook.py │ └── user_defined.py │ ├── py.typed │ ├── rdltypes │ ├── __init__.py │ ├── array.py │ ├── builtin_enums.py │ ├── references.py │ ├── typing.py │ ├── user_enum.py │ └── user_struct.py │ ├── source_ref.py │ ├── udp.py │ ├── walker.py │ └── warnings.py └── test ├── .coveragerc ├── lib ├── __init__.py └── type_hint_utils.py ├── mypy.ini ├── pylint.rc ├── rdl_err_src ├── err_allocators1.rdl ├── err_allocators2.rdl ├── err_allocators3.rdl ├── err_bridge.rdl ├── err_compile.rdl ├── err_duplicate_udp.rdl ├── err_incomplete_struct.rdl ├── err_mem_defs.rdl ├── err_ref_in_parameter.rdl ├── err_reset_signals.rdl ├── err_singlepulse.rdl ├── err_syntax.rdl ├── err_validate.rdl ├── err_we_wel.rdl └── prop_ref_err.rdl ├── rdl_src ├── address_packing.rdl ├── alias.rdl ├── bridge.rdl ├── counter_examples.rdl ├── counter_extras.rdl ├── dpa_names.rdl ├── enums.rdl ├── enums_in_expressions.rdl ├── field_access_types.rdl ├── field_gaps.rdl ├── field_packing.rdl ├── global_type_names.rdl ├── incdir │ └── preprocessor_incl2.rdl ├── incomplete_struct.rdl ├── internal_external.rdl ├── intr_prop.rdl ├── intr_prop_mod.rdl ├── memories.rdl ├── parameters.rdl ├── preprocessor.rdl ├── preprocessor_CRLF.rdl ├── preprocessor_incl.rdl ├── prop_ref-in_array.rdl ├── prop_ref-inferred_vector.rdl ├── prop_ref-value_ref.rdl ├── properties.rdl ├── property_side_effects.rdl ├── property_typecast.rdl ├── rdlformatcode.rdl ├── references_default_lhs.rdl ├── references_direct_lhs.rdl ├── references_dynamic_lhs.rdl ├── reset_signals.rdl ├── scopes.rdl ├── signal_scope.rdl ├── signals.rdl ├── signals_and_reset.rdl ├── struct_compositions.rdl ├── structs.rdl ├── udp_15.2.2_ex1.rdl ├── udp_15.2.2_ex2.rdl ├── udp_arrays.rdl ├── udp_builtin.rdl └── udp_types.rdl ├── requirements.txt ├── run.sh ├── test_accesstype.py ├── test_aliases.py ├── test_api_type_hints.py ├── test_bridge.py ├── test_counters.py ├── test_dpa_type_names.py ├── test_enums.py ├── test_errors.py ├── test_expressions.py ├── test_external.py ├── test_global_type_names.py ├── test_importer.py ├── test_inferred_placement.py ├── test_intr_prop.py ├── test_memories.py ├── test_misc_examples.py ├── test_node_utils.py ├── test_parameters.py ├── test_parse_accelerator.py ├── test_preprocessor.py ├── test_prop_refs.py ├── test_prop_side_effects.py ├── test_prop_typecast.py ├── test_properties.py ├── test_property_errors.py ├── test_rdlformatcode.py ├── test_references.py ├── test_scopes.py ├── test_signals.py ├── test_structs.py ├── test_udp.py └── unittest_utils.py /.gitattributes: -------------------------------------------------------------------------------- 1 | systemrdl/parser/* linguist-generated 2 | systemrdl/parser/ext/* linguist-generated 3 | systemrdl/parser/ext/antlr4-cpp-runtime/** linguist-vendored 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: The compiler is not doing what I expected 4 | title: "[BUG]" 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | - [ ] I have reviewed this project's [contribution guidelines](https://github.com/SystemRDL/systemrdl-compiler/blob/main/CONTRIBUTING.md) 11 | 12 | **Describe the bug** 13 | A clear and concise description of what the bug is. 14 | 15 | Details like these can be helpful: 16 | * Sample SystemRDL code 17 | * Error message 18 | * Version numbers for the tool, Python, and OS 19 | 20 | 21 | **Expected behavior** 22 | A clear and concise description of what you expected to happen. 23 | 24 | 25 | **Additional context** 26 | Add any other context about the problem here. 27 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[FEATURE]" 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | - [ ] I have reviewed this project's [contribution guidelines](https://github.com/SystemRDL/systemrdl-compiler/blob/main/CONTRIBUTING.md) 11 | 12 | **Describe the problem/limitation you think should be addressed** 13 | A clear and concise description of what the problem is. 14 | 15 | **Describe the solution you'd like** 16 | A clear and concise description of what you want to happen. 17 | 18 | **Describe alternatives you've considered** 19 | A clear and concise description of any alternative solutions or features you've considered. 20 | 21 | **Additional context** 22 | Add any other context or about the feature request here. 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: I have a question 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | Please consider using the discussion board for more open-ended questions: https://github.com/orgs/SystemRDL/discussions 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/__pycache__ 2 | **/.antlr 3 | **/.vscode 4 | **/*.o 5 | **/*.so 6 | **/.venv 7 | **/.coverage 8 | **/.coverage.* 9 | **/*.rpt 10 | **/htmlcov 11 | **/*.so 12 | **/.idea 13 | 14 | build/ 15 | dist/ 16 | *.egg-info/ 17 | .eggs/ 18 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 2 | 3 | version: 2 4 | 5 | build: 6 | os: ubuntu-22.04 7 | tools: 8 | python: "3.11" 9 | apt_packages: 10 | - graphviz 11 | 12 | sphinx: 13 | configuration: docs/conf.py 14 | 15 | python: 16 | install: 17 | - requirements: docs/requirements.txt 18 | - method: pip 19 | path: . 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Alex Mykyta 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | recursive-exclude test * 2 | recursive-exclude docs * 3 | recursive-exclude examples * 4 | recursive-exclude .github * 5 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | _build 2 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SOURCEDIR = . 8 | BUILDDIR = _build 9 | 10 | # Put it first so that "make" without argument is like "make help". 11 | help: 12 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 13 | 14 | .PHONY: help Makefile 15 | 16 | # Catch-all target: route all unknown targets to Sphinx using the new 17 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 18 | %: Makefile 19 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 20 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Documentation 2 | 3 | Rendered documentation pages are hosted here: http://systemrdl-compiler.readthedocs.io 4 | -------------------------------------------------------------------------------- /docs/_static/css/theme_overrides.css: -------------------------------------------------------------------------------- 1 | /* override table width restrictions */ 2 | @media screen and (min-width: 767px) { 3 | 4 | .wy-table-responsive table td { 5 | /* !important prevents the common CSS stylesheets from overriding 6 | this as on RTD they are loaded after this stylesheet */ 7 | white-space: normal !important; 8 | } 9 | 10 | .wy-table-responsive { 11 | overflow: visible !important; 12 | } 13 | 14 | th p { 15 | margin-bottom: 0px; 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /docs/api/compiler.rst: -------------------------------------------------------------------------------- 1 | 2 | Compiler 3 | ======== 4 | 5 | .. autoclass:: systemrdl.RDLCompiler 6 | :members: 7 | 8 | .. autoclass:: systemrdl.compiler.FileInfo 9 | :members: 10 | -------------------------------------------------------------------------------- /docs/api/component.rst: -------------------------------------------------------------------------------- 1 | .. _api_component: 2 | 3 | Component 4 | ========= 5 | 6 | Base classes 7 | ------------ 8 | 9 | Component 10 | ^^^^^^^^^ 11 | .. autoclass:: systemrdl.component.Component 12 | :members: 13 | 14 | AddressableComponent 15 | ^^^^^^^^^^^^^^^^^^^^ 16 | .. autoclass:: systemrdl.component.AddressableComponent 17 | :members: 18 | 19 | VectorComponent 20 | ^^^^^^^^^^^^^^^ 21 | .. autoclass:: systemrdl.component.VectorComponent 22 | :members: 23 | 24 | -------------------------------------------------------------------------------- 25 | 26 | Component Types 27 | --------------- 28 | 29 | Signal 30 | ^^^^^^ 31 | .. autoclass:: systemrdl.component.Signal 32 | :members: 33 | 34 | Field 35 | ^^^^^ 36 | .. autoclass:: systemrdl.component.Field 37 | :members: 38 | 39 | Reg 40 | ^^^ 41 | .. autoclass:: systemrdl.component.Reg 42 | :members: 43 | 44 | Regfile 45 | ^^^^^^^ 46 | .. autoclass:: systemrdl.component.Regfile 47 | :members: 48 | 49 | Addrmap 50 | ^^^^^^^ 51 | .. autoclass:: systemrdl.component.Addrmap 52 | :members: 53 | 54 | Mem 55 | ^^^ 56 | .. autoclass:: systemrdl.component.Mem 57 | :members: 58 | -------------------------------------------------------------------------------- /docs/api/messages.rst: -------------------------------------------------------------------------------- 1 | 2 | Messages 3 | ======== 4 | 5 | .. _messages_warnings: 6 | 7 | Warnings 8 | -------- 9 | The SystemRDL compiler provides several optional warnings. These lint-like 10 | checks report constructs that are not inherently wrong, but may be considered 11 | risky. 12 | 13 | All warning messages are disabled by default. 14 | 15 | Individual warning messages can be enabled by passing one or more of the 16 | following flags into the ``warning_flags`` option of the 17 | :class:`~systemrdl.RDLCompiler` constructor. Multiple flags can be combined 18 | using bitwise OR (the ``|`` operator). 19 | 20 | .. autodata:: systemrdl.warnings.ALL 21 | :annotation: 22 | 23 | .. autodata:: systemrdl.warnings.MISSING_RESET 24 | :annotation: 25 | 26 | .. autodata:: systemrdl.warnings.IMPLICIT_FIELD_POS 27 | :annotation: 28 | 29 | .. autodata:: systemrdl.warnings.IMPLICIT_ADDR 30 | :annotation: 31 | 32 | .. autodata:: systemrdl.warnings.STRIDE_NOT_POW2 33 | :annotation: 34 | 35 | .. autodata:: systemrdl.warnings.STRICT_SELF_ALIGN 36 | :annotation: 37 | 38 | 39 | Exceptions 40 | ---------- 41 | .. autoclass:: systemrdl.RDLCompileError 42 | :members: 43 | 44 | 45 | Message Handling 46 | ---------------- 47 | 48 | .. warning:: 49 | 50 | The ``MessagePrinter`` and ``MessageHandler`` classes will be deprecated in 51 | a future release. See the following page for details: https://github.com/SystemRDL/systemrdl-compiler/issues/168 52 | 53 | .. autoclass:: systemrdl.messages.MessagePrinter 54 | :members: 55 | 56 | .. autoclass:: systemrdl.messages.MessageHandler() 57 | :members: 58 | -------------------------------------------------------------------------------- /docs/api/node.rst: -------------------------------------------------------------------------------- 1 | .. _api_node: 2 | 3 | Node 4 | ==== 5 | 6 | Base classes 7 | ------------ 8 | 9 | Node 10 | ^^^^ 11 | .. autoclass:: systemrdl.node.Node 12 | :members: 13 | :undoc-members: 14 | 15 | .. automethod:: systemrdl.node.Node.__eq__ 16 | 17 | .. automethod:: systemrdl.node.Node.__deepcopy__ 18 | 19 | AddressableNode 20 | ^^^^^^^^^^^^^^^ 21 | .. autoclass:: systemrdl.node.AddressableNode 22 | :members: 23 | :undoc-members: 24 | 25 | VectorNode 26 | ^^^^^^^^^^ 27 | .. autoclass:: systemrdl.node.VectorNode 28 | :members: 29 | :undoc-members: 30 | 31 | -------------------------------------------------------------------------------- 32 | 33 | Component Nodes 34 | --------------- 35 | 36 | SignalNode 37 | ^^^^^^^^^^ 38 | .. autoclass:: systemrdl.node.SignalNode 39 | :members: 40 | :undoc-members: 41 | 42 | FieldNode 43 | ^^^^^^^^^ 44 | .. autoclass:: systemrdl.node.FieldNode 45 | :members: 46 | :undoc-members: 47 | 48 | RegNode 49 | ^^^^^^^ 50 | .. autoclass:: systemrdl.node.RegNode 51 | :members: 52 | :undoc-members: 53 | 54 | RegfileNode 55 | ^^^^^^^^^^^ 56 | .. autoclass:: systemrdl.node.RegfileNode 57 | :members: 58 | :undoc-members: 59 | 60 | AddrmapNode 61 | ^^^^^^^^^^^ 62 | .. autoclass:: systemrdl.node.AddrmapNode 63 | :members: 64 | :undoc-members: 65 | 66 | MemNode 67 | ^^^^^^^ 68 | .. autoclass:: systemrdl.node.MemNode 69 | :members: 70 | :undoc-members: 71 | 72 | -------------------------------------------------------------------------------- 73 | 74 | Other 75 | ----- 76 | 77 | RootNode 78 | ^^^^^^^^^^ 79 | .. autoclass:: systemrdl.node.RootNode 80 | :members: 81 | :undoc-members: 82 | -------------------------------------------------------------------------------- /docs/api/source_ref.rst: -------------------------------------------------------------------------------- 1 | .. _api_src_ref: 2 | 3 | Source Reference 4 | ================ 5 | 6 | Every :ref:`api_component` in a SystemRDL register model is capable of providing 7 | contextual information about where it originated: 8 | 9 | * Component definition: :attr:`systemrdl.component.Component.def_src_ref` 10 | * Component instantiation: :attr:`systemrdl.component.Component.inst_src_ref` 11 | 12 | Similarly, information about where in the source a property assignment occurred 13 | is available via: :attr:`systemrdl.component.Component.property_src_ref` 14 | 15 | .. autoclass:: systemrdl.source_ref.SourceRefBase 16 | 17 | .. autoclass:: systemrdl.source_ref.FileSourceRef 18 | :members: path 19 | 20 | .. autoclass:: systemrdl.source_ref.DetailedFileSourceRef 21 | :members: 22 | -------------------------------------------------------------------------------- /docs/api/walker.rst: -------------------------------------------------------------------------------- 1 | 2 | Walker/Listener 3 | =============== 4 | 5 | Walker 6 | ------ 7 | .. autoclass:: systemrdl.RDLWalker 8 | :members: 9 | 10 | Listener 11 | -------- 12 | .. autoclass:: systemrdl.RDLListener 13 | :members: 14 | :undoc-members: 15 | 16 | 17 | .. autoclass:: systemrdl.WalkerAction 18 | :members: 19 | -------------------------------------------------------------------------------- /docs/dev_notes/antlr.rst: -------------------------------------------------------------------------------- 1 | 2 | Antlr 3 | ===== 4 | 5 | This is only required by the developer to re-generate the lexer/parser 6 | based on a grammar file. 7 | 8 | From: https://github.com/antlr/antlr4/blob/master/doc/getting-started.md 9 | 10 | Download antlr4:: 11 | 12 | cd /usr/local/lib 13 | sudo curl -O https://www.antlr.org/download/antlr-4.13.1-complete.jar 14 | 15 | 16 | Antlr API reference: http://www.antlr.org/api/Java/index.html 17 | 18 | 19 | Upgrading the Antlr version 20 | --------------------------- 21 | 22 | * Download latest jar file (See above) 23 | * Install latest python packages:: 24 | 25 | python3 -m pip install -U antlr4-python3-runtime speedy-antlr-tool mypy 26 | 27 | * Download C++ runtime source distribution from https://www.antlr.org/download.html 28 | 29 | * Extract zip 30 | * Update: ``/runtime/src`` to ``systemrdl/parser/ext/antlr4-cpp-runtime`` 31 | 32 | * Update ``systemrdl/parser/generate_parser.sh`` to point to the latest antlr jar 33 | * Run ``systemrdl/parser/generate_parser.sh`` 34 | * Increment systemrdl minor version 35 | * Update antlr runtime version pins in ``setup.py`` 36 | * Run unit tests 37 | * Publish release! 38 | -------------------------------------------------------------------------------- /docs/dev_notes/logbook.rst: -------------------------------------------------------------------------------- 1 | 2 | Logbook 3 | ======= 4 | 5 | This section contains a lot of my personal "logbook" notes that go into more 6 | detail about how some components of the compiler are implemented. 7 | Many of the notes capture my original thought process on how to organize the 8 | project and may serve as a useful reference to future contributors. 9 | 10 | .. toctree:: 11 | :maxdepth: 1 12 | 13 | multi_file_compilation 14 | compilation 15 | preprocessors 16 | perl_preprocessing 17 | namespaces 18 | properties 19 | dpa_type_generation 20 | expressions 21 | hierarchical_references 22 | instance_arrays 23 | inferred_placement 24 | rdl_format_code 25 | user_tree_traversal 26 | antlr 27 | 28 | -------------------------------------------------------------------------------- /docs/dev_notes/rdl_format_code.rst: -------------------------------------------------------------------------------- 1 | 2 | Implementation of RDLFormatCode 3 | =============================== 4 | 5 | A simple RDLFormatCode processing function is accessible via the Node API that 6 | handles conversion of a raw ``desc`` property into HTML. Mapping from RDLFC to 7 | HTML is actually pretty trivial, but here are some additional considerations. 8 | 9 | Array index tags 10 | ---------------- 11 | 12 | In order to support dynamic page generation, the ``[index]`` and 13 | ``[index_parent]`` tags are outputted as ```` tags. These tags are 14 | annotated with ``class='rdlfc-index'`` and ``class='rdlfc-index_parent'`` 15 | respectively. The tag's text contains the indexes as described by the spec. 16 | Annotating the tags with a class allows dynamic HTML pages to 17 | search-and-replace the contents of these tags with updated values 18 | as-appropriate. 19 | 20 | The ``[desc]`` tag 21 | ------------------ 22 | 23 | Intentionally not implemented. 24 | 25 | See :ref:`SystemRDL Spec Errata ` for more 26 | details. 27 | 28 | 29 | Markdown Extension 30 | ------------------ 31 | 32 | After RDLFormatCode processing, the resulting text is passed through a Markdown 33 | formatter. This gives the user the option to use a more modern lightweight 34 | markup language as an alternative to RDLFormatCode. 35 | -------------------------------------------------------------------------------- /docs/dev_notes/semantic_checks.ods: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SystemRDL/systemrdl-compiler/e6bd222554912fdc6a183e6674a6ba5d75e07632/docs/dev_notes/semantic_checks.ods -------------------------------------------------------------------------------- /docs/examples/print_hierarchy_spi.stdout: -------------------------------------------------------------------------------- 1 | atxmega_spi 2 | CTRL 3 | [1:0] PRESCALER sw=rw 4 | [3:2] MODE sw=rw 5 | [4:4] MASTER sw=rw 6 | [5:5] DORD sw=rw 7 | [6:6] ENABLE sw=rw 8 | [7:7] CLK2X sw=rw 9 | INTCTRL 10 | [1:0] INTLVL sw=rw 11 | STATUS 12 | [6:6] WRCOL sw=r 13 | [7:7] IF sw=r 14 | DATA 15 | [7:0] WDATA sw=w 16 | [7:0] RDATA sw=r 17 | -------------------------------------------------------------------------------- /docs/genindex.rst: -------------------------------------------------------------------------------- 1 | 2 | Index 3 | ===== 4 | -------------------------------------------------------------------------------- /docs/img/diagrams.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SystemRDL/systemrdl-compiler/e6bd222554912fdc6a183e6674a6ba5d75e07632/docs/img/diagrams.odg -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | pygments-systemrdl 2 | git+https://github.com/amykyta3/sphinx_csv_filter.git 3 | 4 | sphinx >= 5.0.0 5 | sphinx-rtd-theme >= 1.0.0 6 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Examples 2 | 3 | For a walk-through of these examples, see the [SystemRDL Compiler Documentation](https://systemrdl-compiler.readthedocs.io) 4 | -------------------------------------------------------------------------------- /examples/tiny.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "addrmap", 3 | "inst_name": "tiny", 4 | "addr_offset": 0, 5 | "children": [ 6 | { 7 | "type": "reg", 8 | "inst_name": "r1", 9 | "addr_offset": 0, 10 | "children": [ 11 | { 12 | "type": "field", 13 | "inst_name": "f1", 14 | "lsb": 0, 15 | "msb": 7, 16 | "reset": 123, 17 | "sw_access": "rw" 18 | }, 19 | { 20 | "type": "field", 21 | "inst_name": "f2", 22 | "lsb": 8, 23 | "msb": 15, 24 | "reset": null, 25 | "sw_access": "r" 26 | } 27 | ] 28 | } 29 | ] 30 | } -------------------------------------------------------------------------------- /examples/tiny.rdl: -------------------------------------------------------------------------------- 1 | addrmap tiny { 2 | reg { 3 | field { 4 | sw=rw; 5 | hw=r; 6 | } f1[8] = 123; 7 | 8 | field { 9 | sw=r; 10 | hw=w; 11 | } f2[8]; 12 | }r1; 13 | }; 14 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools", "setuptools-scm"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [project] 6 | name = "systemrdl-compiler" 7 | dynamic = ["version"] 8 | requires-python = ">=3.7" 9 | dependencies = [ 10 | "antlr4-python3-runtime >= 4.11, < 4.14", 11 | "colorama", 12 | "markdown", 13 | "typing_extensions", 14 | ] 15 | authors = [ 16 | {name="Alex Mykyta"}, 17 | ] 18 | description="Parse and elaborate front-end for SystemRDL 2.0" 19 | readme = "README.md" 20 | license = {text = "MIT"} 21 | keywords = [ 22 | "SystemRDL", "CSR", "compiler", "tool", "registers", "generator", 23 | "register abstraction layer", "FPGA", "ASIC", 24 | ] 25 | classifiers = [ 26 | "Development Status :: 5 - Production/Stable", 27 | "Programming Language :: Python", 28 | "Programming Language :: Python :: 3", 29 | "Programming Language :: Python :: 3 :: Only", 30 | "Intended Audience :: Developers", 31 | "License :: OSI Approved :: MIT License", 32 | "Operating System :: OS Independent", 33 | "Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)", 34 | "Topic :: Software Development :: Compilers", 35 | "Topic :: Software Development :: Code Generators", 36 | ] 37 | 38 | [project.urls] 39 | Source = "https://github.com/SystemRDL/systemrdl-compiler" 40 | Tracker = "https://github.com/SystemRDL/systemrdl-compiler/issues" 41 | Changelog = "https://github.com/SystemRDL/systemrdl-compiler/releases" 42 | Documentation = "http://systemrdl-compiler.readthedocs.io" 43 | 44 | [tool.setuptools.dynamic] 45 | version = {attr = "systemrdl.__about__.__version__"} 46 | -------------------------------------------------------------------------------- /src/systemrdl/__about__.py: -------------------------------------------------------------------------------- 1 | __version__ = "1.29.3" 2 | -------------------------------------------------------------------------------- /src/systemrdl/__init__.py: -------------------------------------------------------------------------------- 1 | from .__about__ import __version__ 2 | 3 | from .compiler import RDLCompiler 4 | from .importer import RDLImporter 5 | from .walker import RDLListener, RDLWalker, WalkerAction 6 | from .messages import RDLCompileError 7 | 8 | from .node import AddressableNode, VectorNode, SignalNode 9 | from .node import FieldNode, RegNode, RegfileNode, AddrmapNode, MemNode 10 | 11 | from .component import AddressableComponent, VectorComponent, Signal 12 | from .component import Field, Reg, Regfile, Addrmap, Mem 13 | -------------------------------------------------------------------------------- /src/systemrdl/ast/__init__.py: -------------------------------------------------------------------------------- 1 | from .ast_node import ASTNode 2 | 3 | from .literals import BoolLiteral, IntLiteral, StringLiteral 4 | from .literals import BuiltinEnumLiteral, EnumLiteral 5 | from .literals import StructLiteral, ArrayLiteral, ExternalLiteral 6 | 7 | from .references import ParameterRef, ArrayIndex, MemberRef, InstRef, PropRef 8 | 9 | from .relational import Eq, Neq, Lt, Gt, Leq, Geq 10 | 11 | from .sequence import Concatenate, Replicate 12 | 13 | from .binary import Add, Sub, Mult, Div, Mod 14 | from .binary import BitwiseAnd, BitwiseOr, BitwiseXor, BitwiseXnor 15 | 16 | from .unary import UnaryPlus, UnaryMinus, BitwiseInvert 17 | 18 | from .reduction import AndReduce, NandReduce, OrReduce, NorReduce, XorReduce, XnorReduce, BoolNot 19 | 20 | from .exponential import Exponent, LShift, RShift 21 | 22 | from .boolean import BoolAnd, BoolOr 23 | 24 | from .conditional import Conditional 25 | 26 | from .cast import WidthCast, BoolCast, AssignmentCast, is_castable 27 | -------------------------------------------------------------------------------- /src/systemrdl/core/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SystemRDL/systemrdl-compiler/e6bd222554912fdc6a183e6674a6ba5d75e07632/src/systemrdl/core/__init__.py -------------------------------------------------------------------------------- /src/systemrdl/parser/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SystemRDL/systemrdl-compiler/e6bd222554912fdc6a183e6674a6ba5d75e07632/src/systemrdl/parser/__init__.py -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/SystemRDLBaseVisitor.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Generated from SystemRDL.g4 by ANTLR 4.13.1 3 | 4 | 5 | #include "SystemRDLBaseVisitor.h" 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/SystemRDLVisitor.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Generated from SystemRDL.g4 by ANTLR 4.13.1 3 | 4 | 5 | #include "SystemRDLVisitor.h" 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/ANTLRErrorListener.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "ANTLRErrorListener.h" 7 | 8 | antlr4::ANTLRErrorListener::~ANTLRErrorListener() 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/ANTLRErrorStrategy.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "ANTLRErrorStrategy.h" 7 | 8 | antlr4::ANTLRErrorStrategy::~ANTLRErrorStrategy() 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/ANTLRFileStream.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "ANTLRFileStream.h" 7 | 8 | using namespace antlr4; 9 | 10 | void ANTLRFileStream::loadFromFile(const std::string &fileName) { 11 | _fileName = fileName; 12 | if (_fileName.empty()) { 13 | return; 14 | } 15 | 16 | std::ifstream stream(fileName, std::ios::binary); 17 | 18 | ANTLRInputStream::load(stream); 19 | } 20 | 21 | std::string ANTLRFileStream::getSourceName() const { 22 | return _fileName; 23 | } 24 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/ANTLRFileStream.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "ANTLRInputStream.h" 9 | 10 | namespace antlr4 { 11 | 12 | /// This is an ANTLRInputStream that is loaded from a file all at once 13 | /// when you construct the object (or call load()). 14 | // TODO: this class needs testing. 15 | class ANTLR4CPP_PUBLIC ANTLRFileStream : public ANTLRInputStream { 16 | public: 17 | ANTLRFileStream() = default; 18 | ANTLRFileStream(const std::string &) = delete; 19 | ANTLRFileStream(const char *data, size_t length) = delete; 20 | ANTLRFileStream(std::istream &stream) = delete; 21 | 22 | // Assumes a file name encoded in UTF-8 and file content in the same encoding (with or w/o BOM). 23 | virtual void loadFromFile(const std::string &fileName); 24 | virtual std::string getSourceName() const override; 25 | 26 | private: 27 | std::string _fileName; // UTF-8 encoded file name. 28 | }; 29 | 30 | } // namespace antlr4 31 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/BaseErrorListener.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "BaseErrorListener.h" 7 | #include "RecognitionException.h" 8 | 9 | using namespace antlr4; 10 | 11 | void BaseErrorListener::syntaxError(Recognizer * /*recognizer*/, Token * /*offendingSymbol*/, size_t /*line*/, 12 | size_t /*charPositionInLine*/, const std::string &/*msg*/, std::exception_ptr /*e*/) { 13 | } 14 | 15 | void BaseErrorListener::reportAmbiguity(Parser * /*recognizer*/, const dfa::DFA &/*dfa*/, size_t /*startIndex*/, 16 | size_t /*stopIndex*/, bool /*exact*/, const antlrcpp::BitSet &/*ambigAlts*/, atn::ATNConfigSet * /*configs*/) { 17 | } 18 | 19 | void BaseErrorListener::reportAttemptingFullContext(Parser * /*recognizer*/, const dfa::DFA &/*dfa*/, size_t /*startIndex*/, 20 | size_t /*stopIndex*/, const antlrcpp::BitSet &/*conflictingAlts*/, atn::ATNConfigSet * /*configs*/) { 21 | } 22 | 23 | void BaseErrorListener::reportContextSensitivity(Parser * /*recognizer*/, const dfa::DFA &/*dfa*/, size_t /*startIndex*/, 24 | size_t /*stopIndex*/, size_t /*prediction*/, atn::ATNConfigSet * /*configs*/) { 25 | } 26 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/BaseErrorListener.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "ANTLRErrorListener.h" 9 | 10 | namespace antlrcpp { 11 | class BitSet; 12 | } 13 | 14 | namespace antlr4 { 15 | 16 | /** 17 | * Provides an empty default implementation of {@link ANTLRErrorListener}. The 18 | * default implementation of each method does nothing, but can be overridden as 19 | * necessary. 20 | */ 21 | class ANTLR4CPP_PUBLIC BaseErrorListener : public ANTLRErrorListener { 22 | 23 | virtual void syntaxError(Recognizer *recognizer, Token * offendingSymbol, size_t line, size_t charPositionInLine, 24 | const std::string &msg, std::exception_ptr e) override; 25 | 26 | virtual void reportAmbiguity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, bool exact, 27 | const antlrcpp::BitSet &ambigAlts, atn::ATNConfigSet *configs) override; 28 | 29 | virtual void reportAttemptingFullContext(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, 30 | const antlrcpp::BitSet &conflictingAlts, atn::ATNConfigSet *configs) override; 31 | 32 | virtual void reportContextSensitivity(Parser *recognizer, const dfa::DFA &dfa, size_t startIndex, size_t stopIndex, 33 | size_t prediction, atn::ATNConfigSet *configs) override; 34 | }; 35 | 36 | } // namespace antlr4 37 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/CharStream.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "CharStream.h" 7 | 8 | using namespace antlr4; 9 | 10 | CharStream::~CharStream() { 11 | } 12 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/CharStream.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "IntStream.h" 9 | #include "misc/Interval.h" 10 | 11 | namespace antlr4 { 12 | 13 | /// A source of characters for an ANTLR lexer. 14 | class ANTLR4CPP_PUBLIC CharStream : public IntStream { 15 | public: 16 | virtual ~CharStream(); 17 | 18 | /// This method returns the text for a range of characters within this input 19 | /// stream. This method is guaranteed to not throw an exception if the 20 | /// specified interval lies entirely within a marked range. For more 21 | /// information about marked ranges, see IntStream::mark. 22 | /// 23 | /// an interval within the stream 24 | /// the text of the specified interval 25 | /// 26 | /// if {@code interval} is {@code null} 27 | /// if {@code interval.a < 0}, or if 28 | /// {@code interval.b < interval.a - 1}, or if {@code interval.b} lies at or 29 | /// past the end of the stream 30 | /// if the stream does not support 31 | /// getting the text of the specified interval 32 | virtual std::string getText(const misc::Interval &interval) = 0; 33 | 34 | virtual std::string toString() const = 0; 35 | }; 36 | 37 | } // namespace antlr4 38 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/CommonTokenFactory.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/Interval.h" 7 | #include "CommonToken.h" 8 | #include "CharStream.h" 9 | 10 | #include "CommonTokenFactory.h" 11 | 12 | using namespace antlr4; 13 | 14 | const std::unique_ptr> CommonTokenFactory::DEFAULT(new CommonTokenFactory); 15 | 16 | CommonTokenFactory::CommonTokenFactory(bool copyText_) : copyText(copyText_) { 17 | } 18 | 19 | CommonTokenFactory::CommonTokenFactory() : CommonTokenFactory(false) { 20 | } 21 | 22 | std::unique_ptr CommonTokenFactory::create(std::pair source, size_t type, 23 | const std::string &text, size_t channel, size_t start, size_t stop, size_t line, size_t charPositionInLine) { 24 | 25 | std::unique_ptr t(new CommonToken(source, type, channel, start, stop)); 26 | t->setLine(line); 27 | t->setCharPositionInLine(charPositionInLine); 28 | if (text != "") { 29 | t->setText(text); 30 | } else if (copyText && source.second != nullptr) { 31 | t->setText(source.second->getText(misc::Interval(start, stop))); 32 | } 33 | 34 | return t; 35 | } 36 | 37 | std::unique_ptr CommonTokenFactory::create(size_t type, const std::string &text) { 38 | return std::unique_ptr(new CommonToken(type, text)); 39 | } 40 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/ConsoleErrorListener.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "ConsoleErrorListener.h" 7 | 8 | using namespace antlr4; 9 | 10 | ConsoleErrorListener ConsoleErrorListener::INSTANCE; 11 | 12 | void ConsoleErrorListener::syntaxError(Recognizer * /*recognizer*/, Token * /*offendingSymbol*/, 13 | size_t line, size_t charPositionInLine, const std::string &msg, std::exception_ptr /*e*/) { 14 | std::cerr << "line " << line << ":" << charPositionInLine << " " << msg << std::endl; 15 | } 16 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/ConsoleErrorListener.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "BaseErrorListener.h" 9 | 10 | namespace antlr4 { 11 | 12 | class ANTLR4CPP_PUBLIC ConsoleErrorListener : public BaseErrorListener { 13 | public: 14 | /** 15 | * Provides a default instance of {@link ConsoleErrorListener}. 16 | */ 17 | static ConsoleErrorListener INSTANCE; 18 | 19 | /** 20 | * {@inheritDoc} 21 | * 22 | *

23 | * This implementation prints messages to {@link System#err} containing the 24 | * values of {@code line}, {@code charPositionInLine}, and {@code msg} using 25 | * the following format.

26 | * 27 | *
28 |      * line line:charPositionInLine msg
29 |      * 
30 | */ 31 | virtual void syntaxError(Recognizer *recognizer, Token * offendingSymbol, size_t line, size_t charPositionInLine, 32 | const std::string &msg, std::exception_ptr e) override; 33 | }; 34 | 35 | } // namespace antlr4 36 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/FailedPredicateException.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "RecognitionException.h" 9 | 10 | namespace antlr4 { 11 | 12 | /// A semantic predicate failed during validation. Validation of predicates 13 | /// occurs when normally parsing the alternative just like matching a token. 14 | /// Disambiguating predicate evaluation occurs when we test a predicate during 15 | /// prediction. 16 | class ANTLR4CPP_PUBLIC FailedPredicateException : public RecognitionException { 17 | public: 18 | explicit FailedPredicateException(Parser *recognizer); 19 | FailedPredicateException(Parser *recognizer, const std::string &predicate); 20 | FailedPredicateException(Parser *recognizer, const std::string &predicate, const std::string &message); 21 | 22 | virtual size_t getRuleIndex(); 23 | virtual size_t getPredIndex(); 24 | virtual std::string getPredicate(); 25 | 26 | private: 27 | size_t _ruleIndex; 28 | size_t _predicateIndex; 29 | std::string _predicate; 30 | }; 31 | 32 | } // namespace antlr4 33 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/InputMismatchException.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Parser.h" 7 | 8 | #include "InputMismatchException.h" 9 | 10 | using namespace antlr4; 11 | 12 | InputMismatchException::InputMismatchException(Parser *recognizer) 13 | : RecognitionException(recognizer, recognizer->getInputStream(), recognizer->getContext(), 14 | recognizer->getCurrentToken()) { 15 | } 16 | 17 | InputMismatchException::~InputMismatchException() { 18 | } 19 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/InputMismatchException.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "RecognitionException.h" 9 | 10 | namespace antlr4 { 11 | 12 | /// 13 | /// This signifies any kind of mismatched input exceptions such as 14 | /// when the current input does not match the expected token. 15 | /// 16 | class ANTLR4CPP_PUBLIC InputMismatchException : public RecognitionException { 17 | public: 18 | InputMismatchException(Parser *recognizer); 19 | InputMismatchException(InputMismatchException const&) = default; 20 | ~InputMismatchException(); 21 | InputMismatchException& operator=(InputMismatchException const&) = default; 22 | }; 23 | 24 | } // namespace antlr4 25 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/IntStream.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "IntStream.h" 7 | 8 | using namespace antlr4; 9 | 10 | const std::string IntStream::UNKNOWN_SOURCE_NAME = ""; 11 | 12 | IntStream::~IntStream() = default; 13 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/InterpreterRuleContext.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "InterpreterRuleContext.h" 7 | 8 | using namespace antlr4; 9 | 10 | InterpreterRuleContext::InterpreterRuleContext() : ParserRuleContext() { 11 | } 12 | 13 | InterpreterRuleContext::InterpreterRuleContext(ParserRuleContext *parent, size_t invokingStateNumber, size_t ruleIndex) 14 | : ParserRuleContext(parent, invokingStateNumber), _ruleIndex(ruleIndex) { 15 | } 16 | 17 | size_t InterpreterRuleContext::getRuleIndex() const { 18 | return _ruleIndex; 19 | } 20 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/LexerNoViableAltException.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/Interval.h" 7 | #include "support/CPPUtils.h" 8 | #include "CharStream.h" 9 | #include "Lexer.h" 10 | 11 | #include "LexerNoViableAltException.h" 12 | 13 | using namespace antlr4; 14 | 15 | LexerNoViableAltException::LexerNoViableAltException(Lexer *lexer, CharStream *input, size_t startIndex, 16 | atn::ATNConfigSet *deadEndConfigs) 17 | : RecognitionException(lexer, input, nullptr, nullptr), _startIndex(startIndex), _deadEndConfigs(deadEndConfigs) { 18 | } 19 | 20 | size_t LexerNoViableAltException::getStartIndex() { 21 | return _startIndex; 22 | } 23 | 24 | atn::ATNConfigSet* LexerNoViableAltException::getDeadEndConfigs() { 25 | return _deadEndConfigs; 26 | } 27 | 28 | std::string LexerNoViableAltException::toString() { 29 | std::string symbol; 30 | if (_startIndex < getInputStream()->size()) { 31 | symbol = static_cast(getInputStream())->getText(misc::Interval(_startIndex, _startIndex)); 32 | symbol = antlrcpp::escapeWhitespace(symbol, false); 33 | } 34 | std::string format = "LexerNoViableAltException('" + symbol + "')"; 35 | return format; 36 | } 37 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/LexerNoViableAltException.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "RecognitionException.h" 9 | #include "atn/ATNConfigSet.h" 10 | 11 | namespace antlr4 { 12 | 13 | class ANTLR4CPP_PUBLIC LexerNoViableAltException : public RecognitionException { 14 | public: 15 | LexerNoViableAltException(Lexer *lexer, CharStream *input, size_t startIndex, 16 | atn::ATNConfigSet *deadEndConfigs); 17 | 18 | virtual size_t getStartIndex(); 19 | virtual atn::ATNConfigSet* getDeadEndConfigs(); 20 | virtual std::string toString(); 21 | 22 | private: 23 | /// Matching attempted at what input index? 24 | const size_t _startIndex; 25 | 26 | /// Which configurations did we try at input.index() that couldn't match input.LA(1)? 27 | atn::ATNConfigSet *_deadEndConfigs; 28 | 29 | }; 30 | 31 | } // namespace antlr4 32 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/RuleContextWithAltNum.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/ATN.h" 7 | 8 | #include "RuleContextWithAltNum.h" 9 | 10 | using namespace antlr4; 11 | using namespace antlr4::atn; 12 | 13 | RuleContextWithAltNum::RuleContextWithAltNum() : ParserRuleContext() { 14 | altNum = ATN::INVALID_ALT_NUMBER; 15 | } 16 | 17 | RuleContextWithAltNum::RuleContextWithAltNum(ParserRuleContext *parent, int invokingStateNumber) 18 | : ParserRuleContext(parent, invokingStateNumber) { 19 | } 20 | 21 | size_t RuleContextWithAltNum::getAltNumber() const { 22 | return altNum; 23 | } 24 | 25 | void RuleContextWithAltNum::setAltNumber(size_t number) { 26 | altNum = number; 27 | } 28 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/RuleContextWithAltNum.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "ParserRuleContext.h" 9 | 10 | namespace antlr4 { 11 | 12 | /// A handy class for use with 13 | /// 14 | /// options {contextSuperClass=org.antlr.v4.runtime.RuleContextWithAltNum;} 15 | /// 16 | /// that provides a backing field / impl for the outer alternative number 17 | /// matched for an internal parse tree node. 18 | /// 19 | /// I'm only putting into Java runtime as I'm certain I'm the only one that 20 | /// will really every use this. 21 | class ANTLR4CPP_PUBLIC RuleContextWithAltNum : public ParserRuleContext { 22 | public: 23 | size_t altNum = 0; 24 | 25 | RuleContextWithAltNum(); 26 | RuleContextWithAltNum(ParserRuleContext *parent, int invokingStateNumber); 27 | 28 | virtual size_t getAltNumber() const override; 29 | virtual void setAltNumber(size_t altNum) override; 30 | }; 31 | 32 | } // namespace antlr4 33 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/Token.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Token.h" 7 | 8 | antlr4::Token::~Token() { 9 | } 10 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/TokenFactory.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | 12 | /// The default mechanism for creating tokens. It's used by default in Lexer and 13 | /// the error handling strategy (to create missing tokens). Notifying the parser 14 | /// of a new factory means that it notifies it's token source and error strategy. 15 | template 16 | class ANTLR4CPP_PUBLIC TokenFactory { 17 | public: 18 | virtual ~TokenFactory() {} 19 | 20 | /// This is the method used to create tokens in the lexer and in the 21 | /// error handling strategy. If text!=null, than the start and stop positions 22 | /// are wiped to -1 in the text override is set in the CommonToken. 23 | virtual std::unique_ptr create(std::pair source, size_t type, const std::string &text, 24 | size_t channel, size_t start, size_t stop, size_t line, size_t charPositionInLine) = 0; 25 | 26 | /// Generically useful 27 | virtual std::unique_ptr create(size_t type, const std::string &text) = 0; 28 | }; 29 | 30 | } // namespace antlr4 31 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/TokenSource.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "TokenSource.h" 7 | 8 | antlr4::TokenSource::~TokenSource() { 9 | } 10 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/TokenStream.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "TokenStream.h" 7 | 8 | using namespace antlr4; 9 | 10 | TokenStream::~TokenStream() { 11 | } 12 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/WritableToken.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "WritableToken.h" 7 | 8 | antlr4::WritableToken::~WritableToken() { 9 | } 10 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/WritableToken.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "Token.h" 9 | 10 | namespace antlr4 { 11 | 12 | class ANTLR4CPP_PUBLIC WritableToken : public Token { 13 | public: 14 | virtual ~WritableToken(); 15 | virtual void setText(const std::string &text) = 0; 16 | virtual void setType(size_t ttype) = 0; 17 | virtual void setLine(size_t line) = 0; 18 | virtual void setCharPositionInLine(size_t pos) = 0; 19 | virtual void setChannel(size_t channel) = 0; 20 | virtual void setTokenIndex(size_t index) = 0; 21 | }; 22 | 23 | } // namespace antlr4 24 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/ATNDeserializationOptions.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/ATNDeserializationOptions.h" 7 | #include "Exceptions.h" 8 | 9 | using namespace antlr4; 10 | using namespace antlr4::atn; 11 | 12 | ATNDeserializationOptions::ATNDeserializationOptions(ATNDeserializationOptions *options) 13 | : _readOnly(false), _verifyATN(options->_verifyATN), 14 | _generateRuleBypassTransitions(options->_generateRuleBypassTransitions) {} 15 | 16 | const ATNDeserializationOptions& ATNDeserializationOptions::getDefaultOptions() { 17 | static const ATNDeserializationOptions* const defaultOptions = new ATNDeserializationOptions(); 18 | return *defaultOptions; 19 | } 20 | 21 | void ATNDeserializationOptions::makeReadOnly() { 22 | _readOnly = true; 23 | } 24 | 25 | void ATNDeserializationOptions::setVerifyATN(bool verify) { 26 | throwIfReadOnly(); 27 | _verifyATN = verify; 28 | } 29 | 30 | void ATNDeserializationOptions::setGenerateRuleBypassTransitions(bool generate) { 31 | throwIfReadOnly(); 32 | _generateRuleBypassTransitions = generate; 33 | } 34 | 35 | void ATNDeserializationOptions::throwIfReadOnly() const { 36 | if (isReadOnly()) { 37 | throw IllegalStateException("ATNDeserializationOptions is read only."); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/ATNDeserializationOptions.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC ATNDeserializationOptions final { 14 | public: 15 | ATNDeserializationOptions() 16 | : _readOnly(false), _verifyATN(true), _generateRuleBypassTransitions(false) {} 17 | 18 | // TODO: Is this useful? If so we should mark it as explicit, otherwise remove it. 19 | ATNDeserializationOptions(ATNDeserializationOptions *options); 20 | 21 | ATNDeserializationOptions(const ATNDeserializationOptions&) = default; 22 | 23 | ATNDeserializationOptions& operator=(const ATNDeserializationOptions&) = default; 24 | 25 | static const ATNDeserializationOptions& getDefaultOptions(); 26 | 27 | bool isReadOnly() const { return _readOnly; } 28 | 29 | void makeReadOnly(); 30 | 31 | bool isVerifyATN() const { return _verifyATN; } 32 | 33 | void setVerifyATN(bool verify); 34 | 35 | bool isGenerateRuleBypassTransitions() const { return _generateRuleBypassTransitions; } 36 | 37 | void setGenerateRuleBypassTransitions(bool generate); 38 | 39 | private: 40 | void throwIfReadOnly() const; 41 | 42 | bool _readOnly; 43 | bool _verifyATN; 44 | bool _generateRuleBypassTransitions; 45 | }; 46 | 47 | } // namespace atn 48 | } // namespace antlr4 49 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/ATNDeserializer.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNDeserializationOptions.h" 9 | #include "atn/SerializedATNView.h" 10 | #include "atn/LexerAction.h" 11 | #include "atn/Transition.h" 12 | 13 | namespace antlr4 { 14 | namespace atn { 15 | 16 | class ANTLR4CPP_PUBLIC ATNDeserializer final { 17 | public: 18 | static constexpr size_t SERIALIZED_VERSION = 4; 19 | 20 | ATNDeserializer(); 21 | 22 | explicit ATNDeserializer(ATNDeserializationOptions deserializationOptions); 23 | 24 | std::unique_ptr deserialize(SerializedATNView input) const; 25 | void verifyATN(const ATN &atn) const; 26 | 27 | private: 28 | const ATNDeserializationOptions _deserializationOptions; 29 | }; 30 | 31 | } // namespace atn 32 | } // namespace antlr4 33 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/ATNSimulator.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/ATNSimulator.h" 7 | 8 | #include "atn/ATNConfigSet.h" 9 | #include "atn/ATNDeserializer.h" 10 | #include "atn/ATNType.h" 11 | #include "dfa/DFAState.h" 12 | 13 | using namespace antlr4; 14 | using namespace antlr4::dfa; 15 | using namespace antlr4::atn; 16 | 17 | const Ref ATNSimulator::ERROR = std::make_shared(std::numeric_limits::max()); 18 | 19 | ATNSimulator::ATNSimulator(const ATN &atn, PredictionContextCache &sharedContextCache) 20 | : atn(atn), _sharedContextCache(sharedContextCache) {} 21 | 22 | void ATNSimulator::clearDFA() { 23 | throw UnsupportedOperationException("This ATN simulator does not support clearing the DFA."); 24 | } 25 | 26 | PredictionContextCache& ATNSimulator::getSharedContextCache() const { 27 | return _sharedContextCache; 28 | } 29 | 30 | Ref ATNSimulator::getCachedContext(const Ref &context) { 31 | // This function must only be called with an active state lock, as we are going to change a shared structure. 32 | return PredictionContext::getCachedContext(context, getSharedContextCache()); 33 | } 34 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/ATNStateType.cpp: -------------------------------------------------------------------------------- 1 | #include "atn/ATNStateType.h" 2 | 3 | std::string antlr4::atn::atnStateTypeName(ATNStateType atnStateType) { 4 | switch (atnStateType) { 5 | case ATNStateType::INVALID: 6 | return "INVALID"; 7 | case ATNStateType::BASIC: 8 | return "BASIC"; 9 | case ATNStateType::RULE_START: 10 | return "RULE_START"; 11 | case ATNStateType::BLOCK_START: 12 | return "BLOCK_START"; 13 | case ATNStateType::PLUS_BLOCK_START: 14 | return "PLUS_BLOCK_START"; 15 | case ATNStateType::STAR_BLOCK_START: 16 | return "STAR_BLOCK_START"; 17 | case ATNStateType::TOKEN_START: 18 | return "TOKEN_START"; 19 | case ATNStateType::RULE_STOP: 20 | return "RULE_STOP"; 21 | case ATNStateType::BLOCK_END: 22 | return "BLOCK_END"; 23 | case ATNStateType::STAR_LOOP_BACK: 24 | return "STAR_LOOP_BACK"; 25 | case ATNStateType::STAR_LOOP_ENTRY: 26 | return "STAR_LOOP_ENTRY"; 27 | case ATNStateType::PLUS_LOOP_BACK: 28 | return "PLUS_LOOP_BACK"; 29 | case ATNStateType::LOOP_END: 30 | return "LOOP_END"; 31 | } 32 | return "UNKNOWN"; 33 | } 34 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/ATNStateType.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | #include "antlr4-common.h" 12 | 13 | namespace antlr4 { 14 | namespace atn { 15 | 16 | // Constants for ATNState serialization. 17 | enum class ATNStateType : size_t { 18 | INVALID = 0, 19 | BASIC = 1, 20 | RULE_START = 2, 21 | BLOCK_START = 3, 22 | PLUS_BLOCK_START = 4, 23 | STAR_BLOCK_START = 5, 24 | TOKEN_START = 6, 25 | RULE_STOP = 7, 26 | BLOCK_END = 8, 27 | STAR_LOOP_BACK = 9, 28 | STAR_LOOP_ENTRY = 10, 29 | PLUS_LOOP_BACK = 11, 30 | LOOP_END = 12, 31 | }; 32 | 33 | ANTLR4CPP_PUBLIC std::string atnStateTypeName(ATNStateType atnStateType); 34 | 35 | } // namespace atn 36 | } // namespace antlr4 37 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/ATNType.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// Represents the type of recognizer an ATN applies to. 14 | enum class ATNType { 15 | LEXER = 0, 16 | PARSER = 1, 17 | }; 18 | 19 | } // namespace atn 20 | } // namespace antlr4 21 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/ActionTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/ActionTransition.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | ActionTransition::ActionTransition(ATNState *target, size_t ruleIndex) 11 | : Transition(TransitionType::ACTION, target), ruleIndex(ruleIndex), actionIndex(INVALID_INDEX), isCtxDependent(false) { 12 | } 13 | 14 | ActionTransition::ActionTransition(ATNState *target, size_t ruleIndex, size_t actionIndex, bool isCtxDependent) 15 | : Transition(TransitionType::ACTION, target), ruleIndex(ruleIndex), actionIndex(actionIndex), isCtxDependent(isCtxDependent) { 16 | } 17 | 18 | bool ActionTransition::isEpsilon() const { 19 | return true; // we are to be ignored by analysis 'cept for predicates 20 | } 21 | 22 | bool ActionTransition::matches(size_t /*symbol*/, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const { 23 | return false; 24 | } 25 | 26 | std::string ActionTransition::toString() const { 27 | return " ACTION " + Transition::toString() + " { ruleIndex: " + std::to_string(ruleIndex) + ", actionIndex: " + 28 | std::to_string(actionIndex) + ", isCtxDependent: " + std::to_string(isCtxDependent) + " }"; 29 | } 30 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/ActionTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC ActionTransition final : public Transition { 14 | public: 15 | static bool is(const Transition &transition) { return transition.getTransitionType() == TransitionType::ACTION; } 16 | 17 | static bool is(const Transition *transition) { return transition != nullptr && is(*transition); } 18 | 19 | const size_t ruleIndex; 20 | const size_t actionIndex; 21 | const bool isCtxDependent; // e.g., $i ref in action 22 | 23 | ActionTransition(ATNState *target, size_t ruleIndex); 24 | 25 | ActionTransition(ATNState *target, size_t ruleIndex, size_t actionIndex, bool isCtxDependent); 26 | 27 | virtual bool isEpsilon() const override; 28 | 29 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 30 | 31 | virtual std::string toString() const override; 32 | }; 33 | 34 | } // namespace atn 35 | } // namespace antlr4 36 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/AmbiguityInfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/AmbiguityInfo.h" 7 | 8 | using namespace antlr4; 9 | using namespace antlr4::atn; 10 | 11 | AmbiguityInfo::AmbiguityInfo(size_t decision, ATNConfigSet *configs, const antlrcpp::BitSet &ambigAlts, 12 | TokenStream *input, size_t startIndex, size_t stopIndex, bool fullCtx) 13 | : DecisionEventInfo(decision, configs, input, startIndex, stopIndex, fullCtx) { 14 | 15 | this->ambigAlts = ambigAlts; 16 | } 17 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/AtomTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/IntervalSet.h" 7 | #include "atn/Transition.h" 8 | 9 | #include "atn/AtomTransition.h" 10 | 11 | using namespace antlr4::misc; 12 | using namespace antlr4::atn; 13 | 14 | AtomTransition::AtomTransition(ATNState *target, size_t label) : Transition(TransitionType::ATOM, target), _label(label) { 15 | } 16 | 17 | IntervalSet AtomTransition::label() const { 18 | return IntervalSet::of((int)_label); 19 | } 20 | 21 | bool AtomTransition::matches(size_t symbol, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const { 22 | return _label == symbol; 23 | } 24 | 25 | std::string AtomTransition::toString() const { 26 | return "ATOM " + Transition::toString() + " { label: " + std::to_string(_label) + " }"; 27 | } 28 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/AtomTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// TODO: make all transitions sets? no, should remove set edges. 14 | class ANTLR4CPP_PUBLIC AtomTransition final : public Transition { 15 | public: 16 | static bool is(const Transition &transition) { return transition.getTransitionType() == TransitionType::ATOM; } 17 | 18 | static bool is(const Transition *transition) { return transition != nullptr && is(*transition); } 19 | 20 | /// The token type or character value; or, signifies special label. 21 | /// TODO: rename this to label 22 | const size_t _label; 23 | 24 | AtomTransition(ATNState *target, size_t label); 25 | 26 | virtual misc::IntervalSet label() const override; 27 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 28 | 29 | virtual std::string toString() const override; 30 | }; 31 | 32 | } // namespace atn 33 | } // namespace antlr4 34 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/BasicBlockStartState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | #include "atn/BlockStartState.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | class ANTLR4CPP_PUBLIC BasicBlockStartState final : public BlockStartState { 15 | public: 16 | static bool is(const ATNState &atnState) { return atnState.getStateType() == ATNStateType::BLOCK_START; } 17 | 18 | static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); } 19 | 20 | BasicBlockStartState() : BlockStartState(ATNStateType::BLOCK_START) {} 21 | }; 22 | 23 | } // namespace atn 24 | } // namespace antlr4 25 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/BasicState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC BasicState final : public ATNState { 14 | public: 15 | static bool is(const ATNState &atnState) { return atnState.getStateType() == ATNStateType::BASIC; } 16 | 17 | static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); } 18 | 19 | BasicState() : ATNState(ATNStateType::BASIC) {} 20 | }; 21 | 22 | } // namespace atn 23 | } // namespace antlr4 24 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/BlockEndState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// Terminal node of a simple {@code (a|b|c)} block. 14 | class ANTLR4CPP_PUBLIC BlockEndState final : public ATNState { 15 | public: 16 | static bool is(const ATNState &atnState) { return atnState.getStateType() == ATNStateType::BLOCK_END; } 17 | 18 | static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); } 19 | 20 | BlockStartState *startState = nullptr; 21 | 22 | BlockEndState() : ATNState(ATNStateType::BLOCK_END) {} 23 | }; 24 | 25 | } // namespace atn 26 | } // namespace antlr4 27 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/BlockStartState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/DecisionState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// The start of a regular {@code (...)} block. 14 | class ANTLR4CPP_PUBLIC BlockStartState : public DecisionState { 15 | public: 16 | static bool is(const ATNState &atnState) { 17 | const auto stateType = atnState.getStateType(); 18 | return stateType >= ATNStateType::BLOCK_START && stateType <= ATNStateType::STAR_BLOCK_START; 19 | } 20 | 21 | static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); } 22 | 23 | BlockEndState *endState = nullptr; 24 | 25 | protected: 26 | using DecisionState::DecisionState; 27 | }; 28 | 29 | } // namespace atn 30 | } // namespace antlr4 31 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/ContextSensitivityInfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/ContextSensitivityInfo.h" 7 | 8 | using namespace antlr4; 9 | using namespace antlr4::atn; 10 | 11 | ContextSensitivityInfo::ContextSensitivityInfo(size_t decision, ATNConfigSet *configs, TokenStream *input, 12 | size_t startIndex, size_t stopIndex) 13 | : DecisionEventInfo(decision, configs, input, startIndex, stopIndex, true) { 14 | } 15 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/DecisionEventInfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/DecisionEventInfo.h" 7 | 8 | using namespace antlr4; 9 | using namespace antlr4::atn; 10 | 11 | DecisionEventInfo::DecisionEventInfo(size_t decision, ATNConfigSet *configs, TokenStream *input, size_t startIndex, 12 | size_t stopIndex, bool fullCtx) 13 | : decision(decision), configs(configs), input(input), startIndex(startIndex), stopIndex(stopIndex), fullCtx(fullCtx) { 14 | } 15 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/DecisionInfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/ErrorInfo.h" 7 | #include "atn/LookaheadEventInfo.h" 8 | 9 | #include "atn/DecisionInfo.h" 10 | 11 | using namespace antlr4::atn; 12 | 13 | DecisionInfo::DecisionInfo(size_t decision) : decision(decision) { 14 | } 15 | 16 | std::string DecisionInfo::toString() const { 17 | std::stringstream ss; 18 | 19 | ss << "{decision=" << decision << ", contextSensitivities=" << contextSensitivities.size() << ", errors="; 20 | ss << errors.size() << ", ambiguities=" << ambiguities.size() << ", SLL_lookahead=" << SLL_TotalLook; 21 | ss << ", SLL_ATNTransitions=" << SLL_ATNTransitions << ", SLL_DFATransitions=" << SLL_DFATransitions; 22 | ss << ", LL_Fallback=" << LL_Fallback << ", LL_lookahead=" << LL_TotalLook << ", LL_ATNTransitions=" << LL_ATNTransitions << '}'; 23 | 24 | return ss.str(); 25 | } 26 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/DecisionState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/DecisionState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | std::string DecisionState::toString() const { 11 | return ATNState::toString(); 12 | } 13 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/DecisionState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC DecisionState : public ATNState { 14 | public: 15 | static bool is(const ATNState &atnState) { 16 | const auto stateType = atnState.getStateType(); 17 | return (stateType >= ATNStateType::BLOCK_START && stateType <= ATNStateType::TOKEN_START) || 18 | stateType == ATNStateType::PLUS_LOOP_BACK || 19 | stateType == ATNStateType::STAR_LOOP_ENTRY; 20 | } 21 | 22 | static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); } 23 | 24 | int decision = -1; 25 | bool nonGreedy = false; 26 | 27 | virtual std::string toString() const override; 28 | 29 | protected: 30 | using ATNState::ATNState; 31 | }; 32 | 33 | } // namespace atn 34 | } // namespace antlr4 35 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/EpsilonTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/EpsilonTransition.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | EpsilonTransition::EpsilonTransition(ATNState *target) : EpsilonTransition(target, INVALID_INDEX) { 11 | } 12 | 13 | EpsilonTransition::EpsilonTransition(ATNState *target, size_t outermostPrecedenceReturn) 14 | : Transition(TransitionType::EPSILON, target), _outermostPrecedenceReturn(outermostPrecedenceReturn) { 15 | } 16 | 17 | size_t EpsilonTransition::outermostPrecedenceReturn() const { 18 | return _outermostPrecedenceReturn; 19 | } 20 | 21 | bool EpsilonTransition::isEpsilon() const { 22 | return true; 23 | } 24 | 25 | bool EpsilonTransition::matches(size_t /*symbol*/, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const { 26 | return false; 27 | } 28 | 29 | std::string EpsilonTransition::toString() const { 30 | return "EPSILON " + Transition::toString() + " {}"; 31 | } 32 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/EpsilonTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC EpsilonTransition final : public Transition { 14 | public: 15 | static bool is(const Transition &transition) { return transition.getTransitionType() == TransitionType::EPSILON; } 16 | 17 | static bool is(const Transition *transition) { return transition != nullptr && is(*transition); } 18 | 19 | explicit EpsilonTransition(ATNState *target); 20 | EpsilonTransition(ATNState *target, size_t outermostPrecedenceReturn); 21 | 22 | /** 23 | * @return the rule index of a precedence rule for which this transition is 24 | * returning from, where the precedence value is 0; otherwise, INVALID_INDEX. 25 | * 26 | * @see ATNConfig#isPrecedenceFilterSuppressed() 27 | * @see ParserATNSimulator#applyPrecedenceFilter(ATNConfigSet) 28 | * @since 4.4.1 29 | */ 30 | size_t outermostPrecedenceReturn() const; 31 | 32 | virtual bool isEpsilon() const override; 33 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 34 | 35 | virtual std::string toString() const override; 36 | 37 | private: 38 | const size_t _outermostPrecedenceReturn; // A rule index. 39 | }; 40 | 41 | } // namespace atn 42 | } // namespace antlr4 43 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/ErrorInfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/ATNConfigSet.h" 7 | 8 | #include "atn/ErrorInfo.h" 9 | 10 | using namespace antlr4; 11 | using namespace antlr4::atn; 12 | 13 | ErrorInfo::ErrorInfo(size_t decision, ATNConfigSet *configs, TokenStream *input, size_t startIndex, size_t stopIndex, bool fullCtx) 14 | : DecisionEventInfo(decision, configs, input, startIndex, stopIndex, fullCtx) { 15 | } 16 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/HashUtils.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2022 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | inline bool cachedHashCodeEqual(size_t lhs, size_t rhs) { 14 | return lhs == rhs || lhs == 0 || rhs == 0; 15 | } 16 | 17 | } // namespace atn 18 | } // namespace antlr4 19 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/LexerAction.cpp: -------------------------------------------------------------------------------- 1 | #include "LexerAction.h" 2 | 3 | using namespace antlr4::atn; 4 | 5 | size_t LexerAction::hashCode() const { 6 | auto hash = cachedHashCode(); 7 | if (hash == 0) { 8 | hash = hashCodeImpl(); 9 | if (hash == 0) { 10 | hash = std::numeric_limits::max(); 11 | } 12 | _hashCode.store(hash, std::memory_order_relaxed); 13 | } 14 | return hash; 15 | } 16 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/LexerChannelAction.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/MurmurHash.h" 7 | #include "Lexer.h" 8 | #include "support/Casts.h" 9 | 10 | #include "atn/LexerChannelAction.h" 11 | 12 | using namespace antlr4::atn; 13 | using namespace antlr4::misc; 14 | using namespace antlrcpp; 15 | 16 | LexerChannelAction::LexerChannelAction(int channel) 17 | : LexerAction(LexerActionType::CHANNEL, false), _channel(channel) {} 18 | 19 | void LexerChannelAction::execute(Lexer *lexer) const { 20 | lexer->setChannel(getChannel()); 21 | } 22 | 23 | size_t LexerChannelAction::hashCodeImpl() const { 24 | size_t hash = MurmurHash::initialize(); 25 | hash = MurmurHash::update(hash, static_cast(getActionType())); 26 | hash = MurmurHash::update(hash, getChannel()); 27 | return MurmurHash::finish(hash, 2); 28 | } 29 | 30 | bool LexerChannelAction::equals(const LexerAction &other) const { 31 | if (this == std::addressof(other)) { 32 | return true; 33 | } 34 | if (getActionType() != other.getActionType()) { 35 | return false; 36 | } 37 | const auto &lexerAction = downCast(other); 38 | return getChannel() == lexerAction.getChannel(); 39 | } 40 | 41 | std::string LexerChannelAction::toString() const { 42 | return "channel(" + std::to_string(getChannel()) + ")"; 43 | } 44 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/LexerModeAction.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/MurmurHash.h" 7 | #include "Lexer.h" 8 | #include "support/Casts.h" 9 | 10 | #include "atn/LexerModeAction.h" 11 | 12 | using namespace antlr4; 13 | using namespace antlr4::atn; 14 | using namespace antlr4::misc; 15 | using namespace antlrcpp; 16 | 17 | LexerModeAction::LexerModeAction(int mode) : LexerAction(LexerActionType::MODE, false), _mode(mode) {} 18 | 19 | void LexerModeAction::execute(Lexer *lexer) const { 20 | lexer->setMode(getMode()); 21 | } 22 | 23 | size_t LexerModeAction::hashCodeImpl() const { 24 | size_t hash = MurmurHash::initialize(); 25 | hash = MurmurHash::update(hash, static_cast(getActionType())); 26 | hash = MurmurHash::update(hash, getMode()); 27 | return MurmurHash::finish(hash, 2); 28 | } 29 | 30 | bool LexerModeAction::equals(const LexerAction &other) const { 31 | if (this == std::addressof(other)) { 32 | return true; 33 | } 34 | if (getActionType() != other.getActionType()) { 35 | return false; 36 | } 37 | const auto &lexerAction = downCast(other); 38 | return getMode() == lexerAction.getMode(); 39 | } 40 | 41 | std::string LexerModeAction::toString() const { 42 | return "mode(" + std::to_string(getMode()) + ")"; 43 | } 44 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/LexerMoreAction.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/MurmurHash.h" 7 | #include "Lexer.h" 8 | 9 | #include "atn/LexerMoreAction.h" 10 | 11 | using namespace antlr4; 12 | using namespace antlr4::atn; 13 | using namespace antlr4::misc; 14 | 15 | const Ref& LexerMoreAction::getInstance() { 16 | static const Ref instance(new LexerMoreAction()); 17 | return instance; 18 | } 19 | 20 | void LexerMoreAction::execute(Lexer *lexer) const { 21 | lexer->more(); 22 | } 23 | 24 | size_t LexerMoreAction::hashCodeImpl() const { 25 | size_t hash = MurmurHash::initialize(); 26 | hash = MurmurHash::update(hash, static_cast(getActionType())); 27 | return MurmurHash::finish(hash, 1); 28 | } 29 | 30 | bool LexerMoreAction::equals(const LexerAction &other) const { 31 | return this == std::addressof(other); 32 | } 33 | 34 | std::string LexerMoreAction::toString() const { 35 | return "more"; 36 | } 37 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/LexerPopModeAction.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/MurmurHash.h" 7 | #include "Lexer.h" 8 | 9 | #include "atn/LexerPopModeAction.h" 10 | 11 | using namespace antlr4; 12 | using namespace antlr4::atn; 13 | using namespace antlr4::misc; 14 | 15 | const Ref& LexerPopModeAction::getInstance() { 16 | static const Ref instance(new LexerPopModeAction()); 17 | return instance; 18 | } 19 | 20 | void LexerPopModeAction::execute(Lexer *lexer) const { 21 | lexer->popMode(); 22 | } 23 | 24 | size_t LexerPopModeAction::hashCodeImpl() const { 25 | size_t hash = MurmurHash::initialize(); 26 | hash = MurmurHash::update(hash, static_cast(getActionType())); 27 | return MurmurHash::finish(hash, 1); 28 | } 29 | 30 | bool LexerPopModeAction::equals(const LexerAction &other) const { 31 | return this == std::addressof(other); 32 | } 33 | 34 | std::string LexerPopModeAction::toString() const { 35 | return "popMode"; 36 | } 37 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/LexerPushModeAction.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/MurmurHash.h" 7 | #include "Lexer.h" 8 | #include "support/Casts.h" 9 | 10 | #include "atn/LexerPushModeAction.h" 11 | 12 | using namespace antlr4; 13 | using namespace antlr4::atn; 14 | using namespace antlr4::misc; 15 | using namespace antlrcpp; 16 | 17 | LexerPushModeAction::LexerPushModeAction(int mode) : LexerAction(LexerActionType::PUSH_MODE, false), _mode(mode) {} 18 | 19 | void LexerPushModeAction::execute(Lexer *lexer) const { 20 | lexer->pushMode(getMode()); 21 | } 22 | 23 | size_t LexerPushModeAction::hashCodeImpl() const { 24 | size_t hash = MurmurHash::initialize(); 25 | hash = MurmurHash::update(hash, static_cast(getActionType())); 26 | hash = MurmurHash::update(hash, getMode()); 27 | return MurmurHash::finish(hash, 2); 28 | } 29 | 30 | bool LexerPushModeAction::equals(const LexerAction &other) const { 31 | if (this == std::addressof(other)) { 32 | return true; 33 | } 34 | if (getActionType() != other.getActionType()) { 35 | return false; 36 | } 37 | const auto &lexerAction = downCast(other); 38 | return getMode() == lexerAction.getMode(); 39 | } 40 | 41 | std::string LexerPushModeAction::toString() const { 42 | return "pushMode(" + std::to_string(getMode()) + ")"; 43 | } 44 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/LexerSkipAction.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/MurmurHash.h" 7 | #include "Lexer.h" 8 | 9 | #include "atn/LexerSkipAction.h" 10 | 11 | using namespace antlr4; 12 | using namespace antlr4::atn; 13 | using namespace antlr4::misc; 14 | 15 | const Ref& LexerSkipAction::getInstance() { 16 | static const Ref instance(new LexerSkipAction()); 17 | return instance; 18 | } 19 | 20 | void LexerSkipAction::execute(Lexer *lexer) const { 21 | lexer->skip(); 22 | } 23 | 24 | size_t LexerSkipAction::hashCodeImpl() const { 25 | size_t hash = MurmurHash::initialize(); 26 | hash = MurmurHash::update(hash, static_cast(getActionType())); 27 | return MurmurHash::finish(hash, 1); 28 | } 29 | 30 | bool LexerSkipAction::equals(const LexerAction &other) const { 31 | return this == std::addressof(other); 32 | } 33 | 34 | std::string LexerSkipAction::toString() const { 35 | return "skip"; 36 | } 37 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/LexerTypeAction.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/MurmurHash.h" 7 | #include "Lexer.h" 8 | #include "support/Casts.h" 9 | 10 | #include "atn/LexerTypeAction.h" 11 | 12 | using namespace antlr4; 13 | using namespace antlr4::atn; 14 | using namespace antlr4::misc; 15 | using namespace antlrcpp; 16 | 17 | LexerTypeAction::LexerTypeAction(int type) : LexerAction(LexerActionType::TYPE, false), _type(type) {} 18 | 19 | void LexerTypeAction::execute(Lexer *lexer) const { 20 | lexer->setType(getType()); 21 | } 22 | 23 | size_t LexerTypeAction::hashCodeImpl() const { 24 | size_t hash = MurmurHash::initialize(); 25 | hash = MurmurHash::update(hash, static_cast(getActionType())); 26 | hash = MurmurHash::update(hash, getType()); 27 | return MurmurHash::finish(hash, 2); 28 | } 29 | 30 | bool LexerTypeAction::equals(const LexerAction &other) const { 31 | if (this == std::addressof(other)) { 32 | return true; 33 | } 34 | if (getActionType() != other.getActionType()) { 35 | return false; 36 | } 37 | const auto &lexerAction = downCast(other); 38 | return getType() == lexerAction.getType(); 39 | } 40 | 41 | std::string LexerTypeAction::toString() const { 42 | return "type(" + std::to_string(getType()) + ")"; 43 | } 44 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/LookaheadEventInfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/LookaheadEventInfo.h" 7 | 8 | using namespace antlr4; 9 | using namespace antlr4::atn; 10 | 11 | LookaheadEventInfo::LookaheadEventInfo(size_t decision, ATNConfigSet *configs, size_t predictedAlt, 12 | TokenStream *input, size_t startIndex, size_t stopIndex, bool fullCtx) 13 | : DecisionEventInfo(decision, configs, input, startIndex, stopIndex, fullCtx) { 14 | 15 | this->predictedAlt = predictedAlt; 16 | } 17 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/LoopEndState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// Mark the end of a * or + loop. 14 | class ANTLR4CPP_PUBLIC LoopEndState final : public ATNState { 15 | public: 16 | static bool is(const ATNState &atnState) { return atnState.getStateType() == ATNStateType::LOOP_END; } 17 | 18 | static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); } 19 | 20 | ATNState *loopBackState = nullptr; 21 | 22 | LoopEndState() : ATNState(ATNStateType::LOOP_END) {} 23 | }; 24 | 25 | } // namespace atn 26 | } // namespace antlr4 27 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/NotSetTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/NotSetTransition.h" 7 | #include "atn/ATNState.h" 8 | #include "misc/IntervalSet.h" 9 | 10 | using namespace antlr4; 11 | using namespace antlr4::atn; 12 | 13 | NotSetTransition::NotSetTransition(ATNState *target, misc::IntervalSet set) : SetTransition(TransitionType::NOT_SET, target, std::move(set)) {} 14 | 15 | bool NotSetTransition::matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const { 16 | return symbol >= minVocabSymbol && symbol <= maxVocabSymbol 17 | && !SetTransition::matches(symbol, minVocabSymbol, maxVocabSymbol); 18 | } 19 | 20 | std::string NotSetTransition::toString() const { 21 | return "NOT_SET " + Transition::toString() + " { " + SetTransition::toString() + " }"; 22 | } 23 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/NotSetTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/SetTransition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC NotSetTransition final : public SetTransition { 14 | public: 15 | static bool is(const Transition &transition) { return transition.getTransitionType() == TransitionType::NOT_SET; } 16 | 17 | static bool is(const Transition *transition) { return transition != nullptr && is(*transition); } 18 | 19 | NotSetTransition(ATNState *target, misc::IntervalSet set); 20 | 21 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 22 | 23 | virtual std::string toString() const override; 24 | }; 25 | 26 | } // namespace atn 27 | } // namespace antlr4 28 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/OrderedATNConfigSet.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/OrderedATNConfigSet.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | size_t OrderedATNConfigSet::hashCode(const ATNConfig &atnConfig) const { 11 | return atnConfig.hashCode(); 12 | } 13 | 14 | bool OrderedATNConfigSet::equals(const ATNConfig &lhs, const ATNConfig &rhs) const { 15 | return lhs == rhs; 16 | } 17 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/OrderedATNConfigSet.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNConfigSet.h" 9 | #include "atn/ATNConfig.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | class ANTLR4CPP_PUBLIC OrderedATNConfigSet final : public ATNConfigSet { 15 | public: 16 | OrderedATNConfigSet() = default; 17 | 18 | private: 19 | size_t hashCode(const ATNConfig &atnConfig) const override; 20 | 21 | bool equals(const ATNConfig &lhs, const ATNConfig &rhs) const override; 22 | }; 23 | 24 | } // namespace atn 25 | } // namespace antlr4 26 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/PlusBlockStartState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/BlockStartState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// Start of {@code (A|B|...)+} loop. Technically a decision state, but 14 | /// we don't use for code generation; somebody might need it, so I'm defining 15 | /// it for completeness. In reality, the node is the 16 | /// real decision-making note for {@code A+}. 17 | class ANTLR4CPP_PUBLIC PlusBlockStartState final : public BlockStartState { 18 | public: 19 | static bool is(const ATNState &atnState) { return atnState.getStateType() == ATNStateType::PLUS_BLOCK_START; } 20 | 21 | static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); } 22 | 23 | PlusLoopbackState *loopBackState = nullptr; 24 | 25 | PlusBlockStartState() : BlockStartState(ATNStateType::PLUS_BLOCK_START) {} 26 | }; 27 | 28 | } // namespace atn 29 | } // namespace antlr4 30 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/PlusLoopbackState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/DecisionState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// Decision state for {@code A+} and {@code (A|B)+}. It has two transitions: 14 | /// one to the loop back to start of the block and one to exit. 15 | class ANTLR4CPP_PUBLIC PlusLoopbackState final : public DecisionState { 16 | public: 17 | static bool is(const ATNState &atnState) { return atnState.getStateType() == ATNStateType::PLUS_LOOP_BACK; } 18 | 19 | static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); } 20 | 21 | PlusLoopbackState() : DecisionState(ATNStateType::PLUS_LOOP_BACK) {} 22 | }; 23 | 24 | } // namespace atn 25 | } // namespace antlr4 26 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/PrecedencePredicateTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/PrecedencePredicateTransition.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | PrecedencePredicateTransition::PrecedencePredicateTransition(ATNState *target, int precedence) 11 | : Transition(TransitionType::PRECEDENCE, target), _predicate(std::make_shared(precedence)) {} 12 | 13 | bool PrecedencePredicateTransition::isEpsilon() const { 14 | return true; 15 | } 16 | 17 | bool PrecedencePredicateTransition::matches(size_t /*symbol*/, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const { 18 | return false; 19 | } 20 | 21 | std::string PrecedencePredicateTransition::toString() const { 22 | return "PRECEDENCE " + Transition::toString() + " { precedence: " + std::to_string(getPrecedence()) + " }"; 23 | } 24 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/PrecedencePredicateTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | #include "atn/SemanticContext.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | class ANTLR4CPP_PUBLIC PrecedencePredicateTransition final : public Transition { 15 | public: 16 | static bool is(const Transition &transition) { return transition.getTransitionType() == TransitionType::PRECEDENCE; } 17 | 18 | static bool is(const Transition *transition) { return transition != nullptr && is(*transition); } 19 | 20 | PrecedencePredicateTransition(ATNState *target, int precedence); 21 | 22 | int getPrecedence() const { return _predicate->precedence; } 23 | 24 | bool isEpsilon() const override; 25 | bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 26 | std::string toString() const override; 27 | 28 | const Ref& getPredicate() const { return _predicate; } 29 | 30 | private: 31 | const std::shared_ptr _predicate; 32 | }; 33 | 34 | } // namespace atn 35 | } // namespace antlr4 36 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/PredicateEvalInfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "SemanticContext.h" 7 | 8 | #include "atn/PredicateEvalInfo.h" 9 | 10 | using namespace antlr4; 11 | using namespace antlr4::atn; 12 | 13 | PredicateEvalInfo::PredicateEvalInfo(size_t decision, TokenStream *input, size_t startIndex, size_t stopIndex, 14 | Ref semctx, bool evalResult, size_t predictedAlt, bool fullCtx) 15 | : DecisionEventInfo(decision, nullptr, input, startIndex, stopIndex, fullCtx), 16 | semctx(std::move(semctx)), predictedAlt(predictedAlt), evalResult(evalResult) { 17 | } 18 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/PredicateTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/PredicateTransition.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | PredicateTransition::PredicateTransition(ATNState *target, size_t ruleIndex, size_t predIndex, bool isCtxDependent) 11 | : Transition(TransitionType::PREDICATE, target), _predicate(std::make_shared(ruleIndex, predIndex, isCtxDependent)) {} 12 | 13 | bool PredicateTransition::isEpsilon() const { 14 | return true; 15 | } 16 | 17 | bool PredicateTransition::matches(size_t /*symbol*/, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const { 18 | return false; 19 | } 20 | 21 | std::string PredicateTransition::toString() const { 22 | return "PREDICATE " + Transition::toString() + " { ruleIndex: " + std::to_string(getRuleIndex()) + 23 | ", predIndex: " + std::to_string(getPredIndex()) + ", isCtxDependent: " + std::to_string(isCtxDependent()) + " }"; 24 | } 25 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/PredictionContextType.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | #include "antlr4-common.h" 11 | 12 | namespace antlr4 { 13 | namespace atn { 14 | 15 | enum class PredictionContextType : size_t { 16 | SINGLETON = 1, 17 | ARRAY = 2, 18 | }; 19 | 20 | } // namespace atn 21 | } // namespace antlr4 22 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/RangeTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/IntervalSet.h" 7 | 8 | #include "atn/RangeTransition.h" 9 | 10 | using namespace antlr4; 11 | using namespace antlr4::atn; 12 | 13 | RangeTransition::RangeTransition(ATNState *target, size_t from, size_t to) : Transition(TransitionType::RANGE, target), from(from), to(to) { 14 | } 15 | 16 | misc::IntervalSet RangeTransition::label() const { 17 | return misc::IntervalSet::of((int)from, (int)to); 18 | } 19 | 20 | bool RangeTransition::matches(size_t symbol, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const { 21 | return symbol >= from && symbol <= to; 22 | } 23 | 24 | std::string RangeTransition::toString() const { 25 | return "RANGE " + Transition::toString() + " { from: " + std::to_string(from) + ", to: " + std::to_string(to) + " }"; 26 | } 27 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/RangeTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC RangeTransition final : public Transition { 14 | public: 15 | static bool is(const Transition &transition) { return transition.getTransitionType() == TransitionType::RANGE; } 16 | 17 | static bool is(const Transition *transition) { return transition != nullptr && is(*transition); } 18 | 19 | const size_t from; 20 | const size_t to; 21 | 22 | RangeTransition(ATNState *target, size_t from, size_t to); 23 | 24 | virtual misc::IntervalSet label() const override; 25 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 26 | 27 | virtual std::string toString() const override; 28 | }; 29 | 30 | } // namespace atn 31 | } // namespace antlr4 32 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/RuleStartState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC RuleStartState final : public ATNState { 14 | public: 15 | static bool is(const ATNState &atnState) { return atnState.getStateType() == ATNStateType::RULE_START; } 16 | 17 | static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); } 18 | 19 | RuleStopState *stopState = nullptr; 20 | bool isLeftRecursiveRule = false; 21 | 22 | RuleStartState() : ATNState(ATNStateType::RULE_START) {} 23 | }; 24 | 25 | } // namespace atn 26 | } // namespace antlr4 27 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/RuleStopState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// The last node in the ATN for a rule, unless that rule is the start symbol. 14 | /// In that case, there is one transition to EOF. Later, we might encode 15 | /// references to all calls to this rule to compute FOLLOW sets for 16 | /// error handling. 17 | class ANTLR4CPP_PUBLIC RuleStopState final : public ATNState { 18 | public: 19 | static bool is(const ATNState &atnState) { return atnState.getStateType() == ATNStateType::RULE_STOP; } 20 | 21 | static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); } 22 | 23 | RuleStopState() : ATNState(ATNStateType::RULE_STOP) {} 24 | }; 25 | 26 | } // namespace atn 27 | } // namespace antlr4 28 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/RuleTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/RuleStartState.h" 7 | #include "atn/RuleTransition.h" 8 | 9 | using namespace antlr4::atn; 10 | 11 | RuleTransition::RuleTransition(RuleStartState *ruleStart, size_t ruleIndex, ATNState *followState) 12 | : RuleTransition(ruleStart, ruleIndex, 0, followState) { 13 | } 14 | 15 | RuleTransition::RuleTransition(RuleStartState *ruleStart, size_t ruleIndex, int precedence, ATNState *followState) 16 | : Transition(TransitionType::RULE, ruleStart), ruleIndex(ruleIndex), precedence(precedence) { 17 | this->followState = followState; 18 | } 19 | 20 | bool RuleTransition::isEpsilon() const { 21 | return true; 22 | } 23 | 24 | bool RuleTransition::matches(size_t /*symbol*/, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const { 25 | return false; 26 | } 27 | 28 | std::string RuleTransition::toString() const { 29 | std::stringstream ss; 30 | ss << "RULE " << Transition::toString() << " { ruleIndex: " << ruleIndex << ", precedence: " << precedence << 31 | ", followState: " << std::hex << followState << " }"; 32 | return ss.str(); 33 | } 34 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/RuleTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC RuleTransition final : public Transition { 14 | public: 15 | static bool is(const Transition &transition) { return transition.getTransitionType() == TransitionType::RULE; } 16 | 17 | static bool is(const Transition *transition) { return transition != nullptr && is(*transition); } 18 | 19 | /// Ptr to the rule definition object for this rule ref. 20 | const size_t ruleIndex; // no Rule object at runtime 21 | 22 | const int precedence; 23 | 24 | /// What node to begin computations following ref to rule. 25 | ATNState *followState; 26 | 27 | /// @deprecated Use 28 | /// instead. 29 | RuleTransition(RuleStartState *ruleStart, size_t ruleIndex, ATNState *followState); 30 | 31 | RuleTransition(RuleStartState *ruleStart, size_t ruleIndex, int precedence, ATNState *followState); 32 | RuleTransition(RuleTransition const&) = delete; 33 | RuleTransition& operator=(RuleTransition const&) = delete; 34 | 35 | virtual bool isEpsilon() const override; 36 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 37 | 38 | virtual std::string toString() const override; 39 | }; 40 | 41 | } // namespace atn 42 | } // namespace antlr4 43 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/SemanticContextType.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | #include "antlr4-common.h" 11 | 12 | namespace antlr4 { 13 | namespace atn { 14 | 15 | enum class SemanticContextType : size_t { 16 | PREDICATE = 1, 17 | PRECEDENCE = 2, 18 | AND = 3, 19 | OR = 4, 20 | }; 21 | 22 | } // namespace atn 23 | } // namespace antlr4 24 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/SetTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Token.h" 7 | #include "misc/IntervalSet.h" 8 | 9 | #include "atn/SetTransition.h" 10 | 11 | using namespace antlr4; 12 | using namespace antlr4::atn; 13 | 14 | SetTransition::SetTransition(TransitionType transitionType, ATNState *target, misc::IntervalSet aSet) 15 | : Transition(transitionType, target), set(aSet.isEmpty() ? misc::IntervalSet::of(Token::INVALID_TYPE) : std::move(aSet)) { 16 | } 17 | 18 | misc::IntervalSet SetTransition::label() const { 19 | return set; 20 | } 21 | 22 | bool SetTransition::matches(size_t symbol, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const { 23 | return set.contains(symbol); 24 | } 25 | 26 | std::string SetTransition::toString() const { 27 | return "SET " + Transition::toString() + " { set: " + set.toString() + "}"; 28 | } 29 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/SetTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// 14 | /// A transition containing a set of values. 15 | class ANTLR4CPP_PUBLIC SetTransition : public Transition { 16 | public: 17 | static bool is(const Transition &transition) { 18 | const auto transitionType = transition.getTransitionType(); 19 | return transitionType == TransitionType::SET || transitionType == TransitionType::NOT_SET; 20 | } 21 | 22 | static bool is(const Transition *transition) { return transition != nullptr && is(*transition); } 23 | 24 | const misc::IntervalSet set; 25 | 26 | SetTransition(ATNState *target, misc::IntervalSet set) : SetTransition(TransitionType::SET, target, std::move(set)) {} 27 | 28 | virtual misc::IntervalSet label() const override; 29 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 30 | 31 | virtual std::string toString() const override; 32 | 33 | protected: 34 | SetTransition(TransitionType transitionType, ATNState *target, misc::IntervalSet set); 35 | }; 36 | 37 | } // namespace atn 38 | } // namespace antlr4 39 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/StarBlockStartState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/BlockStartState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// The block that begins a closure loop. 14 | class ANTLR4CPP_PUBLIC StarBlockStartState final : public BlockStartState { 15 | public: 16 | static bool is(const ATNState &atnState) { return atnState.getStateType() == ATNStateType::STAR_BLOCK_START; } 17 | 18 | static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); } 19 | 20 | StarBlockStartState() : BlockStartState(ATNStateType::STAR_BLOCK_START) {} 21 | }; 22 | 23 | } // namespace atn 24 | } // namespace antlr4 25 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/StarLoopEntryState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/DecisionState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC StarLoopEntryState final : public DecisionState { 14 | public: 15 | static bool is(const ATNState &atnState) { return atnState.getStateType() == ATNStateType::STAR_LOOP_ENTRY; } 16 | 17 | static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); } 18 | 19 | /** 20 | * Indicates whether this state can benefit from a precedence DFA during SLL 21 | * decision making. 22 | * 23 | *

This is a computed property that is calculated during ATN deserialization 24 | * and stored for use in {@link ParserATNSimulator} and 25 | * {@link ParserInterpreter}.

26 | * 27 | * @see DFA#isPrecedenceDfa() 28 | */ 29 | bool isPrecedenceDecision = false; 30 | 31 | StarLoopbackState *loopBackState = nullptr; 32 | 33 | StarLoopEntryState() : DecisionState(ATNStateType::STAR_LOOP_ENTRY) {} 34 | }; 35 | 36 | } // namespace atn 37 | } // namespace antlr4 38 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/StarLoopbackState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/StarLoopEntryState.h" 7 | #include "atn/Transition.h" 8 | #include "support/Casts.h" 9 | 10 | #include "atn/StarLoopbackState.h" 11 | 12 | using namespace antlr4::atn; 13 | 14 | StarLoopEntryState *StarLoopbackState::getLoopEntryState() const { 15 | if (transitions[0]->target != nullptr && transitions[0]->target->getStateType() == ATNStateType::STAR_LOOP_ENTRY) { 16 | return antlrcpp::downCast(transitions[0]->target); 17 | } 18 | return nullptr; 19 | } 20 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/StarLoopbackState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC StarLoopbackState final : public ATNState { 14 | public: 15 | static bool is(const ATNState &atnState) { return atnState.getStateType() == ATNStateType::STAR_LOOP_BACK; } 16 | 17 | static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); } 18 | 19 | StarLoopbackState() : ATNState(ATNStateType::STAR_LOOP_BACK) {} 20 | 21 | StarLoopEntryState *getLoopEntryState() const; 22 | }; 23 | 24 | } // namespace atn 25 | } // namespace antlr4 26 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/TokensStartState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/DecisionState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// The Tokens rule start state linking to each lexer rule start state. 14 | class ANTLR4CPP_PUBLIC TokensStartState final : public DecisionState { 15 | public: 16 | static bool is(const ATNState &atnState) { return atnState.getStateType() == ATNStateType::TOKEN_START; } 17 | 18 | static bool is(const ATNState *atnState) { return atnState != nullptr && is(*atnState); } 19 | 20 | TokensStartState() : DecisionState(ATNStateType::TOKEN_START) {} 21 | }; 22 | 23 | } // namespace atn 24 | } // namespace antlr4 25 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/Transition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Exceptions.h" 7 | #include "support/Arrays.h" 8 | 9 | #include "atn/Transition.h" 10 | 11 | using namespace antlr4; 12 | using namespace antlr4::atn; 13 | using namespace antlrcpp; 14 | 15 | Transition::Transition(TransitionType transitionType, ATNState *target) : _transitionType(transitionType) { 16 | if (target == nullptr) { 17 | throw NullPointerException("target cannot be null."); 18 | } 19 | 20 | this->target = target; 21 | } 22 | 23 | bool Transition::isEpsilon() const { 24 | return false; 25 | } 26 | 27 | misc::IntervalSet Transition::label() const { 28 | return misc::IntervalSet::EMPTY_SET; 29 | } 30 | 31 | std::string Transition::toString() const { 32 | std::stringstream ss; 33 | ss << "(Transition " << std::hex << this << ", target: " << std::hex << target << ')'; 34 | 35 | return ss.str(); 36 | } 37 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/TransitionType.cpp: -------------------------------------------------------------------------------- 1 | #include "atn/TransitionType.h" 2 | 3 | std::string antlr4::atn::transitionTypeName(TransitionType transitionType) { 4 | switch (transitionType) { 5 | case TransitionType::EPSILON: 6 | return "EPSILON"; 7 | case TransitionType::RANGE: 8 | return "RANGE"; 9 | case TransitionType::RULE: 10 | return "RULE"; 11 | case TransitionType::PREDICATE: 12 | return "PREDICATE"; 13 | case TransitionType::ATOM: 14 | return "ATOM"; 15 | case TransitionType::ACTION: 16 | return "ACTION"; 17 | case TransitionType::SET: 18 | return "SET"; 19 | case TransitionType::NOT_SET: 20 | return "NOT_SET"; 21 | case TransitionType::WILDCARD: 22 | return "WILDCARD"; 23 | case TransitionType::PRECEDENCE: 24 | return "PRECEDENCE"; 25 | } 26 | return "UNKNOWN"; 27 | } 28 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/TransitionType.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | 11 | #include "antlr4-common.h" 12 | 13 | namespace antlr4 { 14 | namespace atn { 15 | 16 | // Constants for transition serialization. 17 | enum class TransitionType : size_t { 18 | EPSILON = 1, 19 | RANGE = 2, 20 | RULE = 3, 21 | PREDICATE = 4, // e.g., {isType(input.LT(1))}? 22 | ATOM = 5, 23 | ACTION = 6, 24 | SET = 7, // ~(A|B) or ~atom, wildcard, which convert to next 2 25 | NOT_SET = 8, 26 | WILDCARD = 9, 27 | PRECEDENCE = 10, 28 | }; 29 | 30 | ANTLR4CPP_PUBLIC std::string transitionTypeName(TransitionType transitionType); 31 | 32 | } // namespace atn 33 | } // namespace antlr4 34 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/WildcardTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/ATNState.h" 7 | 8 | #include "atn/WildcardTransition.h" 9 | 10 | using namespace antlr4::atn; 11 | 12 | WildcardTransition::WildcardTransition(ATNState *target) : Transition(TransitionType::WILDCARD, target) { 13 | } 14 | 15 | bool WildcardTransition::matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const { 16 | return symbol >= minVocabSymbol && symbol <= maxVocabSymbol; 17 | } 18 | 19 | std::string WildcardTransition::toString() const { 20 | return "WILDCARD " + Transition::toString() + " {}"; 21 | } 22 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/atn/WildcardTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC WildcardTransition final : public Transition { 14 | public: 15 | static bool is(const Transition &transition) { return transition.getTransitionType() == TransitionType::WILDCARD; } 16 | 17 | static bool is(const Transition *transition) { return transition != nullptr && is(*transition); } 18 | 19 | explicit WildcardTransition(ATNState *target); 20 | 21 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 22 | 23 | virtual std::string toString() const override; 24 | }; 25 | 26 | } // namespace atn 27 | } // namespace antlr4 28 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/dfa/DFASerializer.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "Vocabulary.h" 9 | 10 | namespace antlr4 { 11 | namespace dfa { 12 | 13 | /// A DFA walker that knows how to dump them to serialized strings. 14 | class ANTLR4CPP_PUBLIC DFASerializer { 15 | public: 16 | DFASerializer(const DFA *dfa, const Vocabulary &vocabulary); 17 | 18 | virtual ~DFASerializer() = default; 19 | 20 | std::string toString() const; 21 | 22 | protected: 23 | virtual std::string getEdgeLabel(size_t i) const; 24 | std::string getStateString(DFAState *s) const; 25 | 26 | private: 27 | const DFA *_dfa; 28 | const Vocabulary &_vocabulary; 29 | }; 30 | 31 | } // namespace atn 32 | } // namespace antlr4 33 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/dfa/LexerDFASerializer.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Vocabulary.h" 7 | 8 | #include "dfa/LexerDFASerializer.h" 9 | 10 | using namespace antlr4::dfa; 11 | 12 | LexerDFASerializer::LexerDFASerializer(const DFA *dfa) : DFASerializer(dfa, Vocabulary()) { 13 | } 14 | 15 | std::string LexerDFASerializer::getEdgeLabel(size_t i) const { 16 | return std::string("'") + static_cast(i) + "'"; 17 | } 18 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/dfa/LexerDFASerializer.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "dfa/DFASerializer.h" 9 | 10 | namespace antlr4 { 11 | namespace dfa { 12 | 13 | class ANTLR4CPP_PUBLIC LexerDFASerializer final : public DFASerializer { 14 | public: 15 | explicit LexerDFASerializer(const DFA *dfa); 16 | 17 | protected: 18 | std::string getEdgeLabel(size_t i) const override; 19 | }; 20 | 21 | } // namespace atn 22 | } // namespace antlr4 23 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/misc/InterpreterDataReader.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | #include "atn/ATN.h" 10 | #include "Vocabulary.h" 11 | 12 | namespace antlr4 { 13 | namespace misc { 14 | 15 | struct InterpreterData { 16 | std::unique_ptr atn; 17 | dfa::Vocabulary vocabulary; 18 | std::vector ruleNames; 19 | std::vector channels; // Only valid for lexer grammars. 20 | std::vector modes; // ditto 21 | 22 | InterpreterData() {}; // For invalid content. 23 | InterpreterData(std::vector const& literalNames, std::vector const& symbolicNames); 24 | }; 25 | 26 | // A class to read plain text interpreter data produced by ANTLR. 27 | class ANTLR4CPP_PUBLIC InterpreterDataReader { 28 | public: 29 | static InterpreterData parseFile(std::string const& fileName); 30 | }; 31 | 32 | } // namespace atn 33 | } // namespace antlr4 34 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/misc/Predicate.cpp: -------------------------------------------------------------------------------- 1 | #include "misc/Predicate.h" 2 | 3 | antlr4::misc::Predicate::~Predicate() { 4 | } 5 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/misc/Predicate.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | namespace misc { 12 | 13 | class ANTLR4CPP_PUBLIC Predicate { 14 | public: 15 | virtual ~Predicate(); 16 | 17 | virtual bool test(tree::ParseTree *t) = 0; 18 | }; 19 | 20 | } // namespace tree 21 | } // namespace antlr4 22 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/support/Any.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Any.h" 7 | 8 | using namespace antlrcpp; 9 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/support/Any.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | // A standard C++ class loosely modeled after boost::Any. 7 | 8 | #pragma once 9 | 10 | #include "antlr4-common.h" 11 | 12 | namespace antlrcpp { 13 | 14 | using Any = std::any; 15 | 16 | } // namespace antlrcpp 17 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/support/Arrays.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/ParseTree.h" 7 | #include "Exceptions.h" 8 | 9 | #include "support/Arrays.h" 10 | 11 | using namespace antlrcpp; 12 | 13 | std::string Arrays::listToString(const std::vector &list, const std::string &separator) 14 | { 15 | std::stringstream ss; 16 | bool firstEntry = true; 17 | 18 | ss << '['; 19 | for (const auto &entry : list) { 20 | ss << entry; 21 | if (firstEntry) { 22 | ss << separator; 23 | firstEntry = false; 24 | } 25 | } 26 | 27 | ss << ']'; 28 | return ss.str(); 29 | } 30 | 31 | template <> 32 | std::string Arrays::toString(const std::vector &source) { 33 | std::string result = "["; 34 | bool firstEntry = true; 35 | for (auto *value : source) { 36 | result += value->toStringTree(); 37 | if (firstEntry) { 38 | result += ", "; 39 | firstEntry = false; 40 | } 41 | } 42 | return result + "]"; 43 | } 44 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/support/Casts.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2021 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace antlrcpp { 13 | 14 | template 15 | To downCast(From* from) { 16 | static_assert(std::is_pointer_v, "Target type not a pointer."); 17 | static_assert(std::is_base_of_v>, "Target type not derived from source type."); 18 | #if !defined(__GNUC__) || defined(__GXX_RTTI) 19 | assert(from == nullptr || dynamic_cast(from) != nullptr); 20 | #endif 21 | return static_cast(from); 22 | } 23 | 24 | template 25 | To downCast(From& from) { 26 | static_assert(std::is_lvalue_reference_v, "Target type not a lvalue reference."); 27 | static_assert(std::is_base_of_v>, "Target type not derived from source type."); 28 | #if !defined(__GNUC__) || defined(__GXX_RTTI) 29 | assert(dynamic_cast>>(std::addressof(from)) != nullptr); 30 | #endif 31 | return static_cast(from); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/support/StringUtils.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "support/StringUtils.h" 7 | 8 | namespace antlrcpp { 9 | 10 | std::string escapeWhitespace(std::string_view in) { 11 | std::string out; 12 | escapeWhitespace(out, in); 13 | out.shrink_to_fit(); 14 | return out; 15 | } 16 | 17 | std::string& escapeWhitespace(std::string& out, std::string_view in) { 18 | out.reserve(in.size()); // Best case, no escaping. 19 | for (const auto &c : in) { 20 | switch (c) { 21 | case '\t': 22 | out.append("\\t"); 23 | break; 24 | case '\r': 25 | out.append("\\r"); 26 | break; 27 | case '\n': 28 | out.append("\\n"); 29 | break; 30 | default: 31 | out.push_back(c); 32 | break; 33 | } 34 | } 35 | return out; 36 | } 37 | 38 | } // namespace antrlcpp 39 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/support/StringUtils.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlrcpp { 11 | 12 | ANTLR4CPP_PUBLIC std::string escapeWhitespace(std::string_view in); 13 | 14 | ANTLR4CPP_PUBLIC std::string& escapeWhitespace(std::string& out, std::string_view in); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/support/Unicode.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2021 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlrcpp { 11 | 12 | class ANTLR4CPP_PUBLIC Unicode final { 13 | public: 14 | static constexpr char32_t REPLACEMENT_CHARACTER = 0xfffd; 15 | 16 | static constexpr bool isValid(char32_t codePoint) { 17 | return codePoint < 0xd800 || (codePoint > 0xdfff && codePoint <= 0x10ffff); 18 | } 19 | 20 | private: 21 | Unicode() = delete; 22 | Unicode(const Unicode&) = delete; 23 | Unicode(Unicode&&) = delete; 24 | Unicode& operator=(const Unicode&) = delete; 25 | Unicode& operator=(Unicode&&) = delete; 26 | }; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/ErrorNode.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "tree/TerminalNode.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | 13 | class ANTLR4CPP_PUBLIC ErrorNode : public TerminalNode { 14 | public: 15 | static bool is(const tree::ParseTree &parseTree) { return parseTree.getTreeType() == tree::ParseTreeType::ERROR; } 16 | 17 | static bool is(const tree::ParseTree *parseTree) { return parseTree != nullptr && is(*parseTree); } 18 | 19 | protected: 20 | using TerminalNode::TerminalNode; 21 | }; 22 | 23 | } // namespace tree 24 | } // namespace antlr4 25 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/ErrorNodeImpl.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/Interval.h" 7 | #include "Token.h" 8 | #include "RuleContext.h" 9 | #include "tree/ParseTreeVisitor.h" 10 | 11 | #include "tree/ErrorNodeImpl.h" 12 | 13 | using namespace antlr4; 14 | using namespace antlr4::tree; 15 | 16 | Token* ErrorNodeImpl::getSymbol() const { 17 | return symbol; 18 | } 19 | 20 | void ErrorNodeImpl::setParent(RuleContext *parent_) { 21 | this->parent = parent_; 22 | } 23 | 24 | misc::Interval ErrorNodeImpl::getSourceInterval() { 25 | if (symbol == nullptr) { 26 | return misc::Interval::INVALID; 27 | } 28 | 29 | size_t tokenIndex = symbol->getTokenIndex(); 30 | return misc::Interval(tokenIndex, tokenIndex); 31 | } 32 | 33 | std::any ErrorNodeImpl::accept(ParseTreeVisitor *visitor) { 34 | return visitor->visitErrorNode(this); 35 | } 36 | 37 | std::string ErrorNodeImpl::getText() { 38 | return symbol->getText(); 39 | } 40 | 41 | std::string ErrorNodeImpl::toStringTree(Parser * /*parser*/, bool /*pretty*/) { 42 | return toString(); 43 | } 44 | 45 | std::string ErrorNodeImpl::toString() { 46 | if (symbol->getType() == Token::EOF) { 47 | return ""; 48 | } 49 | return symbol->getText(); 50 | } 51 | 52 | std::string ErrorNodeImpl::toStringTree(bool /*pretty*/) { 53 | return toString(); 54 | } 55 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/ErrorNodeImpl.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "tree/ErrorNode.h" 9 | #include "tree/TerminalNodeImpl.h" 10 | #include "misc/Interval.h" 11 | 12 | #include "support/Any.h" 13 | 14 | namespace antlr4 { 15 | namespace tree { 16 | 17 | /// 18 | /// Represents a token that was consumed during resynchronization 19 | /// rather than during a valid match operation. For example, 20 | /// we will create this kind of a node during single token insertion 21 | /// and deletion as well as during "consume until error recovery set" 22 | /// upon no viable alternative exceptions. 23 | /// 24 | class ANTLR4CPP_PUBLIC ErrorNodeImpl : public ErrorNode { 25 | public: 26 | Token *symbol; 27 | 28 | explicit ErrorNodeImpl(Token *symbol) : ErrorNode(ParseTreeType::ERROR), symbol(symbol) {} 29 | 30 | virtual Token* getSymbol() const override; 31 | virtual void setParent(RuleContext *parent) override; 32 | virtual misc::Interval getSourceInterval() override; 33 | 34 | virtual std::any accept(ParseTreeVisitor *visitor) override; 35 | 36 | virtual std::string getText() override; 37 | virtual std::string toStringTree(Parser *parser, bool pretty = false) override; 38 | virtual std::string toString() override; 39 | virtual std::string toStringTree(bool pretty = false) override; 40 | }; 41 | 42 | } // namespace tree 43 | } // namespace antlr4 44 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/ParseTree.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/ParseTree.h" 7 | 8 | using namespace antlr4::tree; 9 | 10 | bool ParseTree::operator == (const ParseTree &other) const { 11 | return &other == this; 12 | } 13 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/ParseTreeListener.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "ParseTreeListener.h" 7 | 8 | antlr4::tree::ParseTreeListener::~ParseTreeListener() { 9 | } 10 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/ParseTreeListener.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | 13 | /** This interface describes the minimal core of methods triggered 14 | * by {@link ParseTreeWalker}. E.g., 15 | * 16 | * ParseTreeWalker walker = new ParseTreeWalker(); 17 | * walker.walk(myParseTreeListener, myParseTree); <-- triggers events in your listener 18 | * 19 | * If you want to trigger events in multiple listeners during a single 20 | * tree walk, you can use the ParseTreeDispatcher object available at 21 | * 22 | * https://github.com/antlr/antlr4/issues/841 23 | */ 24 | class ANTLR4CPP_PUBLIC ParseTreeListener { 25 | public: 26 | virtual ~ParseTreeListener(); 27 | 28 | virtual void visitTerminal(TerminalNode *node) = 0; 29 | virtual void visitErrorNode(ErrorNode *node) = 0; 30 | virtual void enterEveryRule(ParserRuleContext *ctx) = 0; 31 | virtual void exitEveryRule(ParserRuleContext *ctx) = 0; 32 | 33 | bool operator == (const ParseTreeListener &other) { 34 | return this == &other; 35 | } 36 | }; 37 | 38 | } // namespace tree 39 | } // namespace antlr4 40 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/ParseTreeProperty.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | 13 | /// 14 | /// Associate a property with a parse tree node. Useful with parse tree listeners 15 | /// that need to associate values with particular tree nodes, kind of like 16 | /// specifying a return value for the listener event method that visited a 17 | /// particular node. Example: 18 | /// 19 | ///
20 |   /// ParseTreeProperty<Integer> values = new ParseTreeProperty<Integer>();
21 |   /// values.put(tree, 36);
22 |   /// int x = values.get(tree);
23 |   /// values.removeFrom(tree);
24 |   /// 
25 | /// 26 | /// You would make one decl (values here) in the listener and use lots of times 27 | /// in your event methods. 28 | ///
29 | template 30 | class ANTLR4CPP_PUBLIC ParseTreeProperty { 31 | public: 32 | virtual ~ParseTreeProperty() {} 33 | virtual V get(ParseTree *node) { 34 | return _annotations[node]; 35 | } 36 | virtual void put(ParseTree *node, V value) { 37 | _annotations[node] = value; 38 | } 39 | virtual V removeFrom(ParseTree *node) { 40 | auto value = _annotations[node]; 41 | _annotations.erase(node); 42 | return value; 43 | } 44 | 45 | protected: 46 | std::map _annotations; 47 | }; 48 | 49 | } // namespace tree 50 | } // namespace antlr4 51 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/ParseTreeType.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | 10 | #include "antlr4-common.h" 11 | 12 | namespace antlr4 { 13 | namespace tree { 14 | 15 | enum class ParseTreeType : size_t { 16 | TERMINAL = 1, 17 | ERROR = 2, 18 | RULE = 3, 19 | }; 20 | 21 | } // namespace tree 22 | } // namespace antlr4 23 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/ParseTreeVisitor.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "ParseTreeVisitor.h" 7 | 8 | antlr4::tree::ParseTreeVisitor::~ParseTreeVisitor() { 9 | } 10 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/ParseTreeWalker.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/ErrorNode.h" 7 | #include "ParserRuleContext.h" 8 | #include "tree/ParseTreeListener.h" 9 | #include "support/CPPUtils.h" 10 | #include "support/Casts.h" 11 | 12 | #include "tree/IterativeParseTreeWalker.h" 13 | #include "tree/ParseTreeWalker.h" 14 | 15 | using namespace antlr4::tree; 16 | using namespace antlrcpp; 17 | 18 | static IterativeParseTreeWalker defaultWalker; 19 | ParseTreeWalker &ParseTreeWalker::DEFAULT = defaultWalker; 20 | 21 | void ParseTreeWalker::walk(ParseTreeListener *listener, ParseTree *t) const { 22 | if (ErrorNode::is(*t)) { 23 | listener->visitErrorNode(downCast(t)); 24 | return; 25 | } 26 | if (TerminalNode::is(*t)) { 27 | listener->visitTerminal(downCast(t)); 28 | return; 29 | } 30 | 31 | enterRule(listener, t); 32 | for (auto &child : t->children) { 33 | walk(listener, child); 34 | } 35 | exitRule(listener, t); 36 | } 37 | 38 | void ParseTreeWalker::enterRule(ParseTreeListener *listener, ParseTree *r) const { 39 | auto *ctx = downCast(r); 40 | listener->enterEveryRule(ctx); 41 | ctx->enterRule(listener); 42 | } 43 | 44 | void ParseTreeWalker::exitRule(ParseTreeListener *listener, ParseTree *r) const { 45 | auto *ctx = downCast(r); 46 | ctx->exitRule(listener); 47 | listener->exitEveryRule(ctx); 48 | } 49 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/TerminalNode.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "tree/ParseTree.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | 13 | class ANTLR4CPP_PUBLIC TerminalNode : public ParseTree { 14 | public: 15 | static bool is(const tree::ParseTree &parseTree) { 16 | const auto treeType = parseTree.getTreeType(); 17 | return treeType == ParseTreeType::TERMINAL || treeType == ParseTreeType::ERROR; 18 | } 19 | 20 | static bool is(const tree::ParseTree *parseTree) { return parseTree != nullptr && is(*parseTree); } 21 | 22 | virtual Token* getSymbol() const = 0; 23 | 24 | /** Set the parent for this leaf node. 25 | * 26 | * Technically, this is not backward compatible as it changes 27 | * the interface but no one was able to create custom 28 | * TerminalNodes anyway so I'm adding as it improves internal 29 | * code quality. 30 | * 31 | * @since 4.7 32 | */ 33 | virtual void setParent(RuleContext *parent) = 0; 34 | 35 | protected: 36 | using ParseTree::ParseTree; 37 | }; 38 | 39 | } // namespace tree 40 | } // namespace antlr4 41 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/TerminalNodeImpl.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/Interval.h" 7 | #include "Token.h" 8 | #include "RuleContext.h" 9 | #include "tree/ParseTreeVisitor.h" 10 | 11 | #include "tree/TerminalNodeImpl.h" 12 | 13 | using namespace antlr4; 14 | using namespace antlr4::tree; 15 | 16 | Token* TerminalNodeImpl::getSymbol() const { 17 | return symbol; 18 | } 19 | 20 | void TerminalNodeImpl::setParent(RuleContext *parent_) { 21 | this->parent = parent_; 22 | } 23 | 24 | misc::Interval TerminalNodeImpl::getSourceInterval() { 25 | if (symbol == nullptr) { 26 | return misc::Interval::INVALID; 27 | } 28 | 29 | size_t tokenIndex = symbol->getTokenIndex(); 30 | return misc::Interval(tokenIndex, tokenIndex); 31 | } 32 | 33 | std::any TerminalNodeImpl::accept(ParseTreeVisitor *visitor) { 34 | return visitor->visitTerminal(this); 35 | } 36 | 37 | std::string TerminalNodeImpl::getText() { 38 | return symbol->getText(); 39 | } 40 | 41 | std::string TerminalNodeImpl::toStringTree(Parser * /*parser*/, bool /*pretty*/) { 42 | return toString(); 43 | } 44 | 45 | std::string TerminalNodeImpl::toString() { 46 | if (symbol->getType() == Token::EOF) { 47 | return ""; 48 | } 49 | return symbol->getText(); 50 | } 51 | 52 | std::string TerminalNodeImpl::toStringTree(bool /*pretty*/) { 53 | return toString(); 54 | } 55 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/TerminalNodeImpl.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "tree/TerminalNode.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | 13 | class ANTLR4CPP_PUBLIC TerminalNodeImpl : public TerminalNode { 14 | public: 15 | Token *symbol; 16 | 17 | explicit TerminalNodeImpl(Token *symbol) : TerminalNode(ParseTreeType::TERMINAL), symbol(symbol) {} 18 | 19 | virtual Token* getSymbol() const override; 20 | virtual void setParent(RuleContext *parent) override; 21 | virtual misc::Interval getSourceInterval() override; 22 | 23 | virtual std::any accept(ParseTreeVisitor *visitor) override; 24 | 25 | virtual std::string getText() override; 26 | virtual std::string toStringTree(Parser *parser, bool pretty = false) override; 27 | virtual std::string toString() override; 28 | virtual std::string toStringTree(bool pretty = false) override; 29 | }; 30 | 31 | } // namespace tree 32 | } // namespace antlr4 33 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/pattern/Chunk.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/pattern/Chunk.h" 7 | 8 | antlr4::tree::pattern::Chunk::~Chunk() { 9 | } 10 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/pattern/Chunk.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace pattern { 13 | 14 | /// 15 | /// A chunk is either a token tag, a rule tag, or a span of literal text within a 16 | /// tree pattern. 17 | ///

18 | /// The method returns a list of 19 | /// chunks in preparation for creating a token stream by 20 | /// . From there, we get a parse 21 | /// tree from with . These 22 | /// chunks are converted to , , or the 23 | /// regular tokens of the text surrounding the tags. 24 | ///

25 | class ANTLR4CPP_PUBLIC Chunk { 26 | public: 27 | Chunk() = default; 28 | Chunk(Chunk const&) = default; 29 | virtual ~Chunk(); 30 | 31 | Chunk& operator=(Chunk const&) = default; 32 | 33 | /// This method returns a text representation of the tag chunk. Labeled tags 34 | /// are returned in the form {@code label:tag}, and unlabeled tags are 35 | /// returned as just the tag name. 36 | virtual std::string toString() { 37 | std::string str; 38 | return str; 39 | } 40 | }; 41 | 42 | } // namespace pattern 43 | } // namespace tree 44 | } // namespace antlr4 45 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/pattern/TagChunk.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Exceptions.h" 7 | 8 | #include "tree/pattern/TagChunk.h" 9 | 10 | using namespace antlr4::tree::pattern; 11 | 12 | TagChunk::TagChunk(const std::string &tag) : TagChunk("", tag) { 13 | } 14 | 15 | TagChunk::TagChunk(const std::string &label, const std::string &tag) : _tag(tag), _label(label) { 16 | if (tag.empty()) { 17 | throw IllegalArgumentException("tag cannot be null or empty"); 18 | } 19 | 20 | } 21 | 22 | TagChunk::~TagChunk() { 23 | } 24 | 25 | std::string TagChunk::getTag() { 26 | return _tag; 27 | } 28 | 29 | std::string TagChunk::getLabel() { 30 | return _label; 31 | } 32 | 33 | std::string TagChunk::toString() { 34 | if (!_label.empty()) { 35 | return _label + ":" + _tag; 36 | } 37 | 38 | return _tag; 39 | } 40 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/pattern/TextChunk.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Exceptions.h" 7 | 8 | #include "tree/pattern/TextChunk.h" 9 | 10 | using namespace antlr4::tree::pattern; 11 | 12 | TextChunk::TextChunk(const std::string &text) : text(text) { 13 | if (text == "") { 14 | throw IllegalArgumentException("text cannot be nul"); 15 | } 16 | 17 | } 18 | 19 | TextChunk::~TextChunk() { 20 | } 21 | 22 | std::string TextChunk::getText() { 23 | return text; 24 | } 25 | 26 | std::string TextChunk::toString() { 27 | return std::string("'") + text + std::string("'"); 28 | } 29 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/pattern/TokenTagToken.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/pattern/TokenTagToken.h" 7 | 8 | using namespace antlr4::tree::pattern; 9 | 10 | TokenTagToken::TokenTagToken(const std::string &/*tokenName*/, int type) 11 | : CommonToken(type), tokenName(""), label("") { 12 | } 13 | 14 | TokenTagToken::TokenTagToken(const std::string &tokenName, int type, const std::string &label) 15 | : CommonToken(type), tokenName(tokenName), label(label) { 16 | } 17 | 18 | std::string TokenTagToken::getTokenName() const { 19 | return tokenName; 20 | } 21 | 22 | std::string TokenTagToken::getLabel() const { 23 | return label; 24 | } 25 | 26 | std::string TokenTagToken::getText() const { 27 | if (!label.empty()) { 28 | return "<" + label + ":" + tokenName + ">"; 29 | } 30 | 31 | return "<" + tokenName + ">"; 32 | } 33 | 34 | std::string TokenTagToken::toString() const { 35 | return tokenName + ":" + std::to_string(_type); 36 | } 37 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/xpath/XPathElement.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "support/CPPUtils.h" 7 | 8 | #include "XPathElement.h" 9 | 10 | using namespace antlr4::tree; 11 | using namespace antlr4::tree::xpath; 12 | 13 | XPathElement::XPathElement(const std::string &nodeName) { 14 | _nodeName = nodeName; 15 | } 16 | 17 | XPathElement::~XPathElement() { 18 | } 19 | 20 | std::vector XPathElement::evaluate(ParseTree * /*t*/) { 21 | return {}; 22 | } 23 | 24 | std::string XPathElement::toString() const { 25 | std::string inv = _invert ? "!" : ""; 26 | return antlrcpp::toString(*this) + "[" + inv + _nodeName + "]"; 27 | } 28 | 29 | void XPathElement::setInvert(bool value) { 30 | _invert = value; 31 | } 32 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/xpath/XPathElement.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | class ParseTree; 13 | 14 | namespace xpath { 15 | 16 | class ANTLR4CPP_PUBLIC XPathElement { 17 | public: 18 | /// Construct element like {@code /ID} or {@code ID} or {@code /*} etc... 19 | /// op is null if just node 20 | XPathElement(const std::string &nodeName); 21 | XPathElement(XPathElement const&) = default; 22 | virtual ~XPathElement(); 23 | 24 | XPathElement& operator=(XPathElement const&) = default; 25 | 26 | /// Given tree rooted at {@code t} return all nodes matched by this path 27 | /// element. 28 | virtual std::vector evaluate(ParseTree *t); 29 | virtual std::string toString() const; 30 | 31 | void setInvert(bool value); 32 | 33 | protected: 34 | std::string _nodeName; 35 | bool _invert = false; 36 | }; 37 | 38 | } // namespace xpath 39 | } // namespace tree 40 | } // namespace antlr4 41 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/xpath/XPathLexer.g4: -------------------------------------------------------------------------------- 1 | lexer grammar XPathLexer; 2 | 3 | tokens { TOKEN_REF, RULE_REF } 4 | 5 | /* 6 | path : separator? word (separator word)* EOF ; 7 | 8 | separator 9 | : '/' '!' 10 | | '//' '!' 11 | | '/' 12 | | '//' 13 | ; 14 | 15 | word: TOKEN_REF 16 | | RULE_REF 17 | | STRING 18 | | '*' 19 | ; 20 | */ 21 | 22 | ANYWHERE : '//' ; 23 | ROOT : '/' ; 24 | WILDCARD : '*' ; 25 | BANG : '!' ; 26 | 27 | ID : NameStartChar NameChar* 28 | { 29 | if (isupper(getText()[0])) 30 | setType(TOKEN_REF); 31 | else 32 | setType(RULE_REF); 33 | } 34 | ; 35 | 36 | fragment 37 | NameChar : NameStartChar 38 | | '0'..'9' 39 | | '_' 40 | | '\u00B7' 41 | | '\u0300'..'\u036F' 42 | | '\u203F'..'\u2040' 43 | ; 44 | 45 | fragment 46 | NameStartChar 47 | : 'A'..'Z' | 'a'..'z' 48 | | '\u00C0'..'\u00D6' 49 | | '\u00D8'..'\u00F6' 50 | | '\u00F8'..'\u02FF' 51 | | '\u0370'..'\u037D' 52 | | '\u037F'..'\u1FFF' 53 | | '\u200C'..'\u200D' 54 | | '\u2070'..'\u218F' 55 | | '\u2C00'..'\u2FEF' 56 | | '\u3001'..'\uD7FF' 57 | | '\uF900'..'\uFDCF' 58 | | '\uFDF0'..'\uFFFF' // implicitly includes ['\u10000-'\uEFFFF] 59 | ; 60 | 61 | STRING : '\'' .*? '\''; 62 | 63 | //WS : [ \t\r\n]+ -> skip ; 64 | 65 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/xpath/XPathLexer.h: -------------------------------------------------------------------------------- 1 | 2 | // Generated from XPathLexer.g4 by ANTLR 4.13.0 3 | 4 | #pragma once 5 | 6 | 7 | #include "antlr4-runtime.h" 8 | 9 | 10 | 11 | 12 | class XPathLexer : public antlr4::Lexer { 13 | public: 14 | enum { 15 | TOKEN_REF = 1, RULE_REF = 2, ANYWHERE = 3, ROOT = 4, WILDCARD = 5, BANG = 6, 16 | ID = 7, STRING = 8 17 | }; 18 | 19 | explicit XPathLexer(antlr4::CharStream *input); 20 | 21 | ~XPathLexer() override; 22 | 23 | 24 | std::string getGrammarFileName() const override; 25 | 26 | const std::vector& getRuleNames() const override; 27 | 28 | const std::vector& getChannelNames() const override; 29 | 30 | const std::vector& getModeNames() const override; 31 | 32 | const antlr4::dfa::Vocabulary& getVocabulary() const override; 33 | 34 | antlr4::atn::SerializedATNView getSerializedATN() const override; 35 | 36 | const antlr4::atn::ATN& getATN() const override; 37 | 38 | void action(antlr4::RuleContext *context, size_t ruleIndex, size_t actionIndex) override; 39 | 40 | // By default the static state used to implement the lexer is lazily initialized during the first 41 | // call to the constructor. You can call this function if you wish to initialize the static state 42 | // ahead of time. 43 | static void initialize(); 44 | 45 | private: 46 | 47 | // Individual action functions triggered by action() above. 48 | void IDAction(antlr4::RuleContext *context, size_t actionIndex); 49 | 50 | // Individual semantic predicate functions triggered by sempred() above. 51 | 52 | }; 53 | 54 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/xpath/XPathLexer.tokens: -------------------------------------------------------------------------------- 1 | TOKEN_REF=1 2 | RULE_REF=2 3 | ANYWHERE=3 4 | ROOT=4 5 | WILDCARD=5 6 | BANG=6 7 | ID=7 8 | STRING=8 9 | '//'=3 10 | '/'=4 11 | '*'=5 12 | '!'=6 13 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/xpath/XPathLexerErrorListener.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "XPathLexerErrorListener.h" 7 | 8 | using namespace antlr4; 9 | using namespace antlr4::tree::xpath; 10 | 11 | void XPathLexerErrorListener::syntaxError(Recognizer * /*recognizer*/, Token * /*offendingSymbol*/, 12 | size_t /*line*/, size_t /*charPositionInLine*/, const std::string &/*msg*/, std::exception_ptr /*e*/) { 13 | } 14 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/xpath/XPathLexerErrorListener.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "BaseErrorListener.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace xpath { 13 | 14 | class ANTLR4CPP_PUBLIC XPathLexerErrorListener : public BaseErrorListener { 15 | public: 16 | virtual void syntaxError(Recognizer *recognizer, Token *offendingSymbol, size_t line, 17 | size_t charPositionInLine, const std::string &msg, std::exception_ptr e) override; 18 | }; 19 | 20 | } // namespace xpath 21 | } // namespace tree 22 | } // namespace antlr4 23 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/xpath/XPathRuleAnywhereElement.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/ParseTree.h" 7 | #include "tree/Trees.h" 8 | 9 | #include "tree/xpath/XPathRuleAnywhereElement.h" 10 | 11 | using namespace antlr4::tree; 12 | using namespace antlr4::tree::xpath; 13 | 14 | XPathRuleAnywhereElement::XPathRuleAnywhereElement(const std::string &ruleName, int ruleIndex) : XPathElement(ruleName) { 15 | _ruleIndex = ruleIndex; 16 | } 17 | 18 | std::vector XPathRuleAnywhereElement::evaluate(ParseTree *t) { 19 | return Trees::findAllRuleNodes(t, _ruleIndex); 20 | } 21 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/xpath/XPathRuleAnywhereElement.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "XPathElement.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace xpath { 13 | 14 | /// Either {@code ID} at start of path or {@code ...//ID} in middle of path. 15 | class ANTLR4CPP_PUBLIC XPathRuleAnywhereElement : public XPathElement { 16 | public: 17 | XPathRuleAnywhereElement(const std::string &ruleName, int ruleIndex); 18 | 19 | virtual std::vector evaluate(ParseTree *t) override; 20 | 21 | protected: 22 | int _ruleIndex = 0; 23 | }; 24 | 25 | } // namespace xpath 26 | } // namespace tree 27 | } // namespace antlr4 28 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/xpath/XPathRuleElement.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/ParseTree.h" 7 | #include "tree/Trees.h" 8 | 9 | #include "XPathRuleElement.h" 10 | 11 | using namespace antlr4::tree; 12 | using namespace antlr4::tree::xpath; 13 | 14 | XPathRuleElement::XPathRuleElement(const std::string &ruleName, size_t ruleIndex) : XPathElement(ruleName) { 15 | _ruleIndex = ruleIndex; 16 | } 17 | 18 | std::vector XPathRuleElement::evaluate(ParseTree *t) { 19 | // return all children of t that match nodeName 20 | std::vector nodes; 21 | for (auto *c : t->children) { 22 | if (antlrcpp::is(c)) { 23 | ParserRuleContext *ctx = dynamic_cast(c); 24 | if ((ctx->getRuleIndex() == _ruleIndex && !_invert) || (ctx->getRuleIndex() != _ruleIndex && _invert)) { 25 | nodes.push_back(ctx); 26 | } 27 | } 28 | } 29 | return nodes; 30 | } 31 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/xpath/XPathRuleElement.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "XPathElement.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace xpath { 13 | 14 | class ANTLR4CPP_PUBLIC XPathRuleElement : public XPathElement { 15 | public: 16 | XPathRuleElement(const std::string &ruleName, size_t ruleIndex); 17 | 18 | virtual std::vector evaluate(ParseTree *t) override; 19 | 20 | protected: 21 | size_t _ruleIndex = 0; 22 | }; 23 | 24 | } // namespace xpath 25 | } // namespace tree 26 | } // namespace antlr4 27 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/xpath/XPathTokenAnywhereElement.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/ParseTree.h" 7 | #include "tree/Trees.h" 8 | 9 | #include "XPathTokenAnywhereElement.h" 10 | 11 | using namespace antlr4::tree; 12 | using namespace antlr4::tree::xpath; 13 | 14 | XPathTokenAnywhereElement::XPathTokenAnywhereElement(const std::string &tokenName, int tokenType) : XPathElement(tokenName) { 15 | this->tokenType = tokenType; 16 | } 17 | 18 | std::vector XPathTokenAnywhereElement::evaluate(ParseTree *t) { 19 | return Trees::findAllTokenNodes(t, tokenType); 20 | } 21 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/xpath/XPathTokenAnywhereElement.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "XPathElement.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace xpath { 13 | 14 | class ANTLR4CPP_PUBLIC XPathTokenAnywhereElement : public XPathElement { 15 | protected: 16 | int tokenType = 0; 17 | public: 18 | XPathTokenAnywhereElement(const std::string &tokenName, int tokenType); 19 | 20 | virtual std::vector evaluate(ParseTree *t) override; 21 | }; 22 | 23 | } // namespace xpath 24 | } // namespace tree 25 | } // namespace antlr4 26 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/xpath/XPathTokenElement.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/ParseTree.h" 7 | #include "tree/Trees.h" 8 | #include "support/CPPUtils.h" 9 | #include "Token.h" 10 | 11 | #include "XPathTokenElement.h" 12 | 13 | using namespace antlr4; 14 | using namespace antlr4::tree; 15 | using namespace antlr4::tree::xpath; 16 | 17 | XPathTokenElement::XPathTokenElement(const std::string &tokenName, size_t tokenType) : XPathElement(tokenName) { 18 | _tokenType = tokenType; 19 | } 20 | 21 | std::vector XPathTokenElement::evaluate(ParseTree *t) { 22 | // return all children of t that match nodeName 23 | std::vector nodes; 24 | for (auto *c : t->children) { 25 | if (antlrcpp::is(c)) { 26 | TerminalNode *tnode = dynamic_cast(c); 27 | if ((tnode->getSymbol()->getType() == _tokenType && !_invert) || (tnode->getSymbol()->getType() != _tokenType && _invert)) { 28 | nodes.push_back(tnode); 29 | } 30 | } 31 | } 32 | return nodes; 33 | } 34 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/xpath/XPathTokenElement.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "XPathElement.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace xpath { 13 | 14 | class ANTLR4CPP_PUBLIC XPathTokenElement : public XPathElement { 15 | public: 16 | XPathTokenElement(const std::string &tokenName, size_t tokenType); 17 | 18 | virtual std::vector evaluate(ParseTree *t) override; 19 | 20 | protected: 21 | size_t _tokenType = 0; 22 | }; 23 | 24 | } // namespace xpath 25 | } // namespace tree 26 | } // namespace antlr4 27 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/xpath/XPathWildcardAnywhereElement.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "XPath.h" 7 | #include "tree/ParseTree.h" 8 | #include "tree/Trees.h" 9 | 10 | #include "XPathWildcardAnywhereElement.h" 11 | 12 | using namespace antlr4::tree; 13 | using namespace antlr4::tree::xpath; 14 | 15 | XPathWildcardAnywhereElement::XPathWildcardAnywhereElement() : XPathElement(XPath::WILDCARD) { 16 | } 17 | 18 | std::vector XPathWildcardAnywhereElement::evaluate(ParseTree *t) { 19 | if (_invert) { 20 | return {}; // !* is weird but valid (empty) 21 | } 22 | return Trees::getDescendants(t); 23 | } 24 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/xpath/XPathWildcardAnywhereElement.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "XPathElement.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace xpath { 13 | 14 | class ANTLR4CPP_PUBLIC XPathWildcardAnywhereElement : public XPathElement { 15 | public: 16 | XPathWildcardAnywhereElement(); 17 | 18 | virtual std::vector evaluate(ParseTree *t) override; 19 | }; 20 | 21 | } // namespace xpath 22 | } // namespace tree 23 | } // namespace antlr4 24 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/xpath/XPathWildcardElement.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "XPath.h" 7 | #include "tree/ParseTree.h" 8 | #include "tree/Trees.h" 9 | 10 | #include "XPathWildcardElement.h" 11 | 12 | using namespace antlr4::tree; 13 | using namespace antlr4::tree::xpath; 14 | 15 | XPathWildcardElement::XPathWildcardElement() : XPathElement(XPath::WILDCARD) { 16 | } 17 | 18 | std::vector XPathWildcardElement::evaluate(ParseTree *t) { 19 | if (_invert) { 20 | return {}; // !* is weird but valid (empty) 21 | } 22 | 23 | return t->children; 24 | } 25 | -------------------------------------------------------------------------------- /src/systemrdl/parser/ext/antlr4-cpp-runtime/tree/xpath/XPathWildcardElement.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "XPathElement.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace xpath { 13 | 14 | class ANTLR4CPP_PUBLIC XPathWildcardElement : public XPathElement { 15 | public: 16 | XPathWildcardElement(); 17 | 18 | virtual std::vector evaluate(ParseTree *t) override; 19 | }; 20 | 21 | } // namespace xpath 22 | } // namespace tree 23 | } // namespace antlr4 24 | -------------------------------------------------------------------------------- /src/systemrdl/parser/generate_parser.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd "$( dirname "${BASH_SOURCE[0]}" )" 3 | 4 | antlr4="java -Xmx500M -cp /usr/local/lib/antlr-4.13.1-complete.jar org.antlr.v4.Tool" 5 | 6 | # Generate Python target 7 | $antlr4 -Dlanguage=Python3 -visitor -no-listener SystemRDL.g4 8 | 9 | # Generate C++ parse accelerator extension 10 | $antlr4 -Dlanguage=Cpp -visitor -no-listener -o ext SystemRDL.g4 11 | python3 < Tuple[PreprocessedInputStream, Set[str]]: 17 | 18 | # Run file through Perl preprocessor 19 | ppp = PerlPreprocessor(env, path, search_paths) 20 | preprocessed_text, seg_map = ppp.preprocess() 21 | included_files = ppp.included_files 22 | 23 | # ... then through the Verilog preprocessor 24 | vpp = VerilogPreprocessor(env, preprocessed_text, seg_map, defines=defines) 25 | preprocessed_text, seg_map = vpp.preprocess() 26 | 27 | #segment_map.print_segment_debug(preprocessed_text, seg_map) 28 | 29 | # Encapsulate into an Antlr-like input stream object 30 | input_stream = PreprocessedInputStream(preprocessed_text, seg_map) 31 | return input_stream, included_files 32 | -------------------------------------------------------------------------------- /src/systemrdl/preprocessor/stream.py: -------------------------------------------------------------------------------- 1 | from typing import TYPE_CHECKING 2 | 3 | from antlr4 import InputStream 4 | 5 | if TYPE_CHECKING: 6 | from .segment_map import SegmentMap 7 | 8 | class PreprocessedInputStream(InputStream): 9 | def __init__(self, data: str, seg_map: 'SegmentMap'): 10 | super().__init__(data) 11 | self.seg_map = seg_map 12 | -------------------------------------------------------------------------------- /src/systemrdl/properties/__init__.py: -------------------------------------------------------------------------------- 1 | # Explicitly import these to ensure their contents are loaded, otherwise subclass 2 | # discovery wont find their contents since nothing else actually imports them directly. 3 | from . import builtin 4 | from . import prop_refs 5 | -------------------------------------------------------------------------------- /src/systemrdl/py.typed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SystemRDL/systemrdl-compiler/e6bd222554912fdc6a183e6674a6ba5d75e07632/src/systemrdl/py.typed -------------------------------------------------------------------------------- /src/systemrdl/rdltypes/array.py: -------------------------------------------------------------------------------- 1 | from typing import Any, TYPE_CHECKING, Optional 2 | 3 | if TYPE_CHECKING: 4 | from .typing import PreElabRDLType 5 | 6 | class ArrayedType(): 7 | """ 8 | Placeholder class to describe array types 9 | 10 | Once elaborated, arrays are converted to Python lists 11 | In the meantime, this placeholder is used to communicate expected type 12 | information during compilation type checking. 13 | 14 | If element_type is None, then the array being represented is empty, and 15 | therefore its element type is indeterminate 16 | """ 17 | def __init__(self, element_type: Optional['PreElabRDLType']): 18 | self.element_type = element_type 19 | 20 | def __eq__(self, other: Any) -> bool: 21 | if isinstance(other, ArrayedType): 22 | return self.element_type == other.element_type 23 | else: 24 | return NotImplemented 25 | -------------------------------------------------------------------------------- /src/systemrdl/rdltypes/typing.py: -------------------------------------------------------------------------------- 1 | from typing import Type, Union, TYPE_CHECKING 2 | 3 | if TYPE_CHECKING: 4 | from .builtin_enums import BuiltinEnum 5 | from .user_enum import UserEnum 6 | from .references import PropertyReference, RefType 7 | from .user_struct import UserStruct 8 | from .array import ArrayedType 9 | from ..node import Node 10 | from .. import component as comp 11 | 12 | # RDL Types the user will encounter via the public API 13 | RDLValue = Union[ 14 | int, bool, str, list, 15 | 'BuiltinEnum', 'UserEnum', 'UserStruct', Type['UserEnum'], 16 | 'Node', 'PropertyReference' 17 | ] 18 | 19 | # RDL Types used internally prior to elaboration 20 | PreElabRDLValue = Union[ 21 | int, bool, str, 22 | 'BuiltinEnum', 'UserEnum', 'UserStruct', 23 | 'PropertyReference', 'comp.Component', 'RefType' 24 | ] 25 | 26 | PreElabRDLType = Union[Type[PreElabRDLValue], 'ArrayedType'] 27 | -------------------------------------------------------------------------------- /test/.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | branch = True 3 | #relative_files = True 4 | 5 | omit = 6 | # Omit Antlr-generated parser templates 7 | */systemrdl/parser/SystemRDL* 8 | 9 | # Omit files autogenerated by speedy-antlr 10 | */systemrdl/parser/sa_systemrdl.py 11 | 12 | # Is not imported at runtime 13 | */systemrdl/rdltypes/typing.py 14 | 15 | [paths] 16 | source = 17 | ../systemrdl/ 18 | */site-packages/*/systemrdl 19 | */site-packages/systemrdl 20 | 21 | [report] 22 | exclude_lines = 23 | pragma: no cover 24 | raise RuntimeError 25 | raise NotImplementedError 26 | msg.fatal 27 | msg.error 28 | if TYPE_CHECKING: 29 | 30 | precision = 1 31 | -------------------------------------------------------------------------------- /test/lib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SystemRDL/systemrdl-compiler/e6bd222554912fdc6a183e6674a6ba5d75e07632/test/lib/__init__.py -------------------------------------------------------------------------------- /test/mypy.ini: -------------------------------------------------------------------------------- 1 | [mypy] 2 | 3 | # antlr4 library provides poor type hints. Ignoring 4 | ignore_missing_imports = True 5 | 6 | disallow_incomplete_defs = True 7 | disallow_untyped_defs = True 8 | warn_unused_configs = True 9 | warn_unused_ignores = True 10 | warn_unreachable = True 11 | disallow_untyped_calls = True 12 | 13 | # Ignore untyped Antlr-generated output 14 | [mypy-systemrdl.parser.*] 15 | ignore_errors = True 16 | 17 | [mypy-systemrdl.core.ComponentVisitor] 18 | disallow_untyped_calls = False 19 | 20 | [mypy-systemrdl.core.EnumVisitor] 21 | disallow_untyped_calls = False 22 | 23 | [mypy-systemrdl.core.UDPVisitor] 24 | disallow_untyped_calls = False 25 | 26 | [mypy-systemrdl.core.ExprVisitor] 27 | ignore_errors = True 28 | 29 | [mypy-systemrdl.core.StructVisitor] 30 | ignore_errors = True 31 | -------------------------------------------------------------------------------- /test/rdl_err_src/err_allocators1.rdl: -------------------------------------------------------------------------------- 1 | 2 | reg foo { 3 | field {} f1 @ 0; 4 | }; 5 | -------------------------------------------------------------------------------- /test/rdl_err_src/err_allocators2.rdl: -------------------------------------------------------------------------------- 1 | 2 | reg foo { 3 | field {} f1 += 0; 4 | }; 5 | -------------------------------------------------------------------------------- /test/rdl_err_src/err_allocators3.rdl: -------------------------------------------------------------------------------- 1 | 2 | reg foo { 3 | field {} f1 %= 0; 4 | }; 5 | -------------------------------------------------------------------------------- /test/rdl_err_src/err_bridge.rdl: -------------------------------------------------------------------------------- 1 | `include "../rdl_src/bridge.rdl" 2 | 3 | addrmap illegal_wrapper { 4 | some_bridge br; 5 | }; 6 | 7 | addrmap not_enough_addrmaps { 8 | bridge; 9 | addrmap { 10 | reg { 11 | field {} x; 12 | } y; 13 | } foo; 14 | }; 15 | 16 | addrmap illegal_children { 17 | bridge; 18 | reg { 19 | field {} x; 20 | } y; 21 | }; 22 | -------------------------------------------------------------------------------- /test/rdl_err_src/err_compile.rdl: -------------------------------------------------------------------------------- 1 | 2 | addrmap my_design { 3 | reg { 4 | field {} f1; 5 | } r1; 6 | 7 | // Intentionally bad path 8 | r1.badpath->desc = "hello"; 9 | }; 10 | -------------------------------------------------------------------------------- /test/rdl_err_src/err_duplicate_udp.rdl: -------------------------------------------------------------------------------- 1 | 2 | property bool_udp { 3 | type = boolean; 4 | component = field; 5 | }; 6 | 7 | property bool_udp { 8 | type = boolean; 9 | component = field; 10 | }; 11 | 12 | addrmap top { 13 | reg { 14 | field {}foo; 15 | }bar; 16 | }; 17 | -------------------------------------------------------------------------------- /test/rdl_err_src/err_incomplete_struct.rdl: -------------------------------------------------------------------------------- 1 | struct struct_t { 2 | boolean a; 3 | longint b; 4 | }; 5 | 6 | property struct_prop { 7 | type = struct_t; 8 | component = field; 9 | }; 10 | 11 | addrmap top { 12 | reg { 13 | field { 14 | struct_prop = struct_t'{a: true}; 15 | } f; 16 | } reg_error; 17 | }; 18 | -------------------------------------------------------------------------------- /test/rdl_err_src/err_mem_defs.rdl: -------------------------------------------------------------------------------- 1 | mem x { 2 | addrmap foo {}; 3 | }; 4 | -------------------------------------------------------------------------------- /test/rdl_err_src/err_ref_in_parameter.rdl: -------------------------------------------------------------------------------- 1 | signal {} my_signal1; 2 | signal {} my_signal2; 3 | 4 | struct my_struct { 5 | signal my_ref; 6 | }; 7 | 8 | reg myReg #( 9 | my_struct PARAM = my_struct'{my_ref: my_signal1} 10 | ) { 11 | field { 12 | next = PARAM.my_ref; 13 | } data[0:0] = 0; 14 | }; 15 | 16 | addrmap parameters1 { 17 | myReg reg0; 18 | }; 19 | 20 | addrmap parameters2 { 21 | myReg #( 22 | .PARAM(my_struct'{my_ref: my_signal2}) 23 | ) reg0; 24 | }; 25 | -------------------------------------------------------------------------------- /test/rdl_err_src/err_reset_signals.rdl: -------------------------------------------------------------------------------- 1 | default sw=rw; 2 | default hw=r; 3 | 4 | 5 | addrmap field_resets { 6 | reg { 7 | signal {field_reset;} reset_a; 8 | field {} A = 0; 9 | signal {field_reset;} reset_b; 10 | } z; 11 | }; 12 | 13 | 14 | addrmap cpuif_resets { 15 | reg { 16 | signal {cpuif_reset;} reset_x; 17 | field {} A = 0; 18 | signal {cpuif_reset;} reset_y; 19 | } z; 20 | }; 21 | 22 | 23 | signal {field_reset;} freset_root1; 24 | signal {field_reset;} freset_root2; 25 | signal {cpuif_reset;} creset_root1; 26 | signal {cpuif_reset;} creset_root2; 27 | -------------------------------------------------------------------------------- /test/rdl_err_src/err_singlepulse.rdl: -------------------------------------------------------------------------------- 1 | 2 | addrmap top { 3 | reg { 4 | field { 5 | singlepulse; 6 | } good1 = 0; 7 | 8 | field { 9 | singlepulse=false; 10 | } good2 = 0; 11 | 12 | field { 13 | singlepulse; 14 | sw=r; 15 | } bad1[8] = 3; 16 | 17 | field { 18 | singlepulse; 19 | sw=rw; 20 | onwrite=wclr; 21 | } bad2 = 0; 22 | } r1; 23 | }; 24 | -------------------------------------------------------------------------------- /test/rdl_err_src/err_syntax.rdl: -------------------------------------------------------------------------------- 1 | 2 | addrmap my_design 3 | }; 4 | -------------------------------------------------------------------------------- /test/rdl_err_src/err_validate.rdl: -------------------------------------------------------------------------------- 1 | 2 | addrmap reg_overlap { 3 | reg my_reg_t { 4 | field {} f1; 5 | }; 6 | 7 | my_reg_t r1 @ 0x100; 8 | my_reg_t r2 @ 0x100; 9 | }; 10 | 11 | //------------------------------------------------------------------------------ 12 | addrmap reg_array_overlap { 13 | reg reg32 { 14 | field {} f[32] = 0; 15 | }; 16 | reg32 r_array[4] @ 0 += 1; // <--- small array stride causes overlap 17 | }; 18 | 19 | //------------------------------------------------------------------------------ 20 | addrmap regfile_array_overlap { 21 | reg reg32 { 22 | field {} f[32] = 0; 23 | }; 24 | 25 | regfile rf_100 { 26 | reg32 x @ 0xFC; 27 | }; 28 | rf_100 rf_array[4] @ 0x1000 += 1; // <--- small array stride causes overlap 29 | }; 30 | -------------------------------------------------------------------------------- /test/rdl_err_src/err_we_wel.rdl: -------------------------------------------------------------------------------- 1 | addrmap top { 2 | reg { 3 | field { 4 | sw=rw; hw=w; 5 | we; 6 | } good1 = 0; 7 | 8 | field { 9 | sw=rw; hw=w; 10 | wel; 11 | } good2 = 0; 12 | 13 | field { 14 | sw=r; hw=na; 15 | we; 16 | } bad1 = 0; 17 | 18 | field { 19 | sw=r; hw=na; 20 | wel; 21 | } bad2 = 0; 22 | } r1; 23 | }; 24 | -------------------------------------------------------------------------------- /test/rdl_err_src/prop_ref_err.rdl: -------------------------------------------------------------------------------- 1 | addrmap err_missing_reset { 2 | reg { 3 | default sw=rw; 4 | default hw=rw; 5 | field {} a; 6 | field {} b; 7 | b->next = a->reset; // a's reset was never set 8 | }y; 9 | }; 10 | 11 | addrmap err_circular_ref { 12 | reg { 13 | default sw=rw; 14 | default hw=rw; 15 | field {} a; 16 | field {} b; 17 | a->next = b->next; 18 | b->next = a->next; 19 | }y; 20 | }; 21 | 22 | addrmap err_self_reset { 23 | reg { 24 | default sw=rw; 25 | default hw=rw; 26 | field {} a; 27 | a->reset = a; 28 | }y; 29 | }; 30 | 31 | addrmap err_no_inferred { 32 | reg { 33 | default sw=rw; 34 | default hw=rw; 35 | field {} a; 36 | field {} b; 37 | b->next = a->we; 38 | }y; 39 | }; 40 | 41 | addrmap err_not_a_counter { 42 | reg { 43 | default sw=rw; 44 | default hw=rw; 45 | field {} a; 46 | field {} b; 47 | b->next = a->incr; 48 | }y; 49 | }; 50 | 51 | addrmap err_no_counter_threshold { 52 | reg { 53 | default sw=rw; 54 | default hw=rw; 55 | field { 56 | counter; 57 | } a; 58 | field {} b; 59 | field {} c; 60 | b->next = a->incrthreshold; 61 | }y; 62 | }; 63 | -------------------------------------------------------------------------------- /test/rdl_src/alias.rdl: -------------------------------------------------------------------------------- 1 | addrmap alias_basics { 2 | reg my_reg_t { 3 | field {} x = 0; 4 | field {} y = 0; 5 | }; 6 | reg my_alt_reg_t { 7 | field {} x = 0; 8 | }; 9 | 10 | my_reg_t primary @ 0x04; 11 | alias primary my_reg_t alias1 @ 0x00; 12 | alias primary my_reg_t alias2 @ 0x08; 13 | alias primary my_alt_reg_t alias3 @ 0x0C; 14 | 15 | external my_reg_t ext_primary @ 0x14; 16 | alias ext_primary my_reg_t ext_alias1 @ 0x10; 17 | alias ext_primary my_reg_t ext_alias2 @ 0x18; 18 | external alias ext_primary my_reg_t ext_alias3 @ 0x1C; 19 | 20 | 21 | my_reg_t primary_array[2] @ 0x20 += 4; 22 | alias primary_array my_reg_t alias_array[2] @ 0x30 += 4; 23 | }; 24 | 25 | 26 | addrmap mixed_access { 27 | reg my_reg_t { 28 | field { 29 | hw=r; 30 | sw=rw; 31 | } x = 0; 32 | }; 33 | 34 | my_reg_t primary; 35 | 36 | alias primary my_reg_t alias1; 37 | alias1.x->sw=r; 38 | }; 39 | -------------------------------------------------------------------------------- /test/rdl_src/bridge.rdl: -------------------------------------------------------------------------------- 1 | addrmap some_bridge { // Define a Bridge Device 2 | desc="overlapping address maps with both shared register space and 3 | orthogonal register space"; 4 | bridge; // This tells the compiler the top level map contains other maps 5 | 6 | reg status {// Define at least 1 register for the bridge 7 | shared; 8 | // Shared property tells compiler this register 9 | // will be shared by multiple addrmaps 10 | field { 11 | hw=rw; 12 | sw=r; 13 | } stat1 = 1'b0; 14 | }; 15 | 16 | reg some_axi_reg { 17 | field { 18 | desc="credits on the AXI interface"; 19 | } credits[4] = 4'h7; 20 | }; 21 | 22 | reg some_ahb_reg { 23 | field { 24 | desc="credits on the AHB Interface"; 25 | } credits[8] = 8'b00000011; 26 | }; 27 | 28 | addrmap { 29 | littleendian; 30 | some_ahb_reg ahb_credits; // Implies addr = 0 31 | status ahb_stat @0x20; // explicitly at address=20 32 | ahb_stat.stat1->desc = "bar"; // Overload the registers property in 33 | // this instance 34 | } ahb; 35 | 36 | addrmap { // Define the Map for the AXI Side of the bridge 37 | bigendian; // This map is big endian 38 | some_axi_reg axi_credits; // Implies addr = 0 39 | status axi_stat @0x40; // explicitly at address=40 40 | axi_stat.stat1->desc = "foo"; // Overload the registers property 41 | // in this instance 42 | } axi; 43 | 44 | }; 45 | -------------------------------------------------------------------------------- /test/rdl_src/counter_extras.rdl: -------------------------------------------------------------------------------- 1 | addrmap top { 2 | signal {} incr_signal; 3 | signal {} decr_signal; 4 | reg { 5 | field { 6 | sw=r; hw=na; 7 | counter; 8 | incr = incr_signal; 9 | decr = decr_signal; 10 | overflow; 11 | underflow; 12 | incrwidth = 2; 13 | decrwidth = 3; 14 | } f1[8] = 0; 15 | 16 | field { 17 | sw=r; hw=na; 18 | counter; 19 | incr = incr_signal; 20 | decr = decr_signal; 21 | } f2[8] = 0; 22 | } r1; 23 | }; 24 | -------------------------------------------------------------------------------- /test/rdl_src/dpa_names.rdl: -------------------------------------------------------------------------------- 1 | 2 | addrmap dpa_overrides { 3 | reg my_reg { 4 | enum onoff_e { 5 | off = 0; 6 | on = 1; 7 | }; 8 | 9 | field my_field { 10 | sw = rw; 11 | hw = rw; 12 | we; 13 | }; 14 | 15 | my_field f1; 16 | my_field f2; 17 | my_field f3; 18 | f2->rclr; 19 | f3->encode = onoff_e; 20 | f3->next = f1->anded; 21 | }; 22 | 23 | my_reg r0; 24 | 25 | my_reg r1; 26 | r1.f1->rclr; 27 | 28 | my_reg r2; 29 | r2.f1->next = r0.f1; 30 | }; 31 | -------------------------------------------------------------------------------- /test/rdl_src/enums.rdl: -------------------------------------------------------------------------------- 1 | 2 | addrmap enum_test1 { 3 | enum my_enum { 4 | zero; 5 | one; 6 | three = 3 {}; 7 | four {}; 8 | five { 9 | name = "five's [b]name[/b]"; 10 | desc = "this is five"; 11 | }; 12 | }; 13 | 14 | field my_field_t #( 15 | my_enum FOO = my_enum::four 16 | ) { 17 | fieldwidth=4; 18 | reset = FOO + 1; 19 | encode = my_enum; 20 | }; 21 | 22 | reg { 23 | my_field_t f_default[4]; 24 | my_field_t #(.FOO(my_enum::zero)) f_zero[4]; 25 | my_field_t #(.FOO(my_enum::one)) f_one[4]; 26 | my_field_t #(.FOO(my_enum::three)) f_three[4]; 27 | my_field_t #(.FOO(my_enum::four)) f_four[4]; 28 | my_field_t #(.FOO(my_enum::five)) f_five[4]; 29 | } reg1; 30 | 31 | // Make enum that uses names that are hostile to Python 32 | enum __init__ { 33 | mro; 34 | __dict__; 35 | _name_; 36 | _value_; 37 | _missing_; 38 | _ignore_; 39 | _order_; 40 | _generate_next_value_; 41 | }; 42 | 43 | reg { 44 | field { 45 | encode = __init__; 46 | } 47 | f0[3] = __init__::mro, 48 | f1[3] = __init__::__dict__, 49 | f2[3] = __init__::_name_, 50 | f3[3] = __init__::_value_, 51 | f4[3] = __init__::_missing_, 52 | f5[3] = __init__::_ignore_, 53 | f6[3] = __init__::_order_, 54 | f7[3] = __init__::_generate_next_value_; 55 | } reg2; 56 | }; 57 | -------------------------------------------------------------------------------- /test/rdl_src/enums_in_expressions.rdl: -------------------------------------------------------------------------------- 1 | property int_prop { 2 | type = longint; 3 | component = all; 4 | }; 5 | 6 | addrmap enum_expr_test { 7 | enum my_enum1 { 8 | zero; 9 | one; 10 | two; 11 | three; 12 | }; 13 | 14 | enum my_enum2 { 15 | ten = 10; 16 | eleven = 11; 17 | twelve = 12; 18 | thirteen = 13; 19 | }; 20 | 21 | reg myreg { 22 | field {} f; 23 | }; 24 | 25 | // convenience macro that instantiates the reg, and assigns the UDP with an expression 26 | `define EXPR(name, expr) myreg name; name->int_prop = expr 27 | 28 | `EXPR(concat1, {my_enum2::twelve, 8'h10}); 29 | `EXPR(concat2, {8'h22, my_enum2::thirteen, 8'h10}); 30 | `EXPR(concat3, {8'h22, (8)'(my_enum2::thirteen), 8'h10}); 31 | `EXPR(repl, {3{my_enum1::three}}); 32 | `EXPR(add, my_enum1::three + 5); 33 | `EXPR(sub, my_enum1::three - 1); 34 | `EXPR(mul, my_enum1::three * 2); 35 | `EXPR(div, my_enum2::twelve / 2); 36 | `EXPR(mod, my_enum2::twelve % 5); 37 | `EXPR(and, my_enum2::twelve & 9); 38 | `EXPR(or, my_enum2::twelve | 9); 39 | `EXPR(xor, my_enum2::twelve ^ 9); 40 | `EXPR(inv, ~my_enum2::twelve); 41 | }; 42 | -------------------------------------------------------------------------------- /test/rdl_src/field_access_types.rdl: -------------------------------------------------------------------------------- 1 | 2 | addrmap top { 3 | reg { 4 | field { 5 | sw=rw;hw=r; 6 | } f1 = 0; 7 | 8 | field { 9 | sw=r;hw=w; 10 | } f2 = 0; 11 | field { 12 | sw=r;hw=rw; 13 | we; 14 | } f3 = 0; 15 | field { 16 | sw=w;hw=r; 17 | swwe; 18 | } f4 = 0; 19 | field { 20 | sw=r;hw=r; 21 | onread = rclr; 22 | } f5 = 1; 23 | field { 24 | sw=r;hw=r; 25 | hwclr; 26 | } f6 = 1; 27 | field { 28 | sw=rw;hw=rw; 29 | we; 30 | precedence = hw; 31 | } f7 = 0; 32 | field { 33 | sw=rw;hw=rw; 34 | precedence = sw; 35 | we; 36 | } f8 = 0; 37 | field { 38 | sw=rw;hw=rw; 39 | we; 40 | } f9 = 0; 41 | field { 42 | sw=r;hw=w; 43 | we; 44 | } f10 = 0; 45 | field { 46 | sw=r;hw=w; 47 | wel; 48 | } f11 = 0; 49 | field { 50 | sw=w; hw=na; 51 | } f12 = 0; 52 | } r1; 53 | 54 | reg { 55 | field {sw=r; hw=w;} f; 56 | } r2; 57 | reg { 58 | field {sw=w; hw=r;} f; 59 | } r3; 60 | }; 61 | -------------------------------------------------------------------------------- /test/rdl_src/field_gaps.rdl: -------------------------------------------------------------------------------- 1 | addrmap top { 2 | reg { 3 | field {} a[32]; 4 | } a; 5 | 6 | reg { 7 | field {} a[7:0]; 8 | field {} b[15:8]; 9 | field {} c[31:16]; 10 | } b; 11 | 12 | reg { 13 | field {} a[7:1]; 14 | field {} b[15:9]; 15 | field {} c[30:17]; 16 | } c; 17 | 18 | reg { 19 | field {} a[7:2]; 20 | field {} b[15:10]; 21 | field {} c[29:18]; 22 | } d; 23 | }; 24 | -------------------------------------------------------------------------------- /test/rdl_src/global_type_names.rdl: -------------------------------------------------------------------------------- 1 | reg r_global { 2 | field {} f1[4]; 3 | 4 | field myfield {}; 5 | myfield f2; 6 | myfield f3[4]; 7 | field myfield2 {fieldwidth = 4;}; 8 | myfield2 f4; 9 | }; 10 | 11 | regfile rf_global #( 12 | longint unsigned NUM = 4 13 | ){ 14 | reg r_local { 15 | field {} f_param[NUM]; 16 | field myfield {}; 17 | myfield f_param2[NUM]; 18 | } r1; 19 | r_global r2; 20 | }; 21 | 22 | addrmap top { 23 | rf_global rf1; 24 | rf_global #(.NUM (8)) rf2; 25 | }; 26 | -------------------------------------------------------------------------------- /test/rdl_src/incdir/preprocessor_incl2.rdl: -------------------------------------------------------------------------------- 1 | 2 | reg reg2_t { 3 | myField x; 4 | }; 5 | 6 | `define INST_TPASTE(typ, a, b) `INST(typ, a``b) \ -------------------------------------------------------------------------------- /test/rdl_src/incomplete_struct.rdl: -------------------------------------------------------------------------------- 1 | struct struct_t { 2 | boolean x; 3 | boolean a; 4 | string b; 5 | accesstype c; 6 | addressingtype d; 7 | longint e[]; 8 | }; 9 | 10 | property struct_prop { 11 | type = struct_t; 12 | component = field; 13 | }; 14 | 15 | addrmap top { 16 | reg { 17 | field { 18 | struct_prop = struct_t'{}; 19 | } f1; 20 | } r1; 21 | }; 22 | -------------------------------------------------------------------------------- /test/rdl_src/internal_external.rdl: -------------------------------------------------------------------------------- 1 | signal {} test_signal; 2 | 3 | addrmap extern_test { 4 | reg rega_t {field {} x;} external reg1, reg2; 5 | reg regb_t {field {} x;} internal reg3, reg4; 6 | reg regc_t {field {} x;} reg5; 7 | reg reg_t {field {} x;}; 8 | reg {field {} x;} external reg6; 9 | reg {field {} x;} external reg7; 10 | reg {field {} x;} reg8; 11 | external reg_t reg9; 12 | internal reg_t reg10; 13 | external reg { field {} x; } reg11; 14 | internal reg { field {} x; } reg12; 15 | 16 | regfile rfile1_t { 17 | external reg_t rega; 18 | internal reg_t regb; 19 | reg_t regc; 20 | }; 21 | 22 | regfile rfile2_t { 23 | external rfile1_t rf1a; 24 | internal rfile1_t rf1b; 25 | rfile1_t rf1c; 26 | }; 27 | 28 | external rfile1_t rf1a; 29 | internal rfile1_t rf1b; 30 | rfile1_t rf1c; 31 | 32 | external rfile2_t rf2a; 33 | internal rfile2_t rf2b; 34 | rfile2_t rf2c; 35 | }; 36 | -------------------------------------------------------------------------------- /test/rdl_src/intr_prop_mod.rdl: -------------------------------------------------------------------------------- 1 | 2 | addrmap intr_prop_mod_test { 3 | reg { 4 | default posedge intr; 5 | 6 | field {} irq1; // intr=true, intr mod = posedge 7 | field {} irq2; // intr=true, intr mod = posedge 8 | field {} irq3; // intr=false, intr mod = posedge 9 | field { 10 | negedge intr; 11 | } irq4; // intr=true, intr mod = negedge 12 | 13 | irq2->intr = true; 14 | irq3->intr = false; 15 | }reg1; 16 | 17 | reg { 18 | field { 19 | nonsticky intr; // implies intr=true, stickybit = false; 20 | posedge intr;// implies intr=true again 21 | intr = true; // Still OK 22 | }irqA; 23 | }reg2; 24 | 25 | reg { 26 | field { 27 | intr = true; // Implies level 28 | }irqX; 29 | }reg3; 30 | }; 31 | -------------------------------------------------------------------------------- /test/rdl_src/memories.rdl: -------------------------------------------------------------------------------- 1 | addrmap memories { 2 | 3 | external mem { 4 | mementries = 2; 5 | memwidth = 32; 6 | sw = w; 7 | } mem_2_32_w; 8 | 9 | external mem { 10 | mementries = 2; 11 | memwidth = 32; 12 | sw = r; 13 | } mem_2_32_r; 14 | 15 | external mem { 16 | mementries = 2; 17 | memwidth = 32; 18 | sw = rw; 19 | } mem_2_32_rw; 20 | 21 | external mem { 22 | mementries = 5; 23 | memwidth = 64; 24 | sw = w; 25 | } mem_5_64_w; 26 | 27 | external mem { 28 | mementries = 5; 29 | memwidth = 64; 30 | sw = r; 31 | } mem_5_64_r; 32 | 33 | external mem { 34 | mementries = 5; 35 | memwidth = 64; 36 | sw = rw; 37 | } mem_5_64_rw; 38 | 39 | }; -------------------------------------------------------------------------------- /test/rdl_src/preprocessor_incl.rdl: -------------------------------------------------------------------------------- 1 | 2 | <% $n_regs=3; %> 3 | 4 | field myField {}; 5 | 6 | 7 | `include "preprocessor_incl2.rdl" 8 | 9 | `define msg(x,y) `"x: `\`"y`\`"`" 10 | `define TOP(a,b) a + b 11 | `define STR(s) `"s`" 12 | `define TOPSTR `STR(`TOP( `TOP(b,1), `TOP(42,a) )) -------------------------------------------------------------------------------- /test/rdl_src/prop_ref-in_array.rdl: -------------------------------------------------------------------------------- 1 | addrmap ref_in_array { 2 | reg { 3 | default sw=rw; 4 | default hw=rw; 5 | field {} a = 0; 6 | field {} b = 0; 7 | b->next = a->anded; 8 | } myreg[8]; 9 | }; 10 | -------------------------------------------------------------------------------- /test/rdl_src/prop_ref-inferred_vector.rdl: -------------------------------------------------------------------------------- 1 | addrmap inferred_vector { 2 | reg { 3 | default sw=rw; 4 | default hw=rw; 5 | field { 6 | sw=rw; hw=w; we; 7 | } a; 8 | field {} b; 9 | field {} c; 10 | b->next = a->we; 11 | c->next = a->wel; 12 | }y; 13 | }; 14 | -------------------------------------------------------------------------------- /test/rdl_src/prop_ref-value_ref.rdl: -------------------------------------------------------------------------------- 1 | 2 | addrmap prop_value_ref { 3 | reg { 4 | default sw=rw; 5 | default hw=rw; 6 | field {} a = 0; 7 | field {} b; 8 | field {} c; 9 | field {} d; 10 | field {} e; 11 | b->next = a->reset; 12 | c->next = a->reset; 13 | d->next = a->anded; 14 | e->next = b->anded; 15 | }y; 16 | }; 17 | -------------------------------------------------------------------------------- /test/rdl_src/property_typecast.rdl: -------------------------------------------------------------------------------- 1 | enum test_e { 2 | VAL0 = 0; 3 | VAL1 = 1; 4 | VAL2 = 2; 5 | VAL3 = 3; 6 | }; 7 | 8 | addrmap enum_cast { 9 | reg { 10 | field f_t { 11 | encode = test_e; 12 | }; 13 | 14 | f_t f1[2]; 15 | f_t f2[2]; 16 | f_t f3[2]; 17 | f_t f4[2]; 18 | 19 | // Implicit cast to int 20 | f1->reset = test_e::VAL3; 21 | 22 | // implicit cast to bool 23 | f1->we = 100; 24 | f2->we = test_e::VAL1; 25 | f3->we = 0; 26 | f4->we = test_e::VAL0; 27 | } r1; 28 | }; -------------------------------------------------------------------------------- /test/rdl_src/references_default_lhs.rdl: -------------------------------------------------------------------------------- 1 | 2 | property ref_prop { 3 | component = all; 4 | type = ref; 5 | }; 6 | 7 | signal {activehigh;} glbl_sig; 8 | 9 | default resetsignal = glbl_sig; 10 | 11 | reg my_reg { 12 | field {} x; 13 | 14 | signal {activehigh;} sig; 15 | 16 | default ref_prop = x; 17 | default resetsignal = sig; 18 | default next = x->anded; 19 | 20 | field my_field {}; 21 | 22 | my_field y; 23 | }; 24 | 25 | addrmap top { 26 | my_reg reg1; 27 | 28 | default ref_prop = reg1; 29 | 30 | my_reg reg2[2]; 31 | 32 | default resetsignal = reg2[1].sig; 33 | default next = reg2[0].y->ored; 34 | 35 | field field_z {}; 36 | 37 | reg { 38 | field_z z; 39 | } reg3; 40 | }; 41 | -------------------------------------------------------------------------------- /test/rdl_src/references_direct_lhs.rdl: -------------------------------------------------------------------------------- 1 | property ref_prop { 2 | component = all; 3 | type = ref; 4 | }; 5 | 6 | 7 | signal {activehigh;} glbl_sig; 8 | 9 | reg my_reg { 10 | signal {activehigh;} sig; 11 | 12 | field { 13 | resetsignal = glbl_sig; 14 | } x; 15 | 16 | field { 17 | resetsignal = sig; 18 | } y; 19 | 20 | ref_prop = x; 21 | }; 22 | 23 | addrmap top { 24 | my_reg reg1; 25 | my_reg reg2[2]; 26 | 27 | ref_prop = reg2[1].x; 28 | }; 29 | -------------------------------------------------------------------------------- /test/rdl_src/references_dynamic_lhs.rdl: -------------------------------------------------------------------------------- 1 | 2 | property ref_prop { 3 | component = all; 4 | type = ref; 5 | }; 6 | 7 | signal {activehigh;} glbl_sig; 8 | 9 | reg my_reg { 10 | field {} x; 11 | field {} y; 12 | signal {activehigh;} sig; 13 | 14 | x->ref_prop = y; 15 | y->ref_prop = x; 16 | 17 | x->resetsignal = sig; 18 | y->resetsignal = glbl_sig; 19 | 20 | y->next = x->anded; 21 | }; 22 | 23 | addrmap top { 24 | my_reg reg1; 25 | my_reg reg2[2]; 26 | 27 | reg1->ref_prop = reg2[0]; 28 | reg2->ref_prop = reg2[1].x; 29 | 30 | reg2.x->ref_prop = reg1; 31 | reg2.y->ref_prop = reg1.x; 32 | 33 | reg1.x->resetsignal = glbl_sig; 34 | 35 | reg1.x->next = reg2[0].y->ored; 36 | }; 37 | -------------------------------------------------------------------------------- /test/rdl_src/reset_signals.rdl: -------------------------------------------------------------------------------- 1 | default sw=rw; 2 | default hw=r; 3 | 4 | addrmap field_resets { 5 | signal {activehigh;} reset_x; 6 | signal {field_reset = false;} not_a_reset; 7 | 8 | regfile { 9 | signal {field_reset; activehigh;} reset_y; 10 | reg { 11 | signal {field_reset; activelow;} reset_z; 12 | 13 | field {} A = 0; // implied reset_z 14 | field {resetsignal = reset_x;} B = 0; 15 | field {resetsignal = reset_y;} C = 0; 16 | } x; 17 | 18 | reg { 19 | field {} A = 0; // implied reset_y 20 | field {resetsignal = reset_x;} B = 0; 21 | } y; 22 | } rf; 23 | 24 | reg { 25 | field {} A = 0; // No implied resetsignal 26 | field {resetsignal = reset_x;} B = 0; 27 | } z; 28 | }; 29 | 30 | 31 | addrmap cpuif_resets { 32 | signal {cpuif_reset = false;} not_a_reset; 33 | regfile { 34 | signal {cpuif_reset; activehigh;} reset_x; 35 | reg { 36 | signal {cpuif_reset; activehigh;} reset_y; 37 | 38 | field {} A = 0; 39 | } x; 40 | 41 | reg { 42 | field {} A = 0; 43 | } y; 44 | } rf; 45 | 46 | reg { 47 | field {} A = 0; // No implied resetsignal 48 | } z; 49 | }; 50 | -------------------------------------------------------------------------------- /test/rdl_src/scopes.rdl: -------------------------------------------------------------------------------- 1 | 2 | enum root_enum { 3 | zero; 4 | one; 5 | }; 6 | 7 | reg root_reg_t { 8 | field { 9 | enum f1_enum { 10 | a; 11 | b; 12 | }; 13 | encode = f1_enum; 14 | } f1; 15 | 16 | field f2_t { 17 | encode = root_enum; 18 | }; 19 | 20 | f2_t f2; 21 | 22 | enum f3_enum { 23 | x; 24 | y; 25 | }; 26 | field { 27 | encode = f3_enum; 28 | } f3; 29 | }; 30 | 31 | addrmap scope_test { 32 | 33 | root_reg_t r1; 34 | 35 | reg r2_t { 36 | field { 37 | enum f1_enum { 38 | a; 39 | b; 40 | }; 41 | encode = f1_enum; 42 | } f1; 43 | 44 | field f2_t { 45 | encode = root_enum; 46 | }; 47 | 48 | f2_t f2; 49 | }; 50 | r2_t r2; 51 | }; 52 | -------------------------------------------------------------------------------- /test/rdl_src/signal_scope.rdl: -------------------------------------------------------------------------------- 1 | 2 | addrmap top { 3 | signal { 4 | name = "default"; 5 | activehigh; 6 | } my_signal; 7 | 8 | reg my_reg_t { 9 | field my_field_t { 10 | sw=rw; hw=r; 11 | resetsignal = my_signal; 12 | }; 13 | my_field_t b; 14 | }; 15 | my_reg_t a; 16 | 17 | my_signal->name = "override"; 18 | }; 19 | -------------------------------------------------------------------------------- /test/rdl_src/signals.rdl: -------------------------------------------------------------------------------- 1 | addrmap top { 2 | signal { 3 | signalwidth = 8; 4 | } s1; 5 | 6 | reg { 7 | signal { 8 | signalwidth = 6; 9 | } s1; 10 | field { 11 | signal { 12 | signalwidth = 4; 13 | } s1; 14 | } f1; 15 | } r1; 16 | }; 17 | -------------------------------------------------------------------------------- /test/rdl_src/struct_compositions.rdl: -------------------------------------------------------------------------------- 1 | 2 | struct s1_t { 3 | longint n_arr[]; 4 | boolean bool; 5 | string str; 6 | }; 7 | 8 | struct s2_t { 9 | accesstype access; 10 | s1_t nest; 11 | s1_t nest_arr[]; 12 | }; 13 | 14 | property p_int { 15 | component = all; 16 | type = longint; 17 | }; 18 | 19 | property p_bool { 20 | component = all; 21 | type = boolean; 22 | }; 23 | 24 | property p_s1 { 25 | component = all; 26 | type = s1_t; 27 | }; 28 | 29 | //------------------------------------------------------------------------------ 30 | 31 | reg my_reg_t #(s2_t S) { 32 | field {} x; 33 | 34 | desc = S.nest.str; 35 | name = S.nest_arr[0].str; 36 | x->sw = S.access; 37 | x->name = S.nest_arr[1].str; 38 | 39 | p_s1 = S.nest_arr[0]; 40 | p_bool = S.nest.bool; 41 | p_int = S.nest_arr[1].n_arr[2]; 42 | }; 43 | 44 | addrmap top { 45 | my_reg_t #( 46 | .S(s2_t'{ 47 | nest_arr: '{ 48 | s1_t'{ 49 | bool: false, 50 | str: "foo", 51 | n_arr: '{20,40,60,80} 52 | }, 53 | s1_t'{ 54 | bool: true, 55 | str: "bar", 56 | n_arr: '{21,41,61,81} 57 | } 58 | }, 59 | access: r, 60 | nest: s1_t'{ 61 | bool: true, 62 | str: "hey", 63 | n_arr: '{2,4,6,8} 64 | } 65 | }) 66 | ) my_reg; 67 | }; 68 | -------------------------------------------------------------------------------- /test/rdl_src/udp_15.2.2_ex1.rdl: -------------------------------------------------------------------------------- 1 | property a_map_p { type = string; component = addrmap | regfile; }; 2 | property some_bool_p { type = boolean; component = field; default = false; }; 3 | property some_ref_p { type = ref; component = all; }; 4 | property some_num_p { type = number; default = 0x10; component = field | reg | regfile; }; 5 | 6 | addrmap foo { 7 | reg{ 8 | field { some_bool_p; } field1; // Attach some_bool_p to the field 9 | // with a value of false; 10 | 11 | field { sw=rw; some_bool_p = true; some_num_p; } field2; 12 | // Attach some_bool_p to the field with a value of true; 13 | field1->some_ref_p = field2; // create a reference 14 | some_num_p = 0x20; // Assign this property to the reg and give it value 15 | } bar; 16 | 17 | a_map_p; // The property has been bound to the map but it has not been 18 | // assigned a value so its value is undefined 19 | }; 20 | -------------------------------------------------------------------------------- /test/rdl_src/udp_15.2.2_ex2.rdl: -------------------------------------------------------------------------------- 1 | enum myEncoding { 2 | alpha = 1'b0; 3 | beta = 1'b1; 4 | }; 5 | 6 | property my_enc_prop { 7 | type = myEncoding; 8 | component = field; 9 | default = myEncoding::beta; 10 | }; 11 | 12 | addrmap top { 13 | reg { 14 | field { my_enc_prop = myEncoding::alpha ; } f ; 15 | } regA ; 16 | } ; 17 | -------------------------------------------------------------------------------- /test/rdl_src/udp_arrays.rdl: -------------------------------------------------------------------------------- 1 | property ref_array { 2 | type = ref[]; 3 | component = addrmap; 4 | }; 5 | 6 | property reg_array { 7 | type = reg[]; 8 | component = addrmap; 9 | }; 10 | 11 | property field_array { 12 | type = field[]; 13 | component = addrmap; 14 | }; 15 | 16 | property int_array { 17 | type = longint[]; 18 | component = addrmap; 19 | }; 20 | 21 | struct my_struct { 22 | boolean my_bool; 23 | string my_string; 24 | }; 25 | struct my_extended_struct : my_struct { 26 | longint my_int; 27 | }; 28 | 29 | property struct_array { 30 | type = my_struct[]; 31 | component = addrmap; 32 | }; 33 | 34 | 35 | addrmap top { 36 | field my_field {sw=rw; hw=r;}; 37 | reg my_reg { 38 | my_field f1; 39 | my_field f2; 40 | }; 41 | 42 | my_reg r1; 43 | my_reg r2; 44 | my_reg r3; 45 | 46 | ref_array = '{r1, r2.f1, r3.f2->anded}; 47 | reg_array = '{r1, r2}; 48 | field_array = '{r1.f1, r2.f1, r3.f1}; 49 | int_array = '{10, 20}; 50 | struct_array = '{ 51 | my_struct'{my_bool: true, my_string: "hey"}, 52 | my_struct'{my_bool: false, my_string: "hello"}, 53 | my_extended_struct'{my_bool: false, my_string: "extended", my_int: 42} 54 | }; 55 | 56 | addrmap { 57 | my_reg x; 58 | my_reg y; 59 | 60 | ref_array = '{x.f1, x.f2, y.f1, y.f2}; 61 | } sub1; 62 | 63 | addrmap { 64 | my_reg a; 65 | my_reg b; 66 | 67 | ref_array = '{a.f1->anded, b.f2->anded}; 68 | } sub2; 69 | 70 | addrmap { 71 | my_reg reg1; 72 | } sub3; 73 | sub3->ref_array = '{sub2.a.f1, sub1.x.f2}; 74 | }; 75 | -------------------------------------------------------------------------------- /test/rdl_src/udp_builtin.rdl: -------------------------------------------------------------------------------- 1 | addrmap top { 2 | reg{ 3 | field { 4 | int_udp; 5 | } field1; 6 | int_udp = 42; 7 | } reg1; 8 | int_udp = 43; 9 | }; 10 | -------------------------------------------------------------------------------- /test/rdl_src/udp_types.rdl: -------------------------------------------------------------------------------- 1 | property int_udp { 2 | type = longint; 3 | default = 123; 4 | component = all; 5 | }; 6 | 7 | property bool_udp { 8 | type = boolean; 9 | default = false; 10 | component = all; 11 | }; 12 | 13 | 14 | addrmap top { 15 | reg { 16 | field { 17 | int_udp; 18 | bool_udp; 19 | } defaults; 20 | } x; 21 | }; 22 | -------------------------------------------------------------------------------- /test/requirements.txt: -------------------------------------------------------------------------------- 1 | pytest 2 | pytest-cov 3 | parameterized 4 | pylint 5 | types-Markdown 6 | types-colorama 7 | #types-antlr4-python3-runtime 8 | 9 | mypy 10 | -------------------------------------------------------------------------------- /test/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | cd "$(dirname "$0")" 6 | 7 | exists () { 8 | type "$1" >/dev/null 2>/dev/null 9 | } 10 | 11 | # If ccache is installed, use that to cache C++ compilation to speed up re-runs 12 | if exists ccache; then 13 | export CC="ccache gcc" 14 | export CXX="ccache g++" 15 | fi 16 | 17 | # Initialize venv 18 | python3.11 -m venv .venv 19 | source .venv/bin/activate 20 | 21 | # Install 22 | export SYSTEMRDL_REQUIRE_BINARY_BUILD=1 23 | python -m pip install -U .. 24 | python -m pip install -r requirements.txt pytest-parallel 25 | 26 | # Run unit tests while collecting coverage 27 | pytest --cov=systemrdl 28 | export SYSTEMRDL_DISABLE_ACCELERATOR=1 29 | pytest 30 | 31 | # Generate coverage report 32 | coverage html -i -d htmlcov 33 | 34 | # Also run examples in order to make sure output is up-to-date 35 | ../examples/print_hierarchy.py ../examples/atxmega_spi.rdl > ../docs/examples/print_hierarchy_spi.stdout 36 | ../examples/export_json.py ../examples/tiny.rdl 37 | mv out.json ../examples/tiny.json 38 | 39 | # Run lint 40 | pylint --rcfile pylint.rc -j 0 systemrdl 41 | 42 | # Run static type checking 43 | mypy ../src/systemrdl 44 | -------------------------------------------------------------------------------- /test/test_bridge.py: -------------------------------------------------------------------------------- 1 | from unittest_utils import RDLSourceTestCase 2 | 3 | class TestBridge(RDLSourceTestCase): 4 | 5 | def test_bridge(self): 6 | top = self.compile( 7 | ["rdl_src/bridge.rdl"], 8 | "some_bridge" 9 | ) 10 | 11 | self.assertEqual( 12 | top.find_by_path("some_bridge.ahb.ahb_credits").absolute_address, 13 | 0x0 14 | ) 15 | 16 | self.assertEqual( 17 | top.find_by_path("some_bridge.ahb.ahb_stat").absolute_address, 18 | 0x20 19 | ) 20 | 21 | self.assertEqual( 22 | top.find_by_path("some_bridge.axi.axi_credits").absolute_address, 23 | 0x0 24 | ) 25 | 26 | self.assertEqual( 27 | top.find_by_path("some_bridge.axi.axi_stat").absolute_address, 28 | 0x40 29 | ) 30 | 31 | def test_bridge_errors(self): 32 | self.assertRDLCompileError( 33 | ["rdl_err_src/err_bridge.rdl"], 34 | "illegal_wrapper", 35 | r"The 'bridge' property can only be applied to the root address map" 36 | ) 37 | 38 | self.assertRDLCompileError( 39 | ["rdl_err_src/err_bridge.rdl"], 40 | "not_enough_addrmaps", 41 | r"Addrmap 'not_enough_addrmaps' is a bridge and shall contain 2 or more sub-addrmaps" 42 | ) 43 | 44 | self.assertRDLCompileError( 45 | ["rdl_err_src/err_bridge.rdl"], 46 | "illegal_children", 47 | r"Addrmap 'illegal_children' is a bridge which can only contain other addrmaps. Contains a child instance 'y' which is a reg" 48 | ) 49 | -------------------------------------------------------------------------------- /test/test_dpa_type_names.py: -------------------------------------------------------------------------------- 1 | 2 | from unittest_utils import RDLSourceTestCase 3 | 4 | class TestNodeUtils(RDLSourceTestCase): 5 | 6 | def test_dpa_name_generation(self): 7 | top = self.compile( 8 | ["rdl_src/dpa_names.rdl"], 9 | "dpa_overrides" 10 | ) 11 | 12 | self.assertEqual(top.find_by_path("dpa_overrides.r0.f1").type_name, "my_field") 13 | self.assertEqual(top.find_by_path("dpa_overrides.r0.f2").type_name, "my_field_rclr_t") 14 | self.assertEqual(top.find_by_path("dpa_overrides.r0.f3").type_name, "my_field_encode_onoff_e_next_50a21c60") 15 | self.assertEqual(top.find_by_path("dpa_overrides.r0").type_name, "my_reg") 16 | 17 | self.assertEqual(top.find_by_path("dpa_overrides.r1.f1").type_name, "my_field_rclr_t") 18 | self.assertEqual(top.find_by_path("dpa_overrides.r1.f2").type_name, "my_field_rclr_t") 19 | self.assertEqual(top.find_by_path("dpa_overrides.r1.f3").type_name, "my_field_encode_onoff_e_next_50a21c60") 20 | self.assertEqual(top.find_by_path("dpa_overrides.r1").type_name, "my_reg_f1_4e12afb6") 21 | 22 | self.assertEqual(top.find_by_path("dpa_overrides.r2.f1").type_name, "my_field_next_c9e1f96f") 23 | self.assertEqual(top.find_by_path("dpa_overrides.r2.f2").type_name, "my_field_rclr_t") 24 | self.assertEqual(top.find_by_path("dpa_overrides.r2.f3").type_name, "my_field_encode_onoff_e_next_50a21c60") 25 | self.assertEqual(top.find_by_path("dpa_overrides.r2").type_name, "my_reg_f1_e0f883f9") 26 | -------------------------------------------------------------------------------- /test/test_parse_accelerator.py: -------------------------------------------------------------------------------- 1 | import os 2 | import unittest 3 | 4 | from systemrdl.parser import sa_systemrdl 5 | 6 | class TestInstalled(unittest.TestCase): 7 | def test_installed(self): 8 | if 'SYSTEMRDL_DISABLE_ACCELERATOR' not in os.environ: 9 | # Ensure that C++ accelerator installed correctly 10 | self.assertTrue(sa_systemrdl.USE_CPP_IMPLEMENTATION) 11 | -------------------------------------------------------------------------------- /test/test_prop_typecast.py: -------------------------------------------------------------------------------- 1 | 2 | from unittest_utils import RDLSourceTestCase 3 | import systemrdl.rdltypes as rdlt 4 | 5 | class TestIntr(RDLSourceTestCase): 6 | 7 | def test_intr(self): 8 | top = self.compile( 9 | ["rdl_src/property_typecast.rdl"], 10 | "enum_cast" 11 | ) 12 | 13 | f1 = top.find_by_path("enum_cast.r1.f1") 14 | f2 = top.find_by_path("enum_cast.r1.f2") 15 | f3 = top.find_by_path("enum_cast.r1.f3") 16 | f4 = top.find_by_path("enum_cast.r1.f4") 17 | 18 | self.assertEqual(f1.get_property('reset'), 3) 19 | self.assertEqual(f1.get_property('we'), True) 20 | self.assertEqual(f2.get_property('we'), True) 21 | self.assertEqual(f3.get_property('we'), False) 22 | self.assertEqual(f4.get_property('we'), False) 23 | --------------------------------------------------------------------------------