Support _S and _P in initialization expressions
authorunc0rr
Mon, 05 Jan 2015 18:30:43 +0300
changeset 10763 161b9104b7b3
parent 10760 fcef7d62d3c4
child 10772 8bef4adb905a
Support _S and _P in initialization expressions
tools/pas2c/Pas2C.hs
tools/pas2c/PascalParser.hs
tools/pas2c/PascalUnitSyntaxTree.hs
--- a/tools/pas2c/Pas2C.hs	Mon Jan 05 11:35:04 2015 +0300
+++ b/tools/pas2c/Pas2C.hs	Mon Jan 05 18:30:43 2015 +0300
@@ -668,6 +668,7 @@
 initExpr2C' (InitHexNumber s) = return $ text "0x" <> (text . map toLower $ s)
 initExpr2C' (InitString [a]) = return . quotes $ text [a]
 initExpr2C' (InitString s) = return $ strInit s
+initExpr2C' (InitPChar s) = return $ doubleQuotes (text $ escapeStr s)
 initExpr2C' (InitChar a) = return $ text "0x" <> text (showHex (read a) "")
 initExpr2C' (InitReference i) = id2C IOLookup i
 initExpr2C' (InitRecord fields) = do
--- a/tools/pas2c/PascalParser.hs	Mon Jan 05 11:35:04 2015 +0300
+++ b/tools/pas2c/PascalParser.hs	Mon Jan 05 18:30:43 2015 +0300
@@ -629,6 +629,8 @@
         , try $ integer pas >>= \i -> notFollowedBy (char' '.') >> (return . InitNumber . show) i
         , try $ float pas >>= return . InitFloat . show
         , try $ integer pas >>= return . InitNumber . show
+        , try (string' "_S" >> stringLiteral pas) >>= return . InitString
+        , try (string' "_P" >> stringLiteral pas) >>= return . InitPChar
         , stringLiteral pas >>= return . InitString
         , char' '#' >> many digit >>= \c -> comments >> return (InitChar c)
         , char' '$' >> many hexDigit >>= \h -> comments >> return (InitHexNumber h)
--- a/tools/pas2c/PascalUnitSyntaxTree.hs	Mon Jan 05 11:35:04 2015 +0300
+++ b/tools/pas2c/PascalUnitSyntaxTree.hs	Mon Jan 05 18:30:43 2015 +0300
@@ -89,6 +89,7 @@
     | InitNumber String
     | InitHexNumber String
     | InitString String
+    | InitPChar String
     | InitChar String
     | BuiltInFunction String [InitExpression]
     | InitSet [InitExpression]