mirror of
https://github.com/anoma/juvix.git
synced 2025-01-07 08:08:44 +03:00
Add judoc code annotation and face (#2025)
This commit is contained in:
parent
00f5ee9ae1
commit
22742b7a5f
@ -256,6 +256,7 @@ putTag ann x = case ann of
|
|||||||
AnnKeyword -> return (Html.span ! Attr.class_ "ju-keyword" $ x)
|
AnnKeyword -> return (Html.span ! Attr.class_ "ju-keyword" $ x)
|
||||||
AnnUnkindedSym -> return (Html.span ! Attr.class_ "ju-var" $ x)
|
AnnUnkindedSym -> return (Html.span ! Attr.class_ "ju-var" $ x)
|
||||||
AnnComment -> return (Html.span ! Attr.class_ "ju-var" $ x) -- TODO add comment class
|
AnnComment -> return (Html.span ! Attr.class_ "ju-var" $ x) -- TODO add comment class
|
||||||
|
AnnJudoc -> return (Html.span ! Attr.class_ "ju-var" $ x) -- TODO add judoc class
|
||||||
AnnDelimiter -> return (Html.span ! Attr.class_ "ju-delimiter" $ x)
|
AnnDelimiter -> return (Html.span ! Attr.class_ "ju-delimiter" $ x)
|
||||||
AnnDef tmp ni -> boldDefine <*> tagDef tmp ni
|
AnnDef tmp ni -> boldDefine <*> tagDef tmp ni
|
||||||
AnnRef tmp ni -> tagRef tmp ni
|
AnnRef tmp ni -> tagRef tmp ni
|
||||||
|
@ -70,6 +70,7 @@ goFaceParsedItem i = WithLoc (i ^. parsedLoc) (PropertyFace f)
|
|||||||
ParsedTagLiteralString -> FaceString
|
ParsedTagLiteralString -> FaceString
|
||||||
ParsedTagComment -> FaceComment
|
ParsedTagComment -> FaceComment
|
||||||
ParsedTagDelimiter -> FaceDelimiter
|
ParsedTagDelimiter -> FaceDelimiter
|
||||||
|
ParsedTagJudoc -> FaceJudoc
|
||||||
|
|
||||||
goFaceName :: AName -> Maybe (WithLoc PropertyFace)
|
goFaceName :: AName -> Maybe (WithLoc PropertyFace)
|
||||||
goFaceName n = do
|
goFaceName n = do
|
||||||
|
@ -32,6 +32,7 @@ data Face
|
|||||||
| FaceString
|
| FaceString
|
||||||
| FaceNumber
|
| FaceNumber
|
||||||
| FaceComment
|
| FaceComment
|
||||||
|
| FaceJudoc
|
||||||
| FaceError
|
| FaceError
|
||||||
|
|
||||||
faceSymbolStr :: Face -> Text
|
faceSymbolStr :: Face -> Text
|
||||||
@ -45,6 +46,7 @@ faceSymbolStr = \case
|
|||||||
FaceFunction -> Str.function
|
FaceFunction -> Str.function
|
||||||
FaceNumber -> Str.number
|
FaceNumber -> Str.number
|
||||||
FaceComment -> Str.comment
|
FaceComment -> Str.comment
|
||||||
|
FaceJudoc -> Str.judoc
|
||||||
FaceString -> Str.string
|
FaceString -> Str.string
|
||||||
FaceError -> Str.error
|
FaceError -> Str.error
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ fromCodeAnn = \case
|
|||||||
AnnKeyword -> Just (EPropertyFace (PropertyFace FaceKeyword))
|
AnnKeyword -> Just (EPropertyFace (PropertyFace FaceKeyword))
|
||||||
AnnDelimiter -> Just (EPropertyFace (PropertyFace FaceDelimiter))
|
AnnDelimiter -> Just (EPropertyFace (PropertyFace FaceDelimiter))
|
||||||
AnnComment -> Just (EPropertyFace (PropertyFace FaceComment))
|
AnnComment -> Just (EPropertyFace (PropertyFace FaceComment))
|
||||||
|
AnnJudoc -> Just (EPropertyFace (PropertyFace FaceJudoc))
|
||||||
AnnLiteralString -> Just (EPropertyFace (PropertyFace FaceString))
|
AnnLiteralString -> Just (EPropertyFace (PropertyFace FaceString))
|
||||||
AnnLiteralInteger -> Just (EPropertyFace (PropertyFace FaceNumber))
|
AnnLiteralInteger -> Just (EPropertyFace (PropertyFace FaceNumber))
|
||||||
AnnCode -> Nothing
|
AnnCode -> Nothing
|
||||||
|
@ -52,7 +52,7 @@ registerJudocText i =
|
|||||||
registerItem
|
registerItem
|
||||||
ParsedItem
|
ParsedItem
|
||||||
{ _parsedLoc = i,
|
{ _parsedLoc = i,
|
||||||
_parsedTag = ParsedTagComment
|
_parsedTag = ParsedTagJudoc
|
||||||
}
|
}
|
||||||
|
|
||||||
registerLiteral :: Member InfoTableBuilder r => LiteralLoc -> Sem r LiteralLoc
|
registerLiteral :: Member InfoTableBuilder r => LiteralLoc -> Sem r LiteralLoc
|
||||||
|
@ -14,6 +14,7 @@ data ParsedItemTag
|
|||||||
| ParsedTagLiteralString
|
| ParsedTagLiteralString
|
||||||
| ParsedTagComment
|
| ParsedTagComment
|
||||||
| ParsedTagDelimiter
|
| ParsedTagDelimiter
|
||||||
|
| ParsedTagJudoc
|
||||||
deriving stock (Eq, Show, Generic)
|
deriving stock (Eq, Show, Generic)
|
||||||
|
|
||||||
makeLenses ''ParsedItem
|
makeLenses ''ParsedItem
|
||||||
|
@ -174,6 +174,7 @@ stashJudoc = do
|
|||||||
where
|
where
|
||||||
judocBlocks :: ParsecS r (Judoc 'Parsed)
|
judocBlocks :: ParsecS r (Judoc 'Parsed)
|
||||||
judocBlocks = Judoc <$> some judocBlock
|
judocBlocks = Judoc <$> some judocBlock
|
||||||
|
|
||||||
judocBlock :: ParsecS r (JudocBlock 'Parsed)
|
judocBlock :: ParsecS r (JudocBlock 'Parsed)
|
||||||
judocBlock = do
|
judocBlock = do
|
||||||
p <-
|
p <-
|
||||||
@ -188,13 +189,12 @@ stashJudoc = do
|
|||||||
|
|
||||||
judocExample :: ParsecS r (JudocBlock 'Parsed)
|
judocExample :: ParsecS r (JudocBlock 'Parsed)
|
||||||
judocExample = do
|
judocExample = do
|
||||||
-- TODO judocText?
|
|
||||||
P.try (judocStart >> judocExampleStart)
|
P.try (judocStart >> judocExampleStart)
|
||||||
_exampleId <- P.lift freshNameId
|
_exampleId <- P.lift freshNameId
|
||||||
(_exampleExpression, _exampleLoc) <- interval parseExpressionAtoms
|
(_exampleExpression, _exampleLoc) <- interval parseExpressionAtoms
|
||||||
semicolon
|
semicolon
|
||||||
space
|
space
|
||||||
return (JudocExample (Example {..}))
|
return (JudocExample Example {..})
|
||||||
|
|
||||||
judocLine :: ParsecS r (JudocParagraphLine 'Parsed)
|
judocLine :: ParsecS r (JudocParagraphLine 'Parsed)
|
||||||
judocLine = lexeme $ do
|
judocLine = lexeme $ do
|
||||||
@ -213,6 +213,7 @@ judocAtom =
|
|||||||
where
|
where
|
||||||
isValidText :: Char -> Bool
|
isValidText :: Char -> Bool
|
||||||
isValidText = (`notElem` ['\n', ';'])
|
isValidText = (`notElem` ['\n', ';'])
|
||||||
|
|
||||||
judocExpression :: ParsecS r (ExpressionAtoms 'Parsed)
|
judocExpression :: ParsecS r (ExpressionAtoms 'Parsed)
|
||||||
judocExpression = do
|
judocExpression = do
|
||||||
judocText_ (P.char ';')
|
judocText_ (P.char ';')
|
||||||
|
@ -68,7 +68,7 @@ bracedString =
|
|||||||
void (char '\\')
|
void (char '\\')
|
||||||
char '}'
|
char '}'
|
||||||
|
|
||||||
string :: (Members '[InfoTableBuilder] r) => ParsecS r (Text, Interval)
|
string :: Members '[InfoTableBuilder] r => ParsecS r (Text, Interval)
|
||||||
string = lexemeInterval string'
|
string = lexemeInterval string'
|
||||||
|
|
||||||
judocExampleStart :: ParsecS r ()
|
judocExampleStart :: ParsecS r ()
|
||||||
|
@ -18,6 +18,7 @@ data CodeAnn
|
|||||||
| AnnKeyword
|
| AnnKeyword
|
||||||
| AnnCode
|
| AnnCode
|
||||||
| AnnComment
|
| AnnComment
|
||||||
|
| AnnJudoc
|
||||||
| AnnImportant
|
| AnnImportant
|
||||||
| AnnDelimiter
|
| AnnDelimiter
|
||||||
| AnnLiteralString
|
| AnnLiteralString
|
||||||
@ -37,6 +38,7 @@ stylize a = case a of
|
|||||||
AnnCode -> bold
|
AnnCode -> bold
|
||||||
AnnImportant -> bold
|
AnnImportant -> bold
|
||||||
AnnComment -> colorDull Cyan
|
AnnComment -> colorDull Cyan
|
||||||
|
AnnJudoc -> colorDull Cyan
|
||||||
AnnDelimiter -> colorDull White
|
AnnDelimiter -> colorDull White
|
||||||
AnnLiteralString -> colorDull Red
|
AnnLiteralString -> colorDull Red
|
||||||
AnnLiteralInteger -> colorDull Cyan
|
AnnLiteralInteger -> colorDull Cyan
|
||||||
|
@ -77,6 +77,9 @@ public = "public"
|
|||||||
comment :: (IsString s) => s
|
comment :: (IsString s) => s
|
||||||
comment = "comment"
|
comment = "comment"
|
||||||
|
|
||||||
|
judoc :: (IsString s) => s
|
||||||
|
judoc = "judoc"
|
||||||
|
|
||||||
number :: (IsString s) => s
|
number :: (IsString s) => s
|
||||||
number = "number"
|
number = "number"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user