import CPPParser; //============================================================ // COMAspect Language //------------------------------------------------------------ COMAspect = COMComp COMGlue. //============================================================ // COM-Comp Language //------------------------------------------------------------ COMComp = "COM-Comp" "{" SList(ComponentDescription) "}". ComponentDescription = ComponentNameDescription "from" ClassDescription "{" InterfaceList "}" ";". ComponentNameDescription = "component" ComponentName. ClassDescription = "class" ClassName "in" FileName. InterfaceList : List(InterfaceDescription). InterfaceDescription = "interface" InterfaceName "{" MethodList "}" ";". MethodList : List(Method). Method = "method" InterfaceMethodName OptionalMethodMap ";". OptionalMethodMap : List(MethodMap). MethodMap = "mapsto" ClassMethodName. //============================================================ // COM-Glue Language //------------------------------------------------------------ COMGlue = "COM-Glue" "{" SList(GlueItem) "}". GlueItem : ComponentGlue | InterfaceGlue. ComponentGlue = "component" ComponentName "{" SList(ComponentGlueItem) "}" ";". ComponentGlueItem : ClassIDEntry | FriendlyNameEntry | ProgIDEntry | VersionIndProgIDEntry. ClassIDEntry = "CLSID" "=" ClassID ";". FriendlyNameEntry = "FriendlyName" "=" FriendlyName ";". ProgIDEntry = "ProgID" "=" ProgID ";". VersionIndProgIDEntry = "VersionIndProgID" "=" VersionIndProgID ";". InterfaceGlue = "interface" InterfaceName "{" SList(InterfaceGlueItem) "}" ";". InterfaceGlueItem : InterfaceIDEntry. InterfaceIDEntry = "IID" "=" InterfaceID ";". ComponentName = String. ClassName = String. FileName = String. InterfaceName = String. ClassMethodName = String. InterfaceMethodName = String. ClassID = Identifier. FriendlyName = String. ProgID = String. VersionIndProgID = String. InterfaceID = Identifier. Identifier = String. //============================================================ // Generic Stuff //------------------------------------------------------------ List(S) ~ {S}. SList(S) ~ S { *l S } *l . Main = . //============================================================ // Partial C++ Parser // Does not support external class declarations // Does not support function pointer arguments // Only supports built-in types // Member functions and their args MUST start with capital letters //------------------------------------------------------------ *noparse* CPPProgram = TranslationUnit. TranslationUnit = NPList(ExternalDeclaration). ExternalDeclaration = Declaration. Declaration = DeclarationSpecifiers. DeclarationSpecifiers : UnknownTypeSpecifier | TypeSpecifier | ClassSpecifier *common* boolean. UnknownTypeSpecifier = . TypeSpecifier = String. ClassSpecifier = ClassName NPList(MemberDeclaration). MemberDeclaration : FunctionDefinition. FunctionDefinition = FunctionName ReturnType NPList(ParameterDeclaration) Scope. ParameterDeclaration = TypeSpecifier Declarator. Declarator = NPList(AnyPointerOperator) String. FunctionName = String. ParameterName = String. AnyPointerOperator : PointerOperator | EPointerOperator. PointerOperator = String. EPointerOperator = . ReturnType = TypeSpecifier. NPList(S) ~{S}. *parse* //============================================================ // Visitors (old school) //------------------------------------------------------------ *noparse* COMEmittingVisitor = CPPProgram COMAspect. InterfaceDeclVisitor = String String String CPPProgram COMAspect. FuncPrototypeEmittingVisitor = String String String String boolean boolean Integer String. GUIDEmittingVisitor = String String boolean boolean. RegisteringVisitor = String String String String String boolean boolean. InterfaceListingVisitor = String Integer. MethodDeclVisitor = String String CPPProgram. QueryInterfaceEmittingVisitor = String Integer. ComponentMethodEmittingVisitor = String String String CPPProgram. ParamNameListingVisitor = String Integer String String boolean boolean boolean String. *parse*