Skip to content

Commit

Permalink
whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Oct 13, 2023
1 parent 4204a97 commit 40176de
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/analysis/m3/LearnPrettyPrinter.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void generateFormatterForC() {

@synopsis{Takes a corpus of example files and an (external) parser for the given language and produces a pretty printing function as Rascal code.}
@description{
If the external parser satisfies the specification in ((analysis::m3::AST)) then this function will learn a basic
If the external parser satisfies the specification in `analysis::m3::AST` then this function will learn a basic
`unparser` (a.k.a. pretty printer) from the corpus of files.
The code that is generated is Rascal code which can be expanded into a module that imports the right AST format, and nothing else.
Expand Down Expand Up @@ -142,4 +142,4 @@ str escape(str s) = visit("<[s]>"[2..-2]) {
};
@synopsis{Waiting for `node.src` to be available in Rascal for good...}
loc \loc(node n) = l when loc l := n.src;
loc \loc(node n) = l when loc l := n.src;
3 changes: 3 additions & 0 deletions src/lang/cpp/AST.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ module lang::cpp::AST

import lang::cpp::TypeSymbol;

// TODO: this should not be used in AST positions, but it is.
data TypeSymbol;

data Declarator(list[Attribute] attributes = [], loc src = |unknown:///|, loc decl = |unknown:///|, bool isMacroExpansion = false)
= \declarator(list[Declaration] pointerOperators, Name name)
| \declarator(list[Declaration] pointerOperators, Name name, Expression initializer)
Expand Down
7 changes: 5 additions & 2 deletions src/lang/cpp/internal/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -579,13 +579,15 @@ public ISet getMacroExpansionsFromTranslationUnit(IASTTranslationUnit tu) {
}

private void addDeclaredType(ISourceLocation decl, IConstructor typ) {
if (toM3)
if (toM3) {
declaredType.insert(vf.tuple(decl, typ));
}
}

private void addFunctionDefinition(ISourceLocation decl, ISourceLocation loc) {
if (toM3)
if (toM3) {
functionDefinitions.insert(vf.tuple(decl, loc));
}
}

public ISet parseForMacros(ISourceLocation file, IList includePath, IMap standardMacros, IMap additionalMacros) {
Expand Down Expand Up @@ -1247,6 +1249,7 @@ else if (definition instanceof ICPPASTFunctionWithTryBlock) {
stack.push(builder.Declaration_functionDefinition(declSpecifier, declarator, vf.listWriter().done(),
stack.pop(), vf.listWriter().done(), loc, isMacroExpansion));
}

addDeclaredType(br.resolveBinding(definition.getDeclarator(), locs.forNode(definition.getDeclarator())), tr.resolveType(definition.getDeclarator()));
addFunctionDefinition(br.resolveBinding(definition.getDeclarator(), loc), loc);
return PROCESS_ABORT;
Expand Down

0 comments on commit 40176de

Please sign in to comment.