[x3d-public] Thinking of writing ANTLR4 lexer and parser for ClassicVRML

John Carlson yottzumm at gmail.com
Mon Oct 23 08:51:39 PDT 2023


Here's the beginning of an HAnimHumanoid, for example:

('DEF' xs:ID)? 'HAnimHumanoid' '{'
(
   'bboxCenter' SFVec3f
|  'bboxDisplay' SFBool
|  'bboxSize' bboxSizeType
|  'center' SFVec3f
|  'description' SFString
|  'info' MFString
|  'IS' (IS)
|  'jointBindingPositions' MFVec3f
|  'jointBindingRotations' MFRotation
|  'jointBindingScales' MFVec3f
|  'joints' (HAnimJoint)*
|  'loa' loaType
|  'metadata' (X3DMetadataObject)
|  'motions' (HAnimMotion)*
|  'motionsEnabled' MFBool
|  'name' xs:NMTOKEN
|  'rotation' SFRotation
|  'scale' SFVec3f
|  'scaleOrientation' SFRotation
|  'segments' (HAnimSegment)*
|  'sites' (HAnimSite)*
|  'skeletalConfiguration' SFString
|  'skeleton' (HAnimJoint|HAnimSite)*
|  'skin' (Group|Transform|Shape|IndexedFaceSet)*
|  'skinBindingCoords' (Coordinate|CoordinateDouble)
|  'skinBindingNormals' (X3DNormalNode)
|  'skinCoord' (Coordinate|CoordinateDouble)
|  'skinNormal' (X3DNormalNode)
|  'translation' SFVec3f
|  'version' xs:NMTOKEN
|  'viewpoints' (HAnimSite)*
|  'visible' SFBool
|  'class' xs:NMTOKENS
|  'id' xs:NMTOKEN
|  'style' SFString
)*
'}'
| 'USE' xs:IDREF;

On Mon, Oct 23, 2023 at 10:43 AM John Carlson <yottzumm at gmail.com> wrote:

> Hmm.  Looks good.  I am riffing off of:
>
> https://github.com/ingowald/antlr-vrml/blob/master/vrml.g4
>
> I don't know if X3DUOM supports ordering, which probably has
> combinatorial explosion if employed, so I'll probably go for something
> simpler in the long run.
>
> This is interesting, I'm not only targeting Java or Python:
> https://github.com/antlr/antlr4/blob/master/doc/targets.md
>
> Hmm!
>
> John
>
> On Mon, Oct 23, 2023 at 9:19 AM GPU Group <gpugroup at gmail.com> wrote:
>
>> tangentially related, may relate to importer for x3d.py:
>>
>> vrml input
>>
>> https://sourceforge.net/projects/pyvrml97/
>>
>> which uses:
>>
>> from simpleparse.parser import Parser
>>
>> https://pypi.org/project/SimpleParse/
>>
>> - EBNF single pass for largely deterministic grammars
>>
>> parser.py snippet:
>>
>> grammar = r'''
>>
>> header         :=
>> headerStatement,profileStatement,componentStatement*,metaStatement*
>>
>> headerStatement  :=
>> ('#X3D',ts,SFNumber,ts,'utf8',ts,headerComment?,newLine)/('#',headerComment?,newLine)
>>
>> headerComment  := -newLine+
>>
>> profileStatement := 'PROFILE', ts, profileName,newLine
>>
>> profileName    := name
>>
>> <newLine>      := ('\r\n'/'\r'/'\n')
>> ...
>>
>>
>>
>> On Mon, Oct 23, 2023 at 7:47 AM John Carlson <yottzumm at gmail.com> wrote:
>>
>>> Hmm.
>>>
>>> I'm thinking about generating a Classic VRML grammar from X3DUOM using
>>> Python, and then using ANTLR4 to generate Java code for inclusion in
>>> various experiments with GraalVM's Polyglot, Truffle, etc.
>>>
>>> Hmm.
>>>
>>> Hmm.
>>>
>>> Hmm.
>>>
>>> Maybe in another life.
>>>
>>> John
>>> _______________________________________________
>>> x3d-public mailing list
>>> x3d-public at web3d.org
>>> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20231023/9245a8d3/attachment.html>


More information about the x3d-public mailing list