blob: 9a38220c34930cb8cbaae5a999ccb9dec08bc63b [file] [log] [blame]
% Adding New Syntax
%{\scriptsize Last modified }
The process of adding new syntax to Photran is as follows.\footnote{Note that Photran
originally handled Fortran 95, and it was later extended to work with Fortran 2003
and then Fortran 2008; the requisite changes to the lexer, parser, and syntax
highlighting code are fairly clearly marked.}
\item Modify the lexers and parser:
\item Modify the grammar (fortran2008.bnf) to recognize new syntactic constructs, and
modify the phase 1 lexers (FreeFormLexerPhase1.flex and FixedFormLexerPhase1.flex)
to recognize new keywords
\item Add new terminal symbols to
\item Run the build-lexer and build-parser scripts to regenerate the lexers and parser
\item Modify the phase 2 lexer ( to correctly resolve
any new keywords as identifiers
\item Modify the syntax highlighting for the Fortran editor:
\item Modify the list of keywords in FortranKeywordRuleBasedScanner
\item Modify the keyword/identifier resolution rules in SalesScanKeywordRule
\item Modify the model builder (Outline view), if necessary:
\item Add new model elements to, if necessary, and place their
Outline view icons in the org.eclipse.photran.cdtinterface/icons/model folder
\item Modify to visit the new constructs and add
them to the model
\item Modify the name binding analysis, if necessary:
\item \textit{IMPORTANT:}
If you change any classes that implement IPhotranSerializable, or if you
change the ScopingNode class, then be sure to change the VPG database filename
in PhotranVPGDB. This will ensure that end users' code is completely
reindexed using the new versions of the serialized classes.
% Within your runtime workspace, you can simply clear and refresh the VPG
% database (from the Refactor $>$ Debugging menu), but end users should never be
% asked to do this.
\item If any new syntactic constructs are subclasses of ScopingNode, there are
several methods in the ScopingNode class that will need to be modified to
handle the new node type. Currently, these are easy to identify because they
all contain large numbers of
``instanceof'' tests (which is ugly; we will eventually do this the ``right''
way and dispatch dynamically to the subclasses after the parser generator
allows custom subclasses)
\item If the new syntax contains identifiers, modify the ReferenceCollector to bind
any identifiers in new syntactic constructs to their declarations
\item Similarly, if necessary, modify the DefinitionCollector to add any new
declarations to the VPG database
\item Modify the other collector classes in the same package if necessary