1
1
mirror of https://github.com/anoma/juvix.git synced 2025-01-05 22:46:08 +03:00

Add judoc code annotation and face (#2025)

This commit is contained in:
janmasrovira 2023-04-24 11:19:08 +02:00 committed by GitHub
parent 00f5ee9ae1
commit 22742b7a5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 16 additions and 4 deletions

View File

@ -256,6 +256,7 @@ putTag ann x = case ann of
AnnKeyword -> return (Html.span ! Attr.class_ "ju-keyword" $ x)
AnnUnkindedSym -> return (Html.span ! Attr.class_ "ju-var" $ x)
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)
AnnDef tmp ni -> boldDefine <*> tagDef tmp ni
AnnRef tmp ni -> tagRef tmp ni

View File

@ -70,6 +70,7 @@ goFaceParsedItem i = WithLoc (i ^. parsedLoc) (PropertyFace f)
ParsedTagLiteralString -> FaceString
ParsedTagComment -> FaceComment
ParsedTagDelimiter -> FaceDelimiter
ParsedTagJudoc -> FaceJudoc
goFaceName :: AName -> Maybe (WithLoc PropertyFace)
goFaceName n = do

View File

@ -32,6 +32,7 @@ data Face
| FaceString
| FaceNumber
| FaceComment
| FaceJudoc
| FaceError
faceSymbolStr :: Face -> Text
@ -45,6 +46,7 @@ faceSymbolStr = \case
FaceFunction -> Str.function
FaceNumber -> Str.number
FaceComment -> Str.comment
FaceJudoc -> Str.judoc
FaceString -> Str.string
FaceError -> Str.error

View File

@ -25,6 +25,7 @@ fromCodeAnn = \case
AnnKeyword -> Just (EPropertyFace (PropertyFace FaceKeyword))
AnnDelimiter -> Just (EPropertyFace (PropertyFace FaceDelimiter))
AnnComment -> Just (EPropertyFace (PropertyFace FaceComment))
AnnJudoc -> Just (EPropertyFace (PropertyFace FaceJudoc))
AnnLiteralString -> Just (EPropertyFace (PropertyFace FaceString))
AnnLiteralInteger -> Just (EPropertyFace (PropertyFace FaceNumber))
AnnCode -> Nothing

View File

@ -52,7 +52,7 @@ registerJudocText i =
registerItem
ParsedItem
{ _parsedLoc = i,
_parsedTag = ParsedTagComment
_parsedTag = ParsedTagJudoc
}
registerLiteral :: Member InfoTableBuilder r => LiteralLoc -> Sem r LiteralLoc

View File

@ -14,6 +14,7 @@ data ParsedItemTag
| ParsedTagLiteralString
| ParsedTagComment
| ParsedTagDelimiter
| ParsedTagJudoc
deriving stock (Eq, Show, Generic)
makeLenses ''ParsedItem

View File

@ -174,6 +174,7 @@ stashJudoc = do
where
judocBlocks :: ParsecS r (Judoc 'Parsed)
judocBlocks = Judoc <$> some judocBlock
judocBlock :: ParsecS r (JudocBlock 'Parsed)
judocBlock = do
p <-
@ -188,13 +189,12 @@ stashJudoc = do
judocExample :: ParsecS r (JudocBlock 'Parsed)
judocExample = do
-- TODO judocText?
P.try (judocStart >> judocExampleStart)
_exampleId <- P.lift freshNameId
(_exampleExpression, _exampleLoc) <- interval parseExpressionAtoms
semicolon
space
return (JudocExample (Example {..}))
return (JudocExample Example {..})
judocLine :: ParsecS r (JudocParagraphLine 'Parsed)
judocLine = lexeme $ do
@ -213,6 +213,7 @@ judocAtom =
where
isValidText :: Char -> Bool
isValidText = (`notElem` ['\n', ';'])
judocExpression :: ParsecS r (ExpressionAtoms 'Parsed)
judocExpression = do
judocText_ (P.char ';')

View File

@ -68,7 +68,7 @@ bracedString =
void (char '\\')
char '}'
string :: (Members '[InfoTableBuilder] r) => ParsecS r (Text, Interval)
string :: Members '[InfoTableBuilder] r => ParsecS r (Text, Interval)
string = lexemeInterval string'
judocExampleStart :: ParsecS r ()

View File

@ -18,6 +18,7 @@ data CodeAnn
| AnnKeyword
| AnnCode
| AnnComment
| AnnJudoc
| AnnImportant
| AnnDelimiter
| AnnLiteralString
@ -37,6 +38,7 @@ stylize a = case a of
AnnCode -> bold
AnnImportant -> bold
AnnComment -> colorDull Cyan
AnnJudoc -> colorDull Cyan
AnnDelimiter -> colorDull White
AnnLiteralString -> colorDull Red
AnnLiteralInteger -> colorDull Cyan

View File

@ -77,6 +77,9 @@ public = "public"
comment :: (IsString s) => s
comment = "comment"
judoc :: (IsString s) => s
judoc = "judoc"
number :: (IsString s) => s
number = "number"