1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 16:02:43 +03:00

Respond with a oneof of terms types

This commit is contained in:
joshvera 2018-06-29 17:11:23 -04:00
parent 04f6ecc223
commit 44a3780d3b
4 changed files with 17 additions and 3 deletions

View File

@ -44,6 +44,12 @@ message ParseTreeResponse {
}
message RawParseTreeResponse {
oneof response_type {
RubyResponse ruby_response = 1;
}
}
message RubyResponse {
repeated RubyTerm terms = 1;
}

View File

@ -1,4 +1,5 @@
syntax = "proto3";
import "types.proto";
package github.semantic;
message RubyTerm { RubySyntax syntax = 1;
}

View File

@ -15,6 +15,9 @@ enum Language {UNKNOWN = 0;
enum VertexType {PACKAGE = 0;
MODULE = 1;
VARIABLE = 2;}
message ErrorSite { string errorMessage = 1;
SrcLoc errorLocation = 2;
}
message Blob { bytes blobSource = 1;
string blobPath = 2;
Language blobLanguage = 3;
@ -22,9 +25,6 @@ message Blob { bytes blobSource = 1;
message Edge { uint64 edgeFrom = 1;
uint64 edgeTo = 2;
}
message ErrorSite { string errorMessage = 1;
SrcLoc errorLocation = 2;
}
message ImportGraph { repeated Vertex graphVertices = 1;
repeated Edge graphEdges = 2;
}

View File

@ -35,6 +35,7 @@ import qualified Data.Syntax.Statement as Statement
import qualified Data.Term as Term
import qualified Language.Ruby.Syntax as Ruby.Syntax
import Prologue hiding (for)
import Proto3.Suite (Named1(..), Named(..))
-- | The type of Ruby syntax.
type Syntax = '[
@ -124,6 +125,12 @@ type Syntax = '[
type Term = Term.Term (Sum Syntax) (Record Location)
type Assignment = Assignment.Assignment [] Grammar
instance Named1 (Sum Syntax) where
nameOf1 _ = "RubySyntax"
instance Named (Term.Term (Sum Syntax) ()) where
nameOf _ = "RubyTerm"
-- | Assignment from AST in Rubys grammar onto a program in Rubys syntax.
assignment :: Assignment Term
assignment = handleError $ makeTerm <$> symbol Program <*> children (Statement.Statements <$> many expression) <|> parseError