-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2627cf29.0c65a5f9.js
1 lines (1 loc) · 5.4 KB
/
2627cf29.0c65a5f9.js
1
(window.webpackJsonp=window.webpackJsonp||[]).push([[63],{163:function(e,n,r){"use strict";r.r(n),r.d(n,"frontMatter",(function(){return o})),r.d(n,"metadata",(function(){return c})),r.d(n,"rightToc",(function(){return s})),r.d(n,"default",(function(){return p}));var t=r(2),a=r(6),i=(r(0),r(469)),o={title:"Naming Conventions",sidebar_label:"Naming Conventions"},c={id:"version-0.8.0/resources/03_naming_conventions",isDocsHomePage:!1,title:"Naming Conventions",description:"String and Character",source:"@site/versioned_docs/version-0.8.0/resources/03_naming_conventions.md",permalink:"/docs/0.8.0/resources/03_naming_conventions",editUrl:"https://github.com/parsica-php/parsica/tree/main/versioned_docs/version-0.8.0/resources/03_naming_conventions.md",version:"0.8.0",sidebar_label:"Naming Conventions",sidebar:"version-0.8.0/docs",previous:{title:"Performance",permalink:"/docs/0.8.0/resources/02_performance"},next:{title:"Design Goals",permalink:"/docs/0.8.0/contribute/design_goals"},latestVersionMainDocPermalink:"/docs"},s=[{value:"String and Character",id:"string-and-character",children:[]},{value:"Predicates",id:"predicates",children:[]},{value:"Character Parsers",id:"character-parsers",children:[]},{value:"Case",id:"case",children:[]}],l={rightToc:s};function p(e){var n=e.components,r=Object(a.a)(e,["components"]);return Object(i.b)("wrapper",Object(t.a)({},l,r,{components:n,mdxType:"MDXLayout"}),Object(i.b)("h2",{id:"string-and-character"},"String and Character"),Object(i.b)("p",null,"PHP doesn't have a separate type for strings and characters, as opposed to some languages where string is defined as a list of characters. Still, as a convention in Parsica and its documentation, we generally use ",Object(i.b)("inlineCode",{parentName:"p"},"'a'"),", ",Object(i.b)("inlineCode",{parentName:"p"},"'1'")," (single quoted) to indicate a single character, and ",Object(i.b)("inlineCode",{parentName:"p"},'"a"'),", ",Object(i.b)("inlineCode",{parentName:"p"},'"abc123"')," (double quoted) to indicate a string."),Object(i.b)("p",null,"We also use single quotes to indicate constant strings or symbols, such as ",Object(i.b)("inlineCode",{parentName:"p"},"'STATUS_SUCCESS'"),";"),Object(i.b)("h2",{id:"predicates"},"Predicates"),Object(i.b)("p",null,"Predicates are either prefixed with ",Object(i.b)("inlineCode",{parentName:"p"},"is")," or suffixed with ",Object(i.b)("inlineCode",{parentName:"p"},"pred"),"."),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-php"}),"<?php\n$predicate = orPred(isEqual('5'), isEqual('6'));\nassertTrue($predicate('6'));\n")),Object(i.b)("h2",{id:"character-parsers"},"Character Parsers"),Object(i.b)("p",null,"A parser for a single character is always suffixed with ",Object(i.b)("inlineCode",{parentName:"p"},"Char"),", as in ",Object(i.b)("inlineCode",{parentName:"p"},"digitChar()"),". These always output a string."),Object(i.b)("h2",{id:"case"},"Case"),Object(i.b)("p",null,"Some parsers have case-insensitive versions. These are sufficed with 'I'."),Object(i.b)("pre",null,Object(i.b)("code",Object(t.a)({parentName:"pre"},{className:"language-php"}),'<?php\n$parser = stringI(\'hello world\'); \n$result = $parser->tryString("hElLO WoRlD"); \nassertEquals("hElLO WoRlD", $result->output());\n')))}p.isMDXComponent=!0},469:function(e,n,r){"use strict";r.d(n,"a",(function(){return u})),r.d(n,"b",(function(){return m}));var t=r(0),a=r.n(t);function i(e,n,r){return n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function o(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),r.push.apply(r,t)}return r}function c(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?o(Object(r),!0).forEach((function(n){i(e,n,r[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))}))}return e}function s(e,n){if(null==e)return{};var r,t,a=function(e,n){if(null==e)return{};var r,t,a={},i=Object.keys(e);for(t=0;t<i.length;t++)r=i[t],n.indexOf(r)>=0||(a[r]=e[r]);return a}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(t=0;t<i.length;t++)r=i[t],n.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}var l=a.a.createContext({}),p=function(e){var n=a.a.useContext(l),r=n;return e&&(r="function"==typeof e?e(n):c(c({},n),e)),r},u=function(e){var n=p(e.components);return a.a.createElement(l.Provider,{value:n},e.children)},d={inlineCode:"code",wrapper:function(e){var n=e.children;return a.a.createElement(a.a.Fragment,{},n)}},b=a.a.forwardRef((function(e,n){var r=e.components,t=e.mdxType,i=e.originalType,o=e.parentName,l=s(e,["components","mdxType","originalType","parentName"]),u=p(r),b=t,m=u["".concat(o,".").concat(b)]||u[b]||d[b]||i;return r?a.a.createElement(m,c(c({ref:n},l),{},{components:r})):a.a.createElement(m,c({ref:n},l))}));function m(e,n){var r=arguments,t=n&&n.mdxType;if("string"==typeof e||t){var i=r.length,o=new Array(i);o[0]=b;var c={};for(var s in n)hasOwnProperty.call(n,s)&&(c[s]=n[s]);c.originalType=e,c.mdxType="string"==typeof e?e:t,o[1]=c;for(var l=2;l<i;l++)o[l]=r[l];return a.a.createElement.apply(null,o)}return a.a.createElement.apply(null,r)}b.displayName="MDXCreateElement"}}]);