mirror of
https://github.com/github/semantic.git
synced 2024-12-26 00:12:29 +03:00
Respond with a oneof of terms types
This commit is contained in:
parent
04f6ecc223
commit
44a3780d3b
@ -44,6 +44,12 @@ message ParseTreeResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message RawParseTreeResponse {
|
message RawParseTreeResponse {
|
||||||
|
oneof response_type {
|
||||||
|
RubyResponse ruby_response = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message RubyResponse {
|
||||||
repeated RubyTerm terms = 1;
|
repeated RubyTerm terms = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
import "types.proto";
|
||||||
package github.semantic;
|
package github.semantic;
|
||||||
message RubyTerm { RubySyntax syntax = 1;
|
message RubyTerm { RubySyntax syntax = 1;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,9 @@ enum Language {UNKNOWN = 0;
|
|||||||
enum VertexType {PACKAGE = 0;
|
enum VertexType {PACKAGE = 0;
|
||||||
MODULE = 1;
|
MODULE = 1;
|
||||||
VARIABLE = 2;}
|
VARIABLE = 2;}
|
||||||
|
message ErrorSite { string errorMessage = 1;
|
||||||
|
SrcLoc errorLocation = 2;
|
||||||
|
}
|
||||||
message Blob { bytes blobSource = 1;
|
message Blob { bytes blobSource = 1;
|
||||||
string blobPath = 2;
|
string blobPath = 2;
|
||||||
Language blobLanguage = 3;
|
Language blobLanguage = 3;
|
||||||
@ -22,9 +25,6 @@ message Blob { bytes blobSource = 1;
|
|||||||
message Edge { uint64 edgeFrom = 1;
|
message Edge { uint64 edgeFrom = 1;
|
||||||
uint64 edgeTo = 2;
|
uint64 edgeTo = 2;
|
||||||
}
|
}
|
||||||
message ErrorSite { string errorMessage = 1;
|
|
||||||
SrcLoc errorLocation = 2;
|
|
||||||
}
|
|
||||||
message ImportGraph { repeated Vertex graphVertices = 1;
|
message ImportGraph { repeated Vertex graphVertices = 1;
|
||||||
repeated Edge graphEdges = 2;
|
repeated Edge graphEdges = 2;
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ import qualified Data.Syntax.Statement as Statement
|
|||||||
import qualified Data.Term as Term
|
import qualified Data.Term as Term
|
||||||
import qualified Language.Ruby.Syntax as Ruby.Syntax
|
import qualified Language.Ruby.Syntax as Ruby.Syntax
|
||||||
import Prologue hiding (for)
|
import Prologue hiding (for)
|
||||||
|
import Proto3.Suite (Named1(..), Named(..))
|
||||||
|
|
||||||
-- | The type of Ruby syntax.
|
-- | The type of Ruby syntax.
|
||||||
type Syntax = '[
|
type Syntax = '[
|
||||||
@ -124,6 +125,12 @@ type Syntax = '[
|
|||||||
type Term = Term.Term (Sum Syntax) (Record Location)
|
type Term = Term.Term (Sum Syntax) (Record Location)
|
||||||
type Assignment = Assignment.Assignment [] Grammar
|
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 Ruby’s grammar onto a program in Ruby’s syntax.
|
-- | Assignment from AST in Ruby’s grammar onto a program in Ruby’s syntax.
|
||||||
assignment :: Assignment Term
|
assignment :: Assignment Term
|
||||||
assignment = handleError $ makeTerm <$> symbol Program <*> children (Statement.Statements <$> many expression) <|> parseError
|
assignment = handleError $ makeTerm <$> symbol Program <*> children (Statement.Statements <$> many expression) <|> parseError
|
||||||
|
Loading…
Reference in New Issue
Block a user